diff options
| author | A.J. Shulman <Shulman.aj@gmail.com> | 2025-04-27 13:14:49 -0400 |
|---|---|---|
| committer | A.J. Shulman <Shulman.aj@gmail.com> | 2025-04-27 13:14:49 -0400 |
| commit | 3ef3d40506348d9fd537cc8f4aea975b9770689f (patch) | |
| tree | afe779e8240e88c8b20ff6b68ac45840a927ee76 /src/client/views/nodes/chatbot/tools | |
| parent | 5ce2263849bfb901e276a4c5fc8ca2dbd8b80350 (diff) | |
new attempt with new citation unification
Diffstat (limited to 'src/client/views/nodes/chatbot/tools')
| -rw-r--r-- | src/client/views/nodes/chatbot/tools/DocumentMetadataTool.ts | 16 | ||||
| -rw-r--r-- | src/client/views/nodes/chatbot/tools/SearchTool.ts | 18 |
2 files changed, 19 insertions, 15 deletions
diff --git a/src/client/views/nodes/chatbot/tools/DocumentMetadataTool.ts b/src/client/views/nodes/chatbot/tools/DocumentMetadataTool.ts index 4b751acc0..e6c2421e5 100644 --- a/src/client/views/nodes/chatbot/tools/DocumentMetadataTool.ts +++ b/src/client/views/nodes/chatbot/tools/DocumentMetadataTool.ts @@ -417,9 +417,9 @@ export class DocumentMetadataTool extends BaseTool<DocumentMetadataToolParamsTyp const title = String(args.title); const data = String(args.data); - const createdDoc = this._docManager.createDocInDash(docType, title, data); + const id = this._docManager.createDocInDash(docType, data, { title: title }); - if (!createdDoc) { + if (!id) { return [ { type: 'text', @@ -427,18 +427,14 @@ export class DocumentMetadataTool extends BaseTool<DocumentMetadataToolParamsTyp }, ]; } - - // Update our local document maps with the new document - this._docManager.processDocument(createdDoc); - // Get the created document's metadata - const createdMetadata = this._docManager.extractDocumentMetadata(this._docManager.createAgentDoc(createdDoc)); + const createdMetadata = this._docManager.extractDocumentMetadata(id); return [ { type: 'text', text: `Document created successfully. -Document ID: ${createdDoc.id} +Document ID: ${id} Type: ${docType} Title: "${title}" @@ -447,9 +443,9 @@ You can now use the "edit" action to modify additional properties of this docume Next steps: 1. Use the "getFieldOptions" action to understand available editable/addable fields/properties and their dependencies. -2. To modify this document, use: { action: "edit", documentId: "${createdDoc.id}", fieldEdits: [{"fieldName":"property","fieldValue":"value"}] } +2. To modify this document, use: { action: "edit", documentId: "${id}", fieldEdits: [{"fieldName":"property","fieldValue":"value"}] } 3. To add styling, consider setting backgroundColor, fontColor, or other properties -4. For text documents, you can edit the content with: { action: "edit", documentId: "${createdDoc.id}", fieldEdits: [{"fieldName":"text","fieldValue":"New content"}] } +4. For text documents, you can edit the content with: { action: "edit", documentId: "${id}", fieldEdits: [{"fieldName":"text","fieldValue":"New content"}] } Full metadata for the created document: ${JSON.stringify(createdMetadata, null, 2)}`, diff --git a/src/client/views/nodes/chatbot/tools/SearchTool.ts b/src/client/views/nodes/chatbot/tools/SearchTool.ts index 2ee30f0cf..53f5fc109 100644 --- a/src/client/views/nodes/chatbot/tools/SearchTool.ts +++ b/src/client/views/nodes/chatbot/tools/SearchTool.ts @@ -3,6 +3,9 @@ import { Networking } from '../../../../Network'; import { BaseTool } from './BaseTool'; import { Observation } from '../types/types'; import { ParametersType, ToolInfo } from '../types/tool_types'; +import { Agent } from 'http'; +import { AgentDocumentManager } from '../utils/AgentDocumentManager'; +import { StrCast } from '../../../../../fields/Types'; const searchToolParams = [ { @@ -25,12 +28,12 @@ const searchToolInfo: ToolInfo<SearchToolParamsType> = { }; export class SearchTool extends BaseTool<SearchToolParamsType> { - private _addLinkedUrlDoc: (url: string, id: string) => void; + private _docManager: AgentDocumentManager; private _max_results: number; - constructor(addLinkedUrlDoc: (url: string, id: string) => void, max_results: number = 3) { + constructor(docManager: AgentDocumentManager, max_results: number = 3) { super(searchToolInfo); - this._addLinkedUrlDoc = addLinkedUrlDoc; + this._docManager = docManager; this._max_results = max_results; } @@ -46,8 +49,13 @@ export class SearchTool extends BaseTool<SearchToolParamsType> { max_results: this._max_results, })) as { results: { url: string; snippet: string }[] }; const data = results.map((result: { url: string; snippet: string }) => { - const id = uuidv4(); - this._addLinkedUrlDoc(result.url, id); + // Create a web document with the URL + const id = this._docManager.createDocInDash('web', result.url, { + title: `Search Result: ${result.url}`, + text_html: result.snippet, + data_useCors: true, + }); + return { type: 'text' as const, text: `<chunk chunk_id="${id}" chunk_type="url"><url>${result.url}</url><overview>${result.snippet}</overview></chunk>`, |
