Syntax changes in front and back end dirs. These do not affect functionality and are purely intended to better capture and describe the app's functionality and purpose

This commit is contained in:
KS Jannette
2026-08-03 00:07:58 -04:00
parent 4a5e5d6612
commit 0352bdf516
42 changed files with 812 additions and 812 deletions

View File

@@ -7,8 +7,8 @@ import type { ScoredChunk, RankedChunk, TextChunk } from '../services/retrievalS
import { generate } from '../services/generationService.js';
import type { GenerationResult } from '../services/generationService.js';
import { computeGroundedness } from '../services/scoringService.js';
import * as notebookStore from '../stores/notebookStore.js';
import type { SourceGroup } from '../stores/notebookStore.js';
import * as sourceCorpusStore from '../stores/sourceCorpusStore.js';
import type { SourceGroup } from '../stores/sourceCorpusStore.js';
const TOP_K_SEARCH = 20;
const TOP_K_RERANK = 5;
@@ -16,7 +16,7 @@ const TOP_K_RERANK = 5;
const router = Router();
interface QueryBody {
notebookId?: string;
sourceCorpusId?: string;
question?: string;
}
@@ -36,20 +36,20 @@ interface QueryResponse {
router.post('/', async (req: Request<unknown, unknown, QueryBody>, res: Response, next: NextFunction) => {
try {
const { notebookId, question } = req.body;
if (!notebookId || !question) {
res.status(400).json({ error: 'notebookId and question are required' });
const { sourceCorpusId, question } = req.body;
if (!sourceCorpusId || !question) {
res.status(400).json({ error: 'sourceCorpusId and question are required' });
return;
}
logger.info({ notebookId, question }, 'query received');
logger.info({ sourceCorpusId, question }, 'query received');
const [queryEmbedding]: number[][] = await embedTexts([question], 'query');
const searchResults: ScoredChunk[] = search(queryEmbedding, notebookId, TOP_K_SEARCH);
const searchResults: ScoredChunk[] = search(queryEmbedding, sourceCorpusId, TOP_K_SEARCH);
if (searchResults.length === 0) {
res.json({
answer: 'No sources found for this notebook. Upload some documents first.',
answer: 'No sources found for this source corpus. Upload some documents first.',
citations: [],
groundednessScore: null,
followUpQuestions: [],
@@ -69,7 +69,7 @@ router.post('/', async (req: Request<unknown, unknown, QueryBody>, res: Response
'retrieval complete'
);
const sourceGroups: SourceGroup[] = notebookStore.buildSourceGroups(notebookId, topChunks);
const sourceGroups: SourceGroup[] = sourceCorpusStore.buildSourceGroups(sourceCorpusId, topChunks);
const { answer, citedSourceIndices, followUpQuestions }: GenerationResult = await generate(question, sourceGroups);