aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/chatbot/agentsystem/Agent.ts
diff options
context:
space:
mode:
authorA.J. Shulman <Shulman.aj@gmail.com>2025-04-27 14:57:39 -0400
committerA.J. Shulman <Shulman.aj@gmail.com>2025-04-27 14:57:39 -0400
commit393b7f8286422c933102449eba1ba82874a48896 (patch)
treec34cd5dffc7306a66fcfe54c81d8656c341facb9 /src/client/views/nodes/chatbot/agentsystem/Agent.ts
parent67a7996278ce176e227393fa410e7afc80228a83 (diff)
improved consistency across doc types and parsing
Diffstat (limited to 'src/client/views/nodes/chatbot/agentsystem/Agent.ts')
-rw-r--r--src/client/views/nodes/chatbot/agentsystem/Agent.ts15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/client/views/nodes/chatbot/agentsystem/Agent.ts b/src/client/views/nodes/chatbot/agentsystem/Agent.ts
index 80fdb6533..24471bf5b 100644
--- a/src/client/views/nodes/chatbot/agentsystem/Agent.ts
+++ b/src/client/views/nodes/chatbot/agentsystem/Agent.ts
@@ -41,7 +41,6 @@ export class Agent {
private interMessages: AgentMessage[] = [];
private vectorstore: Vectorstore;
private _history: () => string;
- private _summaries: () => string;
private _csvData: () => { filename: string; id: string; text: string }[];
private actionNumber: number = 0;
private thoughtNumber: number = 0;
@@ -54,11 +53,13 @@ export class Agent {
/**
* The constructor initializes the agent with the vector store and toolset, and sets up the OpenAI client.
* @param _vectorstore Vector store instance for document storage and retrieval.
- * @param summaries A function to retrieve document summaries.
+ * @param summaries A function to retrieve document summaries (deprecated, now using docManager directly).
* @param history A function to retrieve chat history.
* @param csvData A function to retrieve CSV data linked to the assistant.
- * @param addLinkedUrlDoc A function to add a linked document from a URL.
+ * @param getLinkedUrlDocId A function to get document IDs from URLs.
+ * @param createImage A function to create images in the dashboard.
* @param createCSVInDash A function to create a CSV document in the dashboard.
+ * @param docManager The document manager instance.
*/
constructor(
_vectorstore: Vectorstore,
@@ -74,7 +75,6 @@ export class Agent {
this.client = new OpenAI({ apiKey: process.env.OPENAI_KEY, dangerouslyAllowBrowser: true });
this.vectorstore = _vectorstore;
this._history = history;
- this._summaries = summaries;
this._csvData = csvData;
this._docManager = docManager;
@@ -124,7 +124,12 @@ export class Agent {
// Retrieve chat history and generate system prompt
const chatHistory = this._history();
- const systemPrompt = getReactPrompt(Object.values(this.tools), this._summaries, chatHistory);
+ // Get document summaries directly from document manager
+ const documentSummaries = this._docManager.getAllDocumentSummaries();
+ // Create a function that returns document summaries for the prompt
+ const getSummaries = () => documentSummaries;
+ // Generate the system prompt with the summaries
+ const systemPrompt = getReactPrompt(Object.values(this.tools), getSummaries, chatHistory);
// Initialize intermediate messages
this.interMessages = [{ role: 'system', content: systemPrompt }];