From 834ca4e21fead079e681b963e2d533d93a53cb91 Mon Sep 17 00:00:00 2001 From: "A.J. Shulman" Date: Mon, 22 Jul 2024 10:49:02 -0400 Subject: fixing summaries by having them part of the ReAct prompt --- src/client/views/nodes/ChatBox/Agent.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/client/views/nodes/ChatBox/Agent.ts') diff --git a/src/client/views/nodes/ChatBox/Agent.ts b/src/client/views/nodes/ChatBox/Agent.ts index a3b1d083c..d494928f9 100644 --- a/src/client/views/nodes/ChatBox/Agent.ts +++ b/src/client/views/nodes/ChatBox/Agent.ts @@ -19,25 +19,27 @@ export class Agent { private interMessages: AgentMessage[] = []; private vectorstore: Vectorstore; private _history: () => string; + private _summaries: () => string; constructor(_vectorstore: Vectorstore, summaries: () => string, history: () => string) { this.client = new OpenAI({ apiKey: process.env.OPENAI_KEY, dangerouslyAllowBrowser: true }); this.vectorstore = _vectorstore; this._history = history; + this._summaries = summaries; this.tools = { wikipedia: new WikipediaTool(), calculate: new CalculateTool(), - rag: new RAGTool(this.vectorstore, summaries), + rag: new RAGTool(this.vectorstore), no_tool: new NoTool(), }; } - async askAgent(question: string, maxTurns: number = 8): Promise { + async askAgent(question: string, maxTurns: number = 10): Promise { console.log(`Starting query: ${question}`); this.messages.push({ role: 'user', content: question }); const chatHistory = this._history(); console.log(`Chat history: ${chatHistory}`); - const systemPrompt = getReactPrompt(Object.values(this.tools), chatHistory); + const systemPrompt = getReactPrompt(Object.values(this.tools), this._summaries, chatHistory); console.log(`System prompt: ${systemPrompt}`); this.interMessages = [{ role: 'system', content: systemPrompt }]; -- cgit v1.2.3-70-g09d2