@@ -14,6 +14,7 @@ import { summarize } from "$lib/server/summarize";
14
14
import { uploadImgFile } from "$lib/server/files/uploadFile" ;
15
15
import sizeof from "image-size" ;
16
16
import RAGs from "$lib/server/rag/rag" ;
17
+ import type { RagContext } from "$lib/types/rag" ;
17
18
18
19
export async function POST ( { request, locals, params, getClientAddress } ) {
19
20
const id = z . string ( ) . parse ( params . id ) ;
@@ -235,12 +236,16 @@ export async function POST({ request, locals, params, getClientAddress }) {
235
236
let webSearchResults : RagContextWebSearch | undefined ;
236
237
237
238
if ( webSearch ) {
238
- webSearchResults = await RAGs [ "webSearch" ] . retrieveRagContext ( conv , newPrompt , update ) ;
239
+ webSearchResults = ( await RAGs [ "webSearch" ] . retrieveRagContext (
240
+ conv ,
241
+ newPrompt ,
242
+ update
243
+ ) ) as RagContextWebSearch ;
239
244
}
240
245
241
246
messages [ messages . length - 1 ] . ragContext = webSearchResults ;
242
247
243
- let pdfSearchResults : PdfSearch | undefined ;
248
+ let pdfSearchResults : RagContext | undefined ;
244
249
const pdfSearch = await collections . files . findOne ( { filename : `${ convId . toString ( ) } -pdf` } ) ;
245
250
if ( pdfSearch ) {
246
251
pdfSearchResults = await RAGs [ "pdfChat" ] . retrieveRagContext ( conv , newPrompt , update ) ;
@@ -274,7 +279,7 @@ export async function POST({ request, locals, params, getClientAddress }) {
274
279
{
275
280
from : "assistant" ,
276
281
content : output . token . text . trimStart ( ) ,
277
- webSearch : webSearchResults ,
282
+ ragContext : webSearchResults ,
278
283
updates : updates ,
279
284
id : ( responseId as Message [ "id" ] ) || crypto . randomUUID ( ) ,
280
285
createdAt : new Date ( ) ,
0 commit comments