From ba0adc57af41c3bd2ccc4ac22e31ea233aa29ab4 Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Thu, 21 Mar 2024 17:35:09 -0300 Subject: [PATCH] new(gpt.gblib): Wikipedia feature. --- packages/gpt.gblib/services/ChatServices.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/gpt.gblib/services/ChatServices.ts b/packages/gpt.gblib/services/ChatServices.ts index 42ea784c..51927952 100644 --- a/packages/gpt.gblib/services/ChatServices.ts +++ b/packages/gpt.gblib/services/ChatServices.ts @@ -50,6 +50,7 @@ import { Serialized } from "@langchain/core/load/serializable"; import { BaseCallbackHandler } from "@langchain/core/callbacks/base"; import { pdfToPng, PngPageOutput } from 'pdf-to-png-converter'; import { DynamicStructuredTool } from "@langchain/core/tools"; +import { WikipediaQueryRun } from "@langchain/community/tools/wikipedia_query_run"; import { BaseLLMOutputParser, OutputParserException, @@ -276,7 +277,9 @@ export class ChatServices { AIMessagePromptTemplate.fromTemplate( ` Answer the question without calling any tool, but if there is a need to call: - You have access to the following set of tools. Here are the names and descriptions for each tool: + You have access to the following set of tools. + Here are the names and descriptions for each tool: + ${toolsAsText} Do not use any previous tools output in the chat_history. @@ -457,6 +460,12 @@ export class ChatServices { }); + const tool = new WikipediaQueryRun({ + topKResults: 3, + maxDocContentLength: 4000, + }); + functions.push(tool); + return functions; } }