From 43feb52788c5c4241c5c17f1ffc1ccfcd1992761 Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Wed, 17 Apr 2024 15:36:08 -0300 Subject: [PATCH] new(core.gbapp): New API endpoint. --- packages/gpt.gblib/services/ChatServices.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/gpt.gblib/services/ChatServices.ts b/packages/gpt.gblib/services/ChatServices.ts index fb810237..3559da9b 100644 --- a/packages/gpt.gblib/services/ChatServices.ts +++ b/packages/gpt.gblib/services/ChatServices.ts @@ -138,13 +138,13 @@ export class GBLLMOutputParser extends } let { sources, text } = res; - + await CollectionUtil.asyncForEach(sources, async (source) => { let found = false; if (source) { - + const gbaiName = DialogKeywords.getGBAIPath(this.min.botId, 'gbkb'); - const localName = Path.join(process.env.PWD,'work', gbaiName, 'docs', source.file); + const localName = Path.join(process.env.PWD, 'work', gbaiName, 'docs', source.file); if (localName) { const { url } = await ChatServices.pdfPageAsImage(this.min, localName, source.page); @@ -214,7 +214,7 @@ export class ChatServices { let output = ''; - for(const filePaths of Object.keys(uniqueDocuments)) { + for (const filePaths of Object.keys(uniqueDocuments)) { const doc = uniqueDocuments[filePaths]; const metadata = doc.metadata; const filename = Path.basename(metadata.source); @@ -492,12 +492,14 @@ export class ChatServices { }); - const tool = new WikipediaQueryRun({ - topKResults: 3, - maxDocContentLength: 4000, - }); - functions.push(tool); + if (process.env.WIKIPEDIA_TOOL) { + const tool = new WikipediaQueryRun({ + topKResults: 3, + maxDocContentLength: 4000, + }); + functions.push(tool); + } return functions; } }