diff --git a/agent/tools/retrieval.py b/agent/tools/retrieval.py index a6e1e4fcd..156469811 100644 --- a/agent/tools/retrieval.py +++ b/agent/tools/retrieval.py @@ -163,9 +163,16 @@ class Retrieval(ToolBase, ABC): self.set_output("formalized_content", self._param.empty_response) return + # Format the chunks for JSON output (similar to how other tools do it) + json_output = kbinfos["chunks"].copy() + self._canvas.add_reference(kbinfos["chunks"], kbinfos["doc_aggs"]) form_cnt = "\n".join(kb_prompt(kbinfos, 200000, True)) + + # Set both formalized content and JSON output self.set_output("formalized_content", form_cnt) + self.set_output("json", json_output) + return form_cnt def thoughts(self) -> str: diff --git a/web/src/pages/agent/constant.tsx b/web/src/pages/agent/constant.tsx index ef7aed18a..5abad0a03 100644 --- a/web/src/pages/agent/constant.tsx +++ b/web/src/pages/agent/constant.tsx @@ -263,6 +263,10 @@ export const initialRetrievalValues = { type: 'string', value: '', }, + json: { + type: 'Array', + value: [], + }, }, }; diff --git a/web/src/pages/agent/form/retrieval-form/next.tsx b/web/src/pages/agent/form/retrieval-form/next.tsx index 425d08e4b..69204d4da 100644 --- a/web/src/pages/agent/form/retrieval-form/next.tsx +++ b/web/src/pages/agent/form/retrieval-form/next.tsx @@ -83,6 +83,10 @@ function RetrievalForm({ node }: INextOperatorForm) { title: 'formalized_content', type: initialRetrievalValues.outputs.formalized_content.type, }, + { + title: 'json', + type: initialRetrievalValues.outputs.json.type, + }, ]; }, []); diff --git a/web/src/pages/data-flow/constant.tsx b/web/src/pages/data-flow/constant.tsx index d1d124f48..85967bb67 100644 --- a/web/src/pages/data-flow/constant.tsx +++ b/web/src/pages/data-flow/constant.tsx @@ -133,6 +133,10 @@ export const initialRetrievalValues = { type: 'string', value: '', }, + json: { + type: 'Array', + value: [], + }, }, }; diff --git a/web/src/pages/data-flow/form/retrieval-form/next.tsx b/web/src/pages/data-flow/form/retrieval-form/next.tsx index 425d08e4b..69204d4da 100644 --- a/web/src/pages/data-flow/form/retrieval-form/next.tsx +++ b/web/src/pages/data-flow/form/retrieval-form/next.tsx @@ -83,6 +83,10 @@ function RetrievalForm({ node }: INextOperatorForm) { title: 'formalized_content', type: initialRetrievalValues.outputs.formalized_content.type, }, + { + title: 'json', + type: initialRetrievalValues.outputs.json.type, + }, ]; }, []);