@rodrigocoliveira/agno-react 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/components/GenerativeUIRenderer.d.ts +21 -0
- package/dist/components/GenerativeUIRenderer.d.ts.map +1 -0
- package/dist/context/AgnoContext.d.ts +16 -0
- package/dist/context/AgnoContext.d.ts.map +1 -0
- package/dist/context/ToolHandlerContext.d.ts +44 -0
- package/dist/context/ToolHandlerContext.d.ts.map +1 -0
- package/dist/hooks/useAgnoActions.d.ts +25 -0
- package/dist/hooks/useAgnoActions.d.ts.map +1 -0
- package/dist/hooks/useAgnoChat.d.ts +22 -0
- package/dist/hooks/useAgnoChat.d.ts.map +1 -0
- package/dist/hooks/useAgnoCustomEvents.d.ts +38 -0
- package/dist/hooks/useAgnoCustomEvents.d.ts.map +1 -0
- package/dist/hooks/useAgnoEvals.d.ts +39 -0
- package/dist/hooks/useAgnoEvals.d.ts.map +1 -0
- package/dist/hooks/useAgnoKnowledge.d.ts +56 -0
- package/dist/hooks/useAgnoKnowledge.d.ts.map +1 -0
- package/dist/hooks/useAgnoMemory.d.ts +42 -0
- package/dist/hooks/useAgnoMemory.d.ts.map +1 -0
- package/dist/hooks/useAgnoMetrics.d.ts +51 -0
- package/dist/hooks/useAgnoMetrics.d.ts.map +1 -0
- package/dist/hooks/useAgnoSession.d.ts +38 -0
- package/dist/hooks/useAgnoSession.d.ts.map +1 -0
- package/dist/hooks/useAgnoToolExecution.d.ts +70 -0
- package/dist/hooks/useAgnoToolExecution.d.ts.map +1 -0
- package/dist/hooks/useAgnoTraces.d.ts +51 -0
- package/dist/hooks/useAgnoTraces.d.ts.map +1 -0
- package/dist/index.d.ts +27 -723
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +932 -1052
- package/dist/index.js.map +24 -0
- package/dist/index.mjs +816 -909
- package/dist/index.mjs.map +24 -0
- package/dist/ui/components/artifact.d.ts +24 -0
- package/dist/ui/components/artifact.d.ts.map +1 -0
- package/dist/ui/components/audio-recorder.d.ts +32 -0
- package/dist/ui/components/audio-recorder.d.ts.map +1 -0
- package/dist/ui/components/code-block.d.ts +15 -0
- package/dist/ui/components/code-block.d.ts.map +1 -0
- package/dist/ui/components/conversation.d.ts +17 -0
- package/dist/ui/components/conversation.d.ts.map +1 -0
- package/dist/ui/components/file-preview-card.d.ts +13 -0
- package/dist/ui/components/file-preview-card.d.ts.map +1 -0
- package/dist/ui/components/file-preview-modal.d.ts +8 -0
- package/dist/ui/components/file-preview-modal.d.ts.map +1 -0
- package/dist/ui/components/image-lightbox.d.ts +12 -0
- package/dist/ui/components/image-lightbox.d.ts.map +1 -0
- package/dist/ui/components/message.d.ts +19 -0
- package/dist/ui/components/message.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/attachments.d.ts +21 -0
- package/dist/ui/components/prompt-input/attachments.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/buttons.d.ts +19 -0
- package/dist/ui/components/prompt-input/buttons.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/command.d.ts +17 -0
- package/dist/ui/components/prompt-input/command.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/context.d.ts +36 -0
- package/dist/ui/components/prompt-input/context.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/drop-zone.d.ts +7 -0
- package/dist/ui/components/prompt-input/drop-zone.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/footer.d.ts +11 -0
- package/dist/ui/components/prompt-input/footer.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/index.d.ts +25 -0
- package/dist/ui/components/prompt-input/index.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/model-select.d.ts +13 -0
- package/dist/ui/components/prompt-input/model-select.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/prompt-input.d.ts +22 -0
- package/dist/ui/components/prompt-input/prompt-input.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/provider.d.ts +6 -0
- package/dist/ui/components/prompt-input/provider.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/speech.d.ts +51 -0
- package/dist/ui/components/prompt-input/speech.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/tabs.d.ts +12 -0
- package/dist/ui/components/prompt-input/tabs.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/textarea.d.ts +5 -0
- package/dist/ui/components/prompt-input/textarea.d.ts.map +1 -0
- package/dist/ui/components/response.d.ts +5 -0
- package/dist/ui/components/response.d.ts.map +1 -0
- package/dist/ui/components/smart-timestamp.d.ts +8 -0
- package/dist/ui/components/smart-timestamp.d.ts.map +1 -0
- package/dist/ui/components/streaming-indicator.d.ts +8 -0
- package/dist/ui/components/streaming-indicator.d.ts.map +1 -0
- package/dist/ui/components/tool.d.ts +24 -0
- package/dist/ui/components/tool.d.ts.map +1 -0
- package/dist/ui/composed/AgnoChatInput.d.ts +44 -0
- package/dist/ui/composed/AgnoChatInput.d.ts.map +1 -0
- package/dist/ui/composed/AgnoChatInterface.d.ts +49 -0
- package/dist/ui/composed/AgnoChatInterface.d.ts.map +1 -0
- package/dist/ui/composed/AgnoMessageItem.d.ts +38 -0
- package/dist/ui/composed/AgnoMessageItem.d.ts.map +1 -0
- package/dist/ui/composed/agno-chat/agno-chat.d.ts +9 -0
- package/dist/ui/composed/agno-chat/agno-chat.d.ts.map +1 -0
- package/dist/ui/composed/agno-chat/context.d.ts +33 -0
- package/dist/ui/composed/agno-chat/context.d.ts.map +1 -0
- package/dist/ui/composed/agno-chat/empty-state.d.ts +6 -0
- package/dist/ui/composed/agno-chat/empty-state.d.ts.map +1 -0
- package/dist/ui/composed/agno-chat/error-bar.d.ts +5 -0
- package/dist/ui/composed/agno-chat/error-bar.d.ts.map +1 -0
- package/dist/ui/composed/agno-chat/index.d.ts +33 -0
- package/dist/ui/composed/agno-chat/index.d.ts.map +1 -0
- package/dist/ui/composed/agno-chat/input.d.ts +39 -0
- package/dist/ui/composed/agno-chat/input.d.ts.map +1 -0
- package/dist/ui/composed/agno-chat/messages.d.ts +21 -0
- package/dist/ui/composed/agno-chat/messages.d.ts.map +1 -0
- package/dist/ui/composed/agno-chat/suggested-prompts.d.ts +7 -0
- package/dist/ui/composed/agno-chat/suggested-prompts.d.ts.map +1 -0
- package/dist/ui/composed/agno-chat/tool-status.d.ts +5 -0
- package/dist/ui/composed/agno-chat/tool-status.d.ts.map +1 -0
- package/dist/ui/composed/index.d.ts +9 -0
- package/dist/ui/composed/index.d.ts.map +1 -0
- package/dist/ui/index.d.ts +59 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/lib/cn.d.ts +3 -0
- package/dist/ui/lib/cn.d.ts.map +1 -0
- package/dist/ui/lib/file-utils.d.ts +20 -0
- package/dist/ui/lib/file-utils.d.ts.map +1 -0
- package/dist/ui/lib/format-timestamp.d.ts +16 -0
- package/dist/ui/lib/format-timestamp.d.ts.map +1 -0
- package/dist/ui/primitives/accordion.d.ts +8 -0
- package/dist/ui/primitives/accordion.d.ts.map +1 -0
- package/dist/ui/primitives/avatar.d.ts +7 -0
- package/dist/ui/primitives/avatar.d.ts.map +1 -0
- package/dist/ui/primitives/badge.d.ts +10 -0
- package/dist/ui/primitives/badge.d.ts.map +1 -0
- package/dist/ui/primitives/button.d.ts +12 -0
- package/dist/ui/primitives/button.d.ts.map +1 -0
- package/dist/ui/primitives/collapsible.d.ts +6 -0
- package/dist/ui/primitives/collapsible.d.ts.map +1 -0
- package/dist/ui/primitives/command.d.ts +79 -0
- package/dist/ui/primitives/command.d.ts.map +1 -0
- package/dist/ui/primitives/dialog.d.ts +26 -0
- package/dist/ui/primitives/dialog.d.ts.map +1 -0
- package/dist/ui/primitives/dropdown-menu.d.ts +28 -0
- package/dist/ui/primitives/dropdown-menu.d.ts.map +1 -0
- package/dist/ui/primitives/hover-card.d.ts +7 -0
- package/dist/ui/primitives/hover-card.d.ts.map +1 -0
- package/dist/ui/primitives/index.d.ts +16 -0
- package/dist/ui/primitives/index.d.ts.map +1 -0
- package/dist/ui/primitives/input-group.d.ts +17 -0
- package/dist/ui/primitives/input-group.d.ts.map +1 -0
- package/dist/ui/primitives/select.d.ts +14 -0
- package/dist/ui/primitives/select.d.ts.map +1 -0
- package/dist/ui/primitives/tooltip.d.ts +8 -0
- package/dist/ui/primitives/tooltip.d.ts.map +1 -0
- package/dist/ui/types.d.ts +56 -0
- package/dist/ui/types.d.ts.map +1 -0
- package/dist/ui.d.ts +2 -891
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +2757 -2323
- package/dist/ui.js.map +60 -0
- package/dist/ui.mjs +2644 -2055
- package/dist/ui.mjs.map +60 -0
- package/dist/utils/component-registry.d.ts +63 -0
- package/dist/utils/component-registry.d.ts.map +1 -0
- package/dist/utils/ui-helpers.d.ts +165 -0
- package/dist/utils/ui-helpers.d.ts.map +1 -0
- package/package.json +9 -10
- package/LICENSE +0 -21
- package/dist/index.d.mts +0 -724
- package/dist/ui.d.mts +0 -891
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/context/AgnoContext.tsx
|
|
2
2
|
import { createContext, useContext, useMemo, useEffect } from "react";
|
|
3
3
|
import { AgnoClient } from "@rodrigocoliveira/agno-client";
|
|
4
|
-
import {
|
|
4
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
5
5
|
var AgnoContext = createContext(null);
|
|
6
6
|
function AgnoProvider({ config, children }) {
|
|
7
7
|
const client = useMemo(() => new AgnoClient(config), []);
|
|
@@ -13,7 +13,10 @@ function AgnoProvider({ config, children }) {
|
|
|
13
13
|
client.removeAllListeners();
|
|
14
14
|
};
|
|
15
15
|
}, [client]);
|
|
16
|
-
return /* @__PURE__ */
|
|
16
|
+
return /* @__PURE__ */ jsxDEV(AgnoContext.Provider, {
|
|
17
|
+
value: client,
|
|
18
|
+
children
|
|
19
|
+
}, undefined, false, undefined, this);
|
|
17
20
|
}
|
|
18
21
|
function useAgnoClient() {
|
|
19
22
|
const client = useContext(AgnoContext);
|
|
@@ -22,10 +25,9 @@ function useAgnoClient() {
|
|
|
22
25
|
}
|
|
23
26
|
return client;
|
|
24
27
|
}
|
|
25
|
-
|
|
26
28
|
// src/context/ToolHandlerContext.tsx
|
|
27
29
|
import { createContext as createContext2, useContext as useContext2, useState, useCallback } from "react";
|
|
28
|
-
import {
|
|
30
|
+
import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
|
|
29
31
|
var ToolHandlerContext = createContext2(null);
|
|
30
32
|
function ToolHandlerProvider({ handlers: initialHandlers = {}, children }) {
|
|
31
33
|
const [handlers, setHandlers] = useState(initialHandlers);
|
|
@@ -43,74 +45,52 @@ function ToolHandlerProvider({ handlers: initialHandlers = {}, children }) {
|
|
|
43
45
|
registerHandler,
|
|
44
46
|
unregisterHandler
|
|
45
47
|
};
|
|
46
|
-
return /* @__PURE__ */
|
|
48
|
+
return /* @__PURE__ */ jsxDEV2(ToolHandlerContext.Provider, {
|
|
49
|
+
value,
|
|
50
|
+
children
|
|
51
|
+
}, undefined, false, undefined, this);
|
|
47
52
|
}
|
|
48
53
|
function useToolHandlers() {
|
|
49
54
|
return useContext2(ToolHandlerContext);
|
|
50
55
|
}
|
|
51
|
-
|
|
52
56
|
// src/components/GenerativeUIRenderer.tsx
|
|
53
57
|
import React3 from "react";
|
|
54
58
|
|
|
55
59
|
// src/utils/component-registry.ts
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Get the singleton instance
|
|
62
|
-
*/
|
|
60
|
+
class ComponentRegistry {
|
|
61
|
+
static instance;
|
|
62
|
+
components = new Map;
|
|
63
|
+
constructor() {}
|
|
63
64
|
static getInstance() {
|
|
64
|
-
if (!
|
|
65
|
-
|
|
65
|
+
if (!ComponentRegistry.instance) {
|
|
66
|
+
ComponentRegistry.instance = new ComponentRegistry;
|
|
66
67
|
}
|
|
67
|
-
return
|
|
68
|
+
return ComponentRegistry.instance;
|
|
68
69
|
}
|
|
69
|
-
/**
|
|
70
|
-
* Register a component renderer
|
|
71
|
-
*/
|
|
72
70
|
register(type, renderer) {
|
|
73
71
|
this.components.set(type, renderer);
|
|
74
72
|
}
|
|
75
|
-
/**
|
|
76
|
-
* Register multiple components at once
|
|
77
|
-
*/
|
|
78
73
|
registerBatch(components) {
|
|
79
74
|
Object.entries(components).forEach(([type, renderer]) => {
|
|
80
75
|
this.register(type, renderer);
|
|
81
76
|
});
|
|
82
77
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Get a registered component renderer
|
|
85
|
-
*/
|
|
86
78
|
get(type) {
|
|
87
79
|
return this.components.get(type);
|
|
88
80
|
}
|
|
89
|
-
/**
|
|
90
|
-
* Check if a component is registered
|
|
91
|
-
*/
|
|
92
81
|
has(type) {
|
|
93
82
|
return this.components.has(type);
|
|
94
83
|
}
|
|
95
|
-
/**
|
|
96
|
-
* Unregister a component
|
|
97
|
-
*/
|
|
98
84
|
unregister(type) {
|
|
99
85
|
this.components.delete(type);
|
|
100
86
|
}
|
|
101
|
-
/**
|
|
102
|
-
* Get all registered component types
|
|
103
|
-
*/
|
|
104
87
|
getRegisteredTypes() {
|
|
105
88
|
return Array.from(this.components.keys());
|
|
106
89
|
}
|
|
107
|
-
/**
|
|
108
|
-
* Clear all registered components
|
|
109
|
-
*/
|
|
110
90
|
clear() {
|
|
111
91
|
this.components.clear();
|
|
112
92
|
}
|
|
113
|
-
}
|
|
93
|
+
}
|
|
114
94
|
function getComponentRegistry() {
|
|
115
95
|
return ComponentRegistry.getInstance();
|
|
116
96
|
}
|
|
@@ -123,7 +103,7 @@ function getChartComponent(name) {
|
|
|
123
103
|
|
|
124
104
|
// src/hooks/useAgnoToolExecution.ts
|
|
125
105
|
import { useState as useState2, useEffect as useEffect2, useCallback as useCallback2, useMemo as useMemo2 } from "react";
|
|
126
|
-
var customRenderRegistry =
|
|
106
|
+
var customRenderRegistry = new Map;
|
|
127
107
|
function registerCustomRender(renderFn) {
|
|
128
108
|
const key = `custom-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
129
109
|
customRenderRegistry.set(key, renderFn);
|
|
@@ -133,7 +113,7 @@ function getCustomRender(key) {
|
|
|
133
113
|
return customRenderRegistry.get(key);
|
|
134
114
|
}
|
|
135
115
|
function isToolHandlerResult(value) {
|
|
136
|
-
return value && typeof value === "object" && ("data" in value || "ui" in value);
|
|
116
|
+
return value && typeof value === "object" && (("data" in value) || ("ui" in value));
|
|
137
117
|
}
|
|
138
118
|
function isUIComponentSpec(value) {
|
|
139
119
|
return value && typeof value === "object" && "type" in value;
|
|
@@ -141,15 +121,14 @@ function isUIComponentSpec(value) {
|
|
|
141
121
|
function processToolResult(result, _tool) {
|
|
142
122
|
if (isToolHandlerResult(result)) {
|
|
143
123
|
const { data, ui } = result;
|
|
144
|
-
let uiComponent =
|
|
124
|
+
let uiComponent = undefined;
|
|
145
125
|
if (ui) {
|
|
146
126
|
if (ui.type === "custom" && typeof ui.render === "function") {
|
|
147
127
|
const renderKey = registerCustomRender(ui.render);
|
|
148
128
|
uiComponent = {
|
|
149
129
|
...ui,
|
|
150
130
|
renderKey,
|
|
151
|
-
render:
|
|
152
|
-
// Don't store the function itself
|
|
131
|
+
render: undefined
|
|
153
132
|
};
|
|
154
133
|
} else {
|
|
155
134
|
uiComponent = ui;
|
|
@@ -167,7 +146,7 @@ function processToolResult(result, _tool) {
|
|
|
167
146
|
uiComponent = {
|
|
168
147
|
...result,
|
|
169
148
|
renderKey,
|
|
170
|
-
render:
|
|
149
|
+
render: undefined
|
|
171
150
|
};
|
|
172
151
|
} else {
|
|
173
152
|
uiComponent = result;
|
|
@@ -179,7 +158,7 @@ function processToolResult(result, _tool) {
|
|
|
179
158
|
}
|
|
180
159
|
return {
|
|
181
160
|
resultData: typeof result === "string" ? result : JSON.stringify(result),
|
|
182
|
-
uiComponent:
|
|
161
|
+
uiComponent: undefined
|
|
183
162
|
};
|
|
184
163
|
}
|
|
185
164
|
function useAgnoToolExecution(handlers = {}, autoExecute = true) {
|
|
@@ -188,9 +167,7 @@ function useAgnoToolExecution(handlers = {}, autoExecute = true) {
|
|
|
188
167
|
const isTeamMode = client.getConfig().mode === "team";
|
|
189
168
|
useEffect2(() => {
|
|
190
169
|
if (isTeamMode) {
|
|
191
|
-
console.warn(
|
|
192
|
-
"[useAgnoToolExecution] HITL (Human-in-the-Loop) frontend tool execution is not supported for teams. Only agents support the continue endpoint. This hook will not function in team mode."
|
|
193
|
-
);
|
|
170
|
+
console.warn("[useAgnoToolExecution] HITL (Human-in-the-Loop) frontend tool execution is not supported for teams. " + "Only agents support the continue endpoint. This hook will not function in team mode.");
|
|
194
171
|
}
|
|
195
172
|
}, [isTeamMode]);
|
|
196
173
|
const mergedHandlers = useMemo2(() => {
|
|
@@ -208,13 +185,13 @@ function useAgnoToolExecution(handlers = {}, autoExecute = true) {
|
|
|
208
185
|
const handleRunPaused = (event) => {
|
|
209
186
|
setIsPaused(true);
|
|
210
187
|
setPendingTools(event.tools);
|
|
211
|
-
setExecutionError(
|
|
188
|
+
setExecutionError(undefined);
|
|
212
189
|
};
|
|
213
190
|
const handleRunContinued = () => {
|
|
214
191
|
setIsPaused(false);
|
|
215
192
|
setPendingTools([]);
|
|
216
193
|
setIsExecuting(false);
|
|
217
|
-
setExecutionError(
|
|
194
|
+
setExecutionError(undefined);
|
|
218
195
|
};
|
|
219
196
|
client.on("run:paused", handleRunPaused);
|
|
220
197
|
client.on("run:continued", handleRunContinued);
|
|
@@ -229,37 +206,35 @@ function useAgnoToolExecution(handlers = {}, autoExecute = true) {
|
|
|
229
206
|
return;
|
|
230
207
|
}
|
|
231
208
|
setIsExecuting(true);
|
|
232
|
-
setExecutionError(
|
|
209
|
+
setExecutionError(undefined);
|
|
233
210
|
try {
|
|
234
|
-
const updatedTools = await Promise.all(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
})
|
|
262
|
-
);
|
|
211
|
+
const updatedTools = await Promise.all(pendingTools.map(async (tool) => {
|
|
212
|
+
const handler = mergedHandlers[tool.tool_name];
|
|
213
|
+
if (!handler) {
|
|
214
|
+
return {
|
|
215
|
+
...tool,
|
|
216
|
+
result: JSON.stringify({
|
|
217
|
+
error: `No handler registered for ${tool.tool_name}`
|
|
218
|
+
})
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
try {
|
|
222
|
+
const result = await handler(tool.tool_args);
|
|
223
|
+
const { resultData, uiComponent } = processToolResult(result, tool);
|
|
224
|
+
return {
|
|
225
|
+
...tool,
|
|
226
|
+
result: resultData,
|
|
227
|
+
ui_component: uiComponent
|
|
228
|
+
};
|
|
229
|
+
} catch (error) {
|
|
230
|
+
return {
|
|
231
|
+
...tool,
|
|
232
|
+
result: JSON.stringify({
|
|
233
|
+
error: error instanceof Error ? error.message : String(error)
|
|
234
|
+
})
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
}));
|
|
263
238
|
const toolsWithUI = updatedTools.filter((t) => t.ui_component);
|
|
264
239
|
if (toolsWithUI.length > 0) {
|
|
265
240
|
client.emit("ui:render", {
|
|
@@ -280,11 +255,14 @@ function useAgnoToolExecution(handlers = {}, autoExecute = true) {
|
|
|
280
255
|
const handleSessionLoaded = async (_sessionId) => {
|
|
281
256
|
const messages = client.getMessages();
|
|
282
257
|
for (const message of messages) {
|
|
283
|
-
if (!message.tool_calls)
|
|
258
|
+
if (!message.tool_calls)
|
|
259
|
+
continue;
|
|
284
260
|
for (const tool of message.tool_calls) {
|
|
285
|
-
if (tool.ui_component)
|
|
261
|
+
if (tool.ui_component)
|
|
262
|
+
continue;
|
|
286
263
|
const handler = mergedHandlers[tool.tool_name];
|
|
287
|
-
if (!handler)
|
|
264
|
+
if (!handler)
|
|
265
|
+
continue;
|
|
288
266
|
try {
|
|
289
267
|
const result = await handler(tool.tool_args);
|
|
290
268
|
const { uiComponent } = processToolResult(result, tool);
|
|
@@ -302,74 +280,61 @@ function useAgnoToolExecution(handlers = {}, autoExecute = true) {
|
|
|
302
280
|
client.off("session:loaded", handleSessionLoaded);
|
|
303
281
|
};
|
|
304
282
|
}, [client, mergedHandlers]);
|
|
305
|
-
const executeTools = useCallback2(
|
|
306
|
-
async (
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
if (!handler) return tool;
|
|
311
|
-
try {
|
|
312
|
-
const result = await handler(tool.tool_args);
|
|
313
|
-
const { resultData, uiComponent } = processToolResult(result, tool);
|
|
314
|
-
return {
|
|
315
|
-
...tool,
|
|
316
|
-
result: resultData,
|
|
317
|
-
ui_component: uiComponent
|
|
318
|
-
};
|
|
319
|
-
} catch (error) {
|
|
320
|
-
return {
|
|
321
|
-
...tool,
|
|
322
|
-
result: JSON.stringify({
|
|
323
|
-
error: error instanceof Error ? error.message : String(error)
|
|
324
|
-
})
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
})
|
|
328
|
-
);
|
|
329
|
-
},
|
|
330
|
-
[mergedHandlers]
|
|
331
|
-
);
|
|
332
|
-
const continueWithResults = useCallback2(
|
|
333
|
-
async (tools, options) => {
|
|
334
|
-
if (!isPaused) {
|
|
335
|
-
throw new Error("No paused run to continue");
|
|
336
|
-
}
|
|
337
|
-
setIsExecuting(true);
|
|
283
|
+
const executeTools = useCallback2(async (tools) => {
|
|
284
|
+
return Promise.all(tools.map(async (tool) => {
|
|
285
|
+
const handler = mergedHandlers[tool.tool_name];
|
|
286
|
+
if (!handler)
|
|
287
|
+
return tool;
|
|
338
288
|
try {
|
|
339
|
-
await
|
|
289
|
+
const result = await handler(tool.tool_args);
|
|
290
|
+
const { resultData, uiComponent } = processToolResult(result, tool);
|
|
291
|
+
return {
|
|
292
|
+
...tool,
|
|
293
|
+
result: resultData,
|
|
294
|
+
ui_component: uiComponent
|
|
295
|
+
};
|
|
340
296
|
} catch (error) {
|
|
341
|
-
|
|
342
|
-
|
|
297
|
+
return {
|
|
298
|
+
...tool,
|
|
299
|
+
result: JSON.stringify({
|
|
300
|
+
error: error instanceof Error ? error.message : String(error)
|
|
301
|
+
})
|
|
302
|
+
};
|
|
343
303
|
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
)
|
|
304
|
+
}));
|
|
305
|
+
}, [mergedHandlers]);
|
|
306
|
+
const continueWithResults = useCallback2(async (tools, options) => {
|
|
307
|
+
if (!isPaused) {
|
|
308
|
+
throw new Error("No paused run to continue");
|
|
309
|
+
}
|
|
310
|
+
setIsExecuting(true);
|
|
311
|
+
try {
|
|
312
|
+
await client.continueRun(tools, options);
|
|
313
|
+
} catch (error) {
|
|
314
|
+
setIsExecuting(false);
|
|
315
|
+
throw error;
|
|
316
|
+
}
|
|
317
|
+
}, [client, isPaused]);
|
|
347
318
|
useEffect2(() => {
|
|
348
319
|
if (autoExecute && isPaused && !isExecuting && pendingTools.length > 0) {
|
|
349
320
|
executeAndContinue();
|
|
350
321
|
}
|
|
351
322
|
}, [autoExecute, isPaused, isExecuting, pendingTools.length, executeAndContinue]);
|
|
352
323
|
return {
|
|
353
|
-
/** Whether the run is currently paused awaiting tool execution */
|
|
354
324
|
isPaused,
|
|
355
|
-
/** Whether tools are currently being executed */
|
|
356
325
|
isExecuting,
|
|
357
|
-
/** Tools awaiting execution */
|
|
358
326
|
pendingTools,
|
|
359
|
-
/** Execute all pending tools and continue the run */
|
|
360
327
|
executeAndContinue,
|
|
361
|
-
/** Execute specific tools and return results without continuing */
|
|
362
328
|
executeTools,
|
|
363
|
-
/** Continue the run with manually provided tool results */
|
|
364
329
|
continueWithResults,
|
|
365
|
-
/** Error from tool execution, if any */
|
|
366
330
|
executionError
|
|
367
331
|
};
|
|
368
332
|
}
|
|
369
333
|
|
|
370
334
|
// src/components/GenerativeUIRenderer.tsx
|
|
371
|
-
import {
|
|
372
|
-
|
|
335
|
+
import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
|
|
336
|
+
|
|
337
|
+
class UIErrorBoundary extends React3.Component {
|
|
373
338
|
constructor(props) {
|
|
374
339
|
super(props);
|
|
375
340
|
this.state = { hasError: false };
|
|
@@ -383,14 +348,23 @@ var UIErrorBoundary = class extends React3.Component {
|
|
|
383
348
|
}
|
|
384
349
|
render() {
|
|
385
350
|
if (this.state.hasError) {
|
|
386
|
-
return this.props.fallback || /* @__PURE__ */
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
351
|
+
return this.props.fallback || /* @__PURE__ */ jsxDEV3("div", {
|
|
352
|
+
className: "p-4 border border-red-300 rounded-md bg-red-50 text-red-800",
|
|
353
|
+
children: [
|
|
354
|
+
/* @__PURE__ */ jsxDEV3("p", {
|
|
355
|
+
className: "font-semibold",
|
|
356
|
+
children: "Failed to render UI component"
|
|
357
|
+
}, undefined, false, undefined, this),
|
|
358
|
+
/* @__PURE__ */ jsxDEV3("p", {
|
|
359
|
+
className: "text-sm mt-1",
|
|
360
|
+
children: this.state.error?.message || "Unknown error"
|
|
361
|
+
}, undefined, false, undefined, this)
|
|
362
|
+
]
|
|
363
|
+
}, undefined, true, undefined, this);
|
|
390
364
|
}
|
|
391
365
|
return this.props.children;
|
|
392
366
|
}
|
|
393
|
-
}
|
|
367
|
+
}
|
|
394
368
|
function GenerativeUIRenderer({
|
|
395
369
|
spec,
|
|
396
370
|
className,
|
|
@@ -402,78 +376,184 @@ function GenerativeUIRenderer({
|
|
|
402
376
|
if (customSpec.renderKey) {
|
|
403
377
|
const renderFn = getCustomRender(customSpec.renderKey);
|
|
404
378
|
if (renderFn) {
|
|
405
|
-
return /* @__PURE__ */
|
|
379
|
+
return /* @__PURE__ */ jsxDEV3(UIErrorBoundary, {
|
|
380
|
+
onError,
|
|
381
|
+
children: /* @__PURE__ */ jsxDEV3("div", {
|
|
382
|
+
className,
|
|
383
|
+
children: renderFn(customSpec.props || {})
|
|
384
|
+
}, undefined, false, undefined, this)
|
|
385
|
+
}, undefined, false, undefined, this);
|
|
406
386
|
}
|
|
407
387
|
}
|
|
408
|
-
return /* @__PURE__ */
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
388
|
+
return /* @__PURE__ */ jsxDEV3("div", {
|
|
389
|
+
className: `p-4 border border-yellow-300 rounded-md bg-yellow-50 text-yellow-800 ${className || ""}`,
|
|
390
|
+
children: [
|
|
391
|
+
/* @__PURE__ */ jsxDEV3("p", {
|
|
392
|
+
className: "font-semibold",
|
|
393
|
+
children: "Custom component not available"
|
|
394
|
+
}, undefined, false, undefined, this),
|
|
395
|
+
/* @__PURE__ */ jsxDEV3("p", {
|
|
396
|
+
className: "text-sm mt-1",
|
|
397
|
+
children: "The custom render function for this component is not available."
|
|
398
|
+
}, undefined, false, undefined, this)
|
|
399
|
+
]
|
|
400
|
+
}, undefined, true, undefined, this);
|
|
412
401
|
}
|
|
413
402
|
if (spec.type === "chart") {
|
|
414
403
|
const chartSpec = spec;
|
|
415
404
|
const chartType = `chart:${chartSpec.component}`;
|
|
416
405
|
if (registry.has(chartType)) {
|
|
417
406
|
const ChartRenderer = registry.get(chartType);
|
|
418
|
-
return /* @__PURE__ */
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
407
|
+
return /* @__PURE__ */ jsxDEV3(UIErrorBoundary, {
|
|
408
|
+
onError,
|
|
409
|
+
children: /* @__PURE__ */ jsxDEV3("div", {
|
|
410
|
+
className,
|
|
411
|
+
children: [
|
|
412
|
+
chartSpec.title && /* @__PURE__ */ jsxDEV3("h3", {
|
|
413
|
+
className: "font-semibold mb-2",
|
|
414
|
+
children: chartSpec.title
|
|
415
|
+
}, undefined, false, undefined, this),
|
|
416
|
+
chartSpec.description && /* @__PURE__ */ jsxDEV3("p", {
|
|
417
|
+
className: "text-sm text-gray-600 mb-4",
|
|
418
|
+
children: chartSpec.description
|
|
419
|
+
}, undefined, false, undefined, this),
|
|
420
|
+
/* @__PURE__ */ jsxDEV3(ChartRenderer, {
|
|
421
|
+
...chartSpec.props
|
|
422
|
+
}, undefined, false, undefined, this)
|
|
423
|
+
]
|
|
424
|
+
}, undefined, true, undefined, this)
|
|
425
|
+
}, undefined, false, undefined, this);
|
|
426
|
+
}
|
|
427
|
+
return /* @__PURE__ */ jsxDEV3("div", {
|
|
428
|
+
className: `p-4 border border-gray-300 rounded-md ${className || ""}`,
|
|
429
|
+
children: [
|
|
430
|
+
/* @__PURE__ */ jsxDEV3("p", {
|
|
431
|
+
className: "font-semibold mb-2",
|
|
432
|
+
children: chartSpec.title || "Chart Data"
|
|
433
|
+
}, undefined, false, undefined, this),
|
|
434
|
+
chartSpec.description && /* @__PURE__ */ jsxDEV3("p", {
|
|
435
|
+
className: "text-sm text-gray-600 mb-2",
|
|
436
|
+
children: chartSpec.description
|
|
437
|
+
}, undefined, false, undefined, this),
|
|
438
|
+
/* @__PURE__ */ jsxDEV3("pre", {
|
|
439
|
+
className: "text-xs bg-gray-100 p-2 rounded overflow-auto",
|
|
440
|
+
children: JSON.stringify(chartSpec.props.data, null, 2)
|
|
441
|
+
}, undefined, false, undefined, this)
|
|
442
|
+
]
|
|
443
|
+
}, undefined, true, undefined, this);
|
|
429
444
|
}
|
|
430
445
|
if (spec.type === "card-grid") {
|
|
431
446
|
const cardGridSpec = spec;
|
|
432
447
|
if (registry.has("card-grid")) {
|
|
433
448
|
const CardGridRenderer = registry.get("card-grid");
|
|
434
|
-
return /* @__PURE__ */
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
449
|
+
return /* @__PURE__ */ jsxDEV3(UIErrorBoundary, {
|
|
450
|
+
onError,
|
|
451
|
+
children: /* @__PURE__ */ jsxDEV3("div", {
|
|
452
|
+
className,
|
|
453
|
+
children: [
|
|
454
|
+
cardGridSpec.title && /* @__PURE__ */ jsxDEV3("h3", {
|
|
455
|
+
className: "font-semibold mb-2",
|
|
456
|
+
children: cardGridSpec.title
|
|
457
|
+
}, undefined, false, undefined, this),
|
|
458
|
+
cardGridSpec.description && /* @__PURE__ */ jsxDEV3("p", {
|
|
459
|
+
className: "text-sm text-gray-600 mb-4",
|
|
460
|
+
children: cardGridSpec.description
|
|
461
|
+
}, undefined, false, undefined, this),
|
|
462
|
+
/* @__PURE__ */ jsxDEV3(CardGridRenderer, {
|
|
463
|
+
...cardGridSpec.props
|
|
464
|
+
}, undefined, false, undefined, this)
|
|
465
|
+
]
|
|
466
|
+
}, undefined, true, undefined, this)
|
|
467
|
+
}, undefined, false, undefined, this);
|
|
439
468
|
}
|
|
440
469
|
}
|
|
441
470
|
if (spec.type === "table") {
|
|
442
471
|
const tableSpec = spec;
|
|
443
472
|
if (registry.has("table")) {
|
|
444
473
|
const TableRenderer = registry.get("table");
|
|
445
|
-
return /* @__PURE__ */
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
474
|
+
return /* @__PURE__ */ jsxDEV3(UIErrorBoundary, {
|
|
475
|
+
onError,
|
|
476
|
+
children: /* @__PURE__ */ jsxDEV3("div", {
|
|
477
|
+
className,
|
|
478
|
+
children: [
|
|
479
|
+
tableSpec.title && /* @__PURE__ */ jsxDEV3("h3", {
|
|
480
|
+
className: "font-semibold mb-2",
|
|
481
|
+
children: tableSpec.title
|
|
482
|
+
}, undefined, false, undefined, this),
|
|
483
|
+
tableSpec.description && /* @__PURE__ */ jsxDEV3("p", {
|
|
484
|
+
className: "text-sm text-gray-600 mb-4",
|
|
485
|
+
children: tableSpec.description
|
|
486
|
+
}, undefined, false, undefined, this),
|
|
487
|
+
/* @__PURE__ */ jsxDEV3(TableRenderer, {
|
|
488
|
+
...tableSpec.props
|
|
489
|
+
}, undefined, false, undefined, this)
|
|
490
|
+
]
|
|
491
|
+
}, undefined, true, undefined, this)
|
|
492
|
+
}, undefined, false, undefined, this);
|
|
450
493
|
}
|
|
451
494
|
}
|
|
452
495
|
if (spec.type === "markdown") {
|
|
453
496
|
const markdownSpec = spec;
|
|
454
497
|
if (registry.has("markdown")) {
|
|
455
498
|
const MarkdownRenderer = registry.get("markdown");
|
|
456
|
-
return /* @__PURE__ */
|
|
499
|
+
return /* @__PURE__ */ jsxDEV3(UIErrorBoundary, {
|
|
500
|
+
onError,
|
|
501
|
+
children: /* @__PURE__ */ jsxDEV3("div", {
|
|
502
|
+
className,
|
|
503
|
+
children: /* @__PURE__ */ jsxDEV3(MarkdownRenderer, {
|
|
504
|
+
...markdownSpec.props
|
|
505
|
+
}, undefined, false, undefined, this)
|
|
506
|
+
}, undefined, false, undefined, this)
|
|
507
|
+
}, undefined, false, undefined, this);
|
|
457
508
|
}
|
|
458
|
-
return /* @__PURE__ */
|
|
509
|
+
return /* @__PURE__ */ jsxDEV3("div", {
|
|
510
|
+
className,
|
|
511
|
+
children: markdownSpec.props.content
|
|
512
|
+
}, undefined, false, undefined, this);
|
|
459
513
|
}
|
|
460
514
|
if (spec.type === "artifact") {
|
|
461
515
|
const artifactSpec = spec;
|
|
462
|
-
return /* @__PURE__ */
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
516
|
+
return /* @__PURE__ */ jsxDEV3(UIErrorBoundary, {
|
|
517
|
+
onError,
|
|
518
|
+
children: /* @__PURE__ */ jsxDEV3("div", {
|
|
519
|
+
className: `p-4 border rounded-md ${className || ""}`,
|
|
520
|
+
children: [
|
|
521
|
+
artifactSpec.title && /* @__PURE__ */ jsxDEV3("h3", {
|
|
522
|
+
className: "font-semibold mb-4",
|
|
523
|
+
children: artifactSpec.title
|
|
524
|
+
}, undefined, false, undefined, this),
|
|
525
|
+
artifactSpec.description && /* @__PURE__ */ jsxDEV3("p", {
|
|
526
|
+
className: "text-sm text-gray-600 mb-4",
|
|
527
|
+
children: artifactSpec.description
|
|
528
|
+
}, undefined, false, undefined, this),
|
|
529
|
+
/* @__PURE__ */ jsxDEV3("div", {
|
|
530
|
+
className: "space-y-4",
|
|
531
|
+
children: artifactSpec.props.content?.map((childSpec, index) => /* @__PURE__ */ jsxDEV3(GenerativeUIRenderer, {
|
|
532
|
+
spec: childSpec,
|
|
533
|
+
onError
|
|
534
|
+
}, index, false, undefined, this))
|
|
535
|
+
}, undefined, false, undefined, this)
|
|
536
|
+
]
|
|
537
|
+
}, undefined, true, undefined, this)
|
|
538
|
+
}, undefined, false, undefined, this);
|
|
467
539
|
}
|
|
468
|
-
return /* @__PURE__ */
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
540
|
+
return /* @__PURE__ */ jsxDEV3("div", {
|
|
541
|
+
className: `p-4 border border-gray-300 rounded-md ${className || ""}`,
|
|
542
|
+
children: [
|
|
543
|
+
/* @__PURE__ */ jsxDEV3("p", {
|
|
544
|
+
className: "font-semibold",
|
|
545
|
+
children: "Unsupported UI component"
|
|
546
|
+
}, undefined, false, undefined, this),
|
|
547
|
+
/* @__PURE__ */ jsxDEV3("p", {
|
|
548
|
+
className: "text-sm text-gray-600 mt-1",
|
|
549
|
+
children: [
|
|
550
|
+
"Component type: ",
|
|
551
|
+
spec.type
|
|
552
|
+
]
|
|
553
|
+
}, undefined, true, undefined, this)
|
|
554
|
+
]
|
|
555
|
+
}, undefined, true, undefined, this);
|
|
475
556
|
}
|
|
476
|
-
|
|
477
557
|
// src/utils/ui-helpers.ts
|
|
478
558
|
function createBarChart(data, xKey, bars, options) {
|
|
479
559
|
return {
|
|
@@ -639,34 +719,17 @@ function createSmartChart(data, options) {
|
|
|
639
719
|
}
|
|
640
720
|
const firstItem = data[0];
|
|
641
721
|
const keys = Object.keys(firstItem);
|
|
642
|
-
const xKey = options?.xKey || keys.find(
|
|
643
|
-
(k) => ["name", "label", "category", "date", "time", "month", "year"].includes(k.toLowerCase())
|
|
644
|
-
) || keys[0];
|
|
722
|
+
const xKey = options?.xKey || keys.find((k) => ["name", "label", "category", "date", "time", "month", "year"].includes(k.toLowerCase())) || keys[0];
|
|
645
723
|
const numericKeys = keys.filter((k) => k !== xKey && typeof firstItem[k] === "number");
|
|
646
724
|
const yKeys = options?.yKeys || numericKeys;
|
|
647
725
|
if (options?.preferredType) {
|
|
648
726
|
switch (options.preferredType) {
|
|
649
727
|
case "bar":
|
|
650
|
-
return createBarChart(
|
|
651
|
-
data,
|
|
652
|
-
xKey,
|
|
653
|
-
yKeys.map((key) => ({ key })),
|
|
654
|
-
options
|
|
655
|
-
);
|
|
728
|
+
return createBarChart(data, xKey, yKeys.map((key) => ({ key })), options);
|
|
656
729
|
case "line":
|
|
657
|
-
return createLineChart(
|
|
658
|
-
data,
|
|
659
|
-
xKey,
|
|
660
|
-
yKeys.map((key) => ({ key })),
|
|
661
|
-
options
|
|
662
|
-
);
|
|
730
|
+
return createLineChart(data, xKey, yKeys.map((key) => ({ key })), options);
|
|
663
731
|
case "area":
|
|
664
|
-
return createAreaChart(
|
|
665
|
-
data,
|
|
666
|
-
xKey,
|
|
667
|
-
yKeys.map((key) => ({ key })),
|
|
668
|
-
options
|
|
669
|
-
);
|
|
732
|
+
return createAreaChart(data, xKey, yKeys.map((key) => ({ key })), options);
|
|
670
733
|
case "pie":
|
|
671
734
|
return createPieChart(data, yKeys[0], xKey, options);
|
|
672
735
|
}
|
|
@@ -675,19 +738,9 @@ function createSmartChart(data, options) {
|
|
|
675
738
|
return createPieChart(data, yKeys[0], xKey, options);
|
|
676
739
|
}
|
|
677
740
|
if (xKey.toLowerCase().includes("date") || xKey.toLowerCase().includes("time") || xKey.toLowerCase().includes("month") || xKey.toLowerCase().includes("year")) {
|
|
678
|
-
return createLineChart(
|
|
679
|
-
data,
|
|
680
|
-
xKey,
|
|
681
|
-
yKeys.map((key) => ({ key })),
|
|
682
|
-
options
|
|
683
|
-
);
|
|
741
|
+
return createLineChart(data, xKey, yKeys.map((key) => ({ key })), options);
|
|
684
742
|
}
|
|
685
|
-
return createBarChart(
|
|
686
|
-
data,
|
|
687
|
-
xKey,
|
|
688
|
-
yKeys.map((key) => ({ key })),
|
|
689
|
-
options
|
|
690
|
-
);
|
|
743
|
+
return createBarChart(data, xKey, yKeys.map((key) => ({ key })), options);
|
|
691
744
|
}
|
|
692
745
|
function createToolResult(data, ui) {
|
|
693
746
|
return { data, ui };
|
|
@@ -704,7 +757,6 @@ function resultWithCardGrid(cards, options) {
|
|
|
704
757
|
function resultWithTable(data, columns, options) {
|
|
705
758
|
return createToolResult(data, createTable(data, columns, options));
|
|
706
759
|
}
|
|
707
|
-
|
|
708
760
|
// src/hooks/useAgnoChat.ts
|
|
709
761
|
import { useState as useState3, useEffect as useEffect3, useCallback as useCallback3 } from "react";
|
|
710
762
|
function useAgnoChat() {
|
|
@@ -736,8 +788,7 @@ function useAgnoChat() {
|
|
|
736
788
|
}
|
|
737
789
|
}
|
|
738
790
|
};
|
|
739
|
-
const handleRunCancelled = () => {
|
|
740
|
-
};
|
|
791
|
+
const handleRunCancelled = () => {};
|
|
741
792
|
client.on("message:update", handleMessageUpdate);
|
|
742
793
|
client.on("message:complete", handleMessageComplete);
|
|
743
794
|
client.on("message:refreshed", handleMessageRefreshed);
|
|
@@ -757,23 +808,20 @@ function useAgnoChat() {
|
|
|
757
808
|
client.off("run:cancelled", handleRunCancelled);
|
|
758
809
|
};
|
|
759
810
|
}, [client]);
|
|
760
|
-
const sendMessage = useCallback3(
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
},
|
|
771
|
-
[client]
|
|
772
|
-
);
|
|
811
|
+
const sendMessage = useCallback3(async (message, options) => {
|
|
812
|
+
setError(undefined);
|
|
813
|
+
try {
|
|
814
|
+
await client.sendMessage(message, options);
|
|
815
|
+
} catch (err) {
|
|
816
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
817
|
+
setError(errorMessage);
|
|
818
|
+
throw err;
|
|
819
|
+
}
|
|
820
|
+
}, [client]);
|
|
773
821
|
const clearMessages = useCallback3(() => {
|
|
774
822
|
client.clearMessages();
|
|
775
823
|
setMessages([]);
|
|
776
|
-
setError(
|
|
824
|
+
setError(undefined);
|
|
777
825
|
}, [client]);
|
|
778
826
|
const cancelRun = useCallback3(async () => {
|
|
779
827
|
try {
|
|
@@ -798,15 +846,12 @@ function useAgnoChat() {
|
|
|
798
846
|
state
|
|
799
847
|
};
|
|
800
848
|
}
|
|
801
|
-
|
|
802
849
|
// src/hooks/useAgnoSession.ts
|
|
803
850
|
import { useState as useState4, useEffect as useEffect4, useCallback as useCallback4 } from "react";
|
|
804
851
|
function useAgnoSession() {
|
|
805
852
|
const client = useAgnoClient();
|
|
806
853
|
const [sessions, setSessions] = useState4([]);
|
|
807
|
-
const [currentSessionId, setCurrentSessionId] = useState4(
|
|
808
|
-
client.getConfig().sessionId
|
|
809
|
-
);
|
|
854
|
+
const [currentSessionId, setCurrentSessionId] = useState4(client.getConfig().sessionId);
|
|
810
855
|
const [isLoading, setIsLoading] = useState4(false);
|
|
811
856
|
const [error, setError] = useState4();
|
|
812
857
|
useEffect4(() => {
|
|
@@ -833,27 +878,24 @@ function useAgnoSession() {
|
|
|
833
878
|
client.off("state:change", handleStateChange);
|
|
834
879
|
};
|
|
835
880
|
}, [client]);
|
|
836
|
-
const loadSession = useCallback4(
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
},
|
|
852
|
-
[client]
|
|
853
|
-
);
|
|
881
|
+
const loadSession = useCallback4(async (sessionId, options) => {
|
|
882
|
+
setIsLoading(true);
|
|
883
|
+
setError(undefined);
|
|
884
|
+
try {
|
|
885
|
+
const messages = await client.loadSession(sessionId, options);
|
|
886
|
+
setCurrentSessionId(sessionId);
|
|
887
|
+
return messages;
|
|
888
|
+
} catch (err) {
|
|
889
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
890
|
+
setError(errorMessage);
|
|
891
|
+
throw err;
|
|
892
|
+
} finally {
|
|
893
|
+
setIsLoading(false);
|
|
894
|
+
}
|
|
895
|
+
}, [client]);
|
|
854
896
|
const fetchSessions = useCallback4(async (options) => {
|
|
855
897
|
setIsLoading(true);
|
|
856
|
-
setError(
|
|
898
|
+
setError(undefined);
|
|
857
899
|
try {
|
|
858
900
|
const fetchedSessions = await client.fetchSessions(options);
|
|
859
901
|
setSessions(fetchedSessions);
|
|
@@ -866,119 +908,98 @@ function useAgnoSession() {
|
|
|
866
908
|
setIsLoading(false);
|
|
867
909
|
}
|
|
868
910
|
}, [client]);
|
|
869
|
-
const getSessionById = useCallback4(
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
setIsLoading(false);
|
|
962
|
-
}
|
|
963
|
-
},
|
|
964
|
-
[client]
|
|
965
|
-
);
|
|
966
|
-
const deleteMultipleSessions = useCallback4(
|
|
967
|
-
async (sessionIds, options) => {
|
|
968
|
-
setIsLoading(true);
|
|
969
|
-
setError(void 0);
|
|
970
|
-
try {
|
|
971
|
-
await client.deleteMultipleSessions(sessionIds, options);
|
|
972
|
-
} catch (err) {
|
|
973
|
-
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
974
|
-
setError(errorMessage);
|
|
975
|
-
throw err;
|
|
976
|
-
} finally {
|
|
977
|
-
setIsLoading(false);
|
|
978
|
-
}
|
|
979
|
-
},
|
|
980
|
-
[client]
|
|
981
|
-
);
|
|
911
|
+
const getSessionById = useCallback4(async (sessionId, options) => {
|
|
912
|
+
setIsLoading(true);
|
|
913
|
+
setError(undefined);
|
|
914
|
+
try {
|
|
915
|
+
return await client.getSessionById(sessionId, options);
|
|
916
|
+
} catch (err) {
|
|
917
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
918
|
+
setError(errorMessage);
|
|
919
|
+
throw err;
|
|
920
|
+
} finally {
|
|
921
|
+
setIsLoading(false);
|
|
922
|
+
}
|
|
923
|
+
}, [client]);
|
|
924
|
+
const getRunById = useCallback4(async (sessionId, runId, options) => {
|
|
925
|
+
setIsLoading(true);
|
|
926
|
+
setError(undefined);
|
|
927
|
+
try {
|
|
928
|
+
return await client.getRunById(sessionId, runId, options);
|
|
929
|
+
} catch (err) {
|
|
930
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
931
|
+
setError(errorMessage);
|
|
932
|
+
throw err;
|
|
933
|
+
} finally {
|
|
934
|
+
setIsLoading(false);
|
|
935
|
+
}
|
|
936
|
+
}, [client]);
|
|
937
|
+
const createSession = useCallback4(async (request, options) => {
|
|
938
|
+
setIsLoading(true);
|
|
939
|
+
setError(undefined);
|
|
940
|
+
try {
|
|
941
|
+
const session = await client.createSession(request, options);
|
|
942
|
+
return session;
|
|
943
|
+
} catch (err) {
|
|
944
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
945
|
+
setError(errorMessage);
|
|
946
|
+
throw err;
|
|
947
|
+
} finally {
|
|
948
|
+
setIsLoading(false);
|
|
949
|
+
}
|
|
950
|
+
}, [client]);
|
|
951
|
+
const updateSession = useCallback4(async (sessionId, request, options) => {
|
|
952
|
+
setIsLoading(true);
|
|
953
|
+
setError(undefined);
|
|
954
|
+
try {
|
|
955
|
+
return await client.updateSession(sessionId, request, options);
|
|
956
|
+
} catch (err) {
|
|
957
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
958
|
+
setError(errorMessage);
|
|
959
|
+
throw err;
|
|
960
|
+
} finally {
|
|
961
|
+
setIsLoading(false);
|
|
962
|
+
}
|
|
963
|
+
}, [client]);
|
|
964
|
+
const renameSession = useCallback4(async (sessionId, newName, options) => {
|
|
965
|
+
setIsLoading(true);
|
|
966
|
+
setError(undefined);
|
|
967
|
+
try {
|
|
968
|
+
return await client.renameSession(sessionId, newName, options);
|
|
969
|
+
} catch (err) {
|
|
970
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
971
|
+
setError(errorMessage);
|
|
972
|
+
throw err;
|
|
973
|
+
} finally {
|
|
974
|
+
setIsLoading(false);
|
|
975
|
+
}
|
|
976
|
+
}, [client]);
|
|
977
|
+
const deleteSession = useCallback4(async (sessionId, options) => {
|
|
978
|
+
setIsLoading(true);
|
|
979
|
+
setError(undefined);
|
|
980
|
+
try {
|
|
981
|
+
await client.deleteSession(sessionId, options);
|
|
982
|
+
} catch (err) {
|
|
983
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
984
|
+
setError(errorMessage);
|
|
985
|
+
throw err;
|
|
986
|
+
} finally {
|
|
987
|
+
setIsLoading(false);
|
|
988
|
+
}
|
|
989
|
+
}, [client]);
|
|
990
|
+
const deleteMultipleSessions = useCallback4(async (sessionIds, options) => {
|
|
991
|
+
setIsLoading(true);
|
|
992
|
+
setError(undefined);
|
|
993
|
+
try {
|
|
994
|
+
await client.deleteMultipleSessions(sessionIds, options);
|
|
995
|
+
} catch (err) {
|
|
996
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
997
|
+
setError(errorMessage);
|
|
998
|
+
throw err;
|
|
999
|
+
} finally {
|
|
1000
|
+
setIsLoading(false);
|
|
1001
|
+
}
|
|
1002
|
+
}, [client]);
|
|
982
1003
|
return {
|
|
983
1004
|
sessions,
|
|
984
1005
|
currentSessionId,
|
|
@@ -995,7 +1016,6 @@ function useAgnoSession() {
|
|
|
995
1016
|
error
|
|
996
1017
|
};
|
|
997
1018
|
}
|
|
998
|
-
|
|
999
1019
|
// src/hooks/useAgnoActions.ts
|
|
1000
1020
|
import { useState as useState5, useCallback as useCallback5 } from "react";
|
|
1001
1021
|
function useAgnoActions() {
|
|
@@ -1004,7 +1024,7 @@ function useAgnoActions() {
|
|
|
1004
1024
|
const [error, setError] = useState5();
|
|
1005
1025
|
const initialize = useCallback5(async (options) => {
|
|
1006
1026
|
setIsInitializing(true);
|
|
1007
|
-
setError(
|
|
1027
|
+
setError(undefined);
|
|
1008
1028
|
try {
|
|
1009
1029
|
const result = await client.initialize(options);
|
|
1010
1030
|
return result;
|
|
@@ -1017,7 +1037,7 @@ function useAgnoActions() {
|
|
|
1017
1037
|
}
|
|
1018
1038
|
}, [client]);
|
|
1019
1039
|
const checkStatus = useCallback5(async (options) => {
|
|
1020
|
-
setError(
|
|
1040
|
+
setError(undefined);
|
|
1021
1041
|
try {
|
|
1022
1042
|
return await client.checkStatus(options);
|
|
1023
1043
|
} catch (err) {
|
|
@@ -1027,7 +1047,7 @@ function useAgnoActions() {
|
|
|
1027
1047
|
}
|
|
1028
1048
|
}, [client]);
|
|
1029
1049
|
const fetchAgents = useCallback5(async (options) => {
|
|
1030
|
-
setError(
|
|
1050
|
+
setError(undefined);
|
|
1031
1051
|
try {
|
|
1032
1052
|
return await client.fetchAgents(options);
|
|
1033
1053
|
} catch (err) {
|
|
@@ -1037,7 +1057,7 @@ function useAgnoActions() {
|
|
|
1037
1057
|
}
|
|
1038
1058
|
}, [client]);
|
|
1039
1059
|
const fetchTeams = useCallback5(async (options) => {
|
|
1040
|
-
setError(
|
|
1060
|
+
setError(undefined);
|
|
1041
1061
|
try {
|
|
1042
1062
|
return await client.fetchTeams(options);
|
|
1043
1063
|
} catch (err) {
|
|
@@ -1046,12 +1066,9 @@ function useAgnoActions() {
|
|
|
1046
1066
|
throw err;
|
|
1047
1067
|
}
|
|
1048
1068
|
}, [client]);
|
|
1049
|
-
const updateConfig = useCallback5(
|
|
1050
|
-
(updates)
|
|
1051
|
-
|
|
1052
|
-
},
|
|
1053
|
-
[client]
|
|
1054
|
-
);
|
|
1069
|
+
const updateConfig = useCallback5((updates) => {
|
|
1070
|
+
client.updateConfig(updates);
|
|
1071
|
+
}, [client]);
|
|
1055
1072
|
return {
|
|
1056
1073
|
initialize,
|
|
1057
1074
|
checkStatus,
|
|
@@ -1062,7 +1079,6 @@ function useAgnoActions() {
|
|
|
1062
1079
|
error
|
|
1063
1080
|
};
|
|
1064
1081
|
}
|
|
1065
|
-
|
|
1066
1082
|
// src/hooks/useAgnoCustomEvents.ts
|
|
1067
1083
|
import { useState as useState6, useEffect as useEffect5, useCallback as useCallback6, useRef } from "react";
|
|
1068
1084
|
function useAgnoCustomEvents(handler) {
|
|
@@ -1085,7 +1101,6 @@ function useAgnoCustomEvents(handler) {
|
|
|
1085
1101
|
}, []);
|
|
1086
1102
|
return { events, clearEvents };
|
|
1087
1103
|
}
|
|
1088
|
-
|
|
1089
1104
|
// src/hooks/useAgnoMemory.ts
|
|
1090
1105
|
import { useState as useState7, useEffect as useEffect6, useCallback as useCallback7 } from "react";
|
|
1091
1106
|
function useAgnoMemory() {
|
|
@@ -1099,9 +1114,7 @@ function useAgnoMemory() {
|
|
|
1099
1114
|
setMemories((prev) => [memory, ...prev]);
|
|
1100
1115
|
};
|
|
1101
1116
|
const handleMemoryUpdated = (memory) => {
|
|
1102
|
-
setMemories(
|
|
1103
|
-
(prev) => prev.map((m) => m.memory_id === memory.memory_id ? memory : m)
|
|
1104
|
-
);
|
|
1117
|
+
setMemories((prev) => prev.map((m) => m.memory_id === memory.memory_id ? memory : m));
|
|
1105
1118
|
};
|
|
1106
1119
|
const handleMemoryDeleted = ({ memoryId }) => {
|
|
1107
1120
|
setMemories((prev) => prev.filter((m) => m.memory_id !== memoryId));
|
|
@@ -1131,138 +1144,114 @@ function useAgnoMemory() {
|
|
|
1131
1144
|
client.off("state:change", handleStateChange);
|
|
1132
1145
|
};
|
|
1133
1146
|
}, [client]);
|
|
1134
|
-
const fetchMemories = useCallback7(
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
setError(
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
}
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
setError(errorMessage);
|
|
1243
|
-
throw err;
|
|
1244
|
-
} finally {
|
|
1245
|
-
setIsLoading(false);
|
|
1246
|
-
}
|
|
1247
|
-
},
|
|
1248
|
-
[client]
|
|
1249
|
-
);
|
|
1250
|
-
const deleteMultipleMemories = useCallback7(
|
|
1251
|
-
async (memoryIds, options) => {
|
|
1252
|
-
setIsLoading(true);
|
|
1253
|
-
setError(void 0);
|
|
1254
|
-
try {
|
|
1255
|
-
await client.deleteMultipleMemories(memoryIds, options);
|
|
1256
|
-
} catch (err) {
|
|
1257
|
-
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1258
|
-
setError(errorMessage);
|
|
1259
|
-
throw err;
|
|
1260
|
-
} finally {
|
|
1261
|
-
setIsLoading(false);
|
|
1262
|
-
}
|
|
1263
|
-
},
|
|
1264
|
-
[client]
|
|
1265
|
-
);
|
|
1147
|
+
const fetchMemories = useCallback7(async (queryParams, options) => {
|
|
1148
|
+
setIsLoading(true);
|
|
1149
|
+
setError(undefined);
|
|
1150
|
+
try {
|
|
1151
|
+
const response = await client.fetchMemories(queryParams, options);
|
|
1152
|
+
setMemories(response.data);
|
|
1153
|
+
return response;
|
|
1154
|
+
} catch (err) {
|
|
1155
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1156
|
+
setError(errorMessage);
|
|
1157
|
+
throw err;
|
|
1158
|
+
} finally {
|
|
1159
|
+
setIsLoading(false);
|
|
1160
|
+
}
|
|
1161
|
+
}, [client]);
|
|
1162
|
+
const getMemoryById = useCallback7(async (memoryId, options) => {
|
|
1163
|
+
setIsLoading(true);
|
|
1164
|
+
setError(undefined);
|
|
1165
|
+
try {
|
|
1166
|
+
return await client.getMemoryById(memoryId, options);
|
|
1167
|
+
} catch (err) {
|
|
1168
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1169
|
+
setError(errorMessage);
|
|
1170
|
+
throw err;
|
|
1171
|
+
} finally {
|
|
1172
|
+
setIsLoading(false);
|
|
1173
|
+
}
|
|
1174
|
+
}, [client]);
|
|
1175
|
+
const getMemoryTopics = useCallback7(async (options) => {
|
|
1176
|
+
setIsLoading(true);
|
|
1177
|
+
setError(undefined);
|
|
1178
|
+
try {
|
|
1179
|
+
const result = await client.getMemoryTopics(options);
|
|
1180
|
+
setTopics(result);
|
|
1181
|
+
return result;
|
|
1182
|
+
} catch (err) {
|
|
1183
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1184
|
+
setError(errorMessage);
|
|
1185
|
+
throw err;
|
|
1186
|
+
} finally {
|
|
1187
|
+
setIsLoading(false);
|
|
1188
|
+
}
|
|
1189
|
+
}, [client]);
|
|
1190
|
+
const getUserMemoryStats = useCallback7(async (queryParams, options) => {
|
|
1191
|
+
setIsLoading(true);
|
|
1192
|
+
setError(undefined);
|
|
1193
|
+
try {
|
|
1194
|
+
return await client.getUserMemoryStats(queryParams, options);
|
|
1195
|
+
} catch (err) {
|
|
1196
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1197
|
+
setError(errorMessage);
|
|
1198
|
+
throw err;
|
|
1199
|
+
} finally {
|
|
1200
|
+
setIsLoading(false);
|
|
1201
|
+
}
|
|
1202
|
+
}, [client]);
|
|
1203
|
+
const createMemory = useCallback7(async (request, options) => {
|
|
1204
|
+
setIsLoading(true);
|
|
1205
|
+
setError(undefined);
|
|
1206
|
+
try {
|
|
1207
|
+
return await client.createMemory(request, options);
|
|
1208
|
+
} catch (err) {
|
|
1209
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1210
|
+
setError(errorMessage);
|
|
1211
|
+
throw err;
|
|
1212
|
+
} finally {
|
|
1213
|
+
setIsLoading(false);
|
|
1214
|
+
}
|
|
1215
|
+
}, [client]);
|
|
1216
|
+
const updateMemory = useCallback7(async (memoryId, request, options) => {
|
|
1217
|
+
setIsLoading(true);
|
|
1218
|
+
setError(undefined);
|
|
1219
|
+
try {
|
|
1220
|
+
return await client.updateMemory(memoryId, request, options);
|
|
1221
|
+
} catch (err) {
|
|
1222
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1223
|
+
setError(errorMessage);
|
|
1224
|
+
throw err;
|
|
1225
|
+
} finally {
|
|
1226
|
+
setIsLoading(false);
|
|
1227
|
+
}
|
|
1228
|
+
}, [client]);
|
|
1229
|
+
const deleteMemory = useCallback7(async (memoryId, options) => {
|
|
1230
|
+
setIsLoading(true);
|
|
1231
|
+
setError(undefined);
|
|
1232
|
+
try {
|
|
1233
|
+
await client.deleteMemory(memoryId, options);
|
|
1234
|
+
} catch (err) {
|
|
1235
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1236
|
+
setError(errorMessage);
|
|
1237
|
+
throw err;
|
|
1238
|
+
} finally {
|
|
1239
|
+
setIsLoading(false);
|
|
1240
|
+
}
|
|
1241
|
+
}, [client]);
|
|
1242
|
+
const deleteMultipleMemories = useCallback7(async (memoryIds, options) => {
|
|
1243
|
+
setIsLoading(true);
|
|
1244
|
+
setError(undefined);
|
|
1245
|
+
try {
|
|
1246
|
+
await client.deleteMultipleMemories(memoryIds, options);
|
|
1247
|
+
} catch (err) {
|
|
1248
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1249
|
+
setError(errorMessage);
|
|
1250
|
+
throw err;
|
|
1251
|
+
} finally {
|
|
1252
|
+
setIsLoading(false);
|
|
1253
|
+
}
|
|
1254
|
+
}, [client]);
|
|
1266
1255
|
return {
|
|
1267
1256
|
memories,
|
|
1268
1257
|
topics,
|
|
@@ -1278,7 +1267,6 @@ function useAgnoMemory() {
|
|
|
1278
1267
|
deleteMultipleMemories
|
|
1279
1268
|
};
|
|
1280
1269
|
}
|
|
1281
|
-
|
|
1282
1270
|
// src/hooks/useAgnoKnowledge.ts
|
|
1283
1271
|
import { useState as useState8, useCallback as useCallback8 } from "react";
|
|
1284
1272
|
function useAgnoKnowledge() {
|
|
@@ -1287,172 +1275,139 @@ function useAgnoKnowledge() {
|
|
|
1287
1275
|
const [error, setError] = useState8();
|
|
1288
1276
|
const [config, setConfig] = useState8();
|
|
1289
1277
|
const [content, setContent] = useState8([]);
|
|
1290
|
-
const getConfig = useCallback8(
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
);
|
|
1374
|
-
const
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
try {
|
|
1419
|
-
await client.deleteAllKnowledgeContent(options);
|
|
1420
|
-
setContent([]);
|
|
1421
|
-
} catch (err) {
|
|
1422
|
-
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1423
|
-
setError(errorMessage);
|
|
1424
|
-
throw err;
|
|
1425
|
-
} finally {
|
|
1426
|
-
setIsLoading(false);
|
|
1427
|
-
}
|
|
1428
|
-
},
|
|
1429
|
-
[client]
|
|
1430
|
-
);
|
|
1431
|
-
const deleteContent = useCallback8(
|
|
1432
|
-
async (contentId, options) => {
|
|
1433
|
-
setIsLoading(true);
|
|
1434
|
-
setError(void 0);
|
|
1435
|
-
try {
|
|
1436
|
-
const result = await client.deleteKnowledgeContent(contentId, options);
|
|
1437
|
-
setContent((prev) => prev.filter((c) => c.id !== contentId));
|
|
1438
|
-
return result;
|
|
1439
|
-
} catch (err) {
|
|
1440
|
-
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1441
|
-
setError(errorMessage);
|
|
1442
|
-
throw err;
|
|
1443
|
-
} finally {
|
|
1444
|
-
setIsLoading(false);
|
|
1445
|
-
}
|
|
1446
|
-
},
|
|
1447
|
-
[client]
|
|
1448
|
-
);
|
|
1278
|
+
const getConfig = useCallback8(async (options) => {
|
|
1279
|
+
setIsLoading(true);
|
|
1280
|
+
setError(undefined);
|
|
1281
|
+
try {
|
|
1282
|
+
const result = await client.getKnowledgeConfig(options);
|
|
1283
|
+
setConfig(result);
|
|
1284
|
+
return result;
|
|
1285
|
+
} catch (err) {
|
|
1286
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1287
|
+
setError(errorMessage);
|
|
1288
|
+
throw err;
|
|
1289
|
+
} finally {
|
|
1290
|
+
setIsLoading(false);
|
|
1291
|
+
}
|
|
1292
|
+
}, [client]);
|
|
1293
|
+
const listContent = useCallback8(async (listOptions, options) => {
|
|
1294
|
+
setIsLoading(true);
|
|
1295
|
+
setError(undefined);
|
|
1296
|
+
try {
|
|
1297
|
+
const result = await client.listKnowledgeContent(listOptions, options);
|
|
1298
|
+
setContent(result.data);
|
|
1299
|
+
return result;
|
|
1300
|
+
} catch (err) {
|
|
1301
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1302
|
+
setError(errorMessage);
|
|
1303
|
+
throw err;
|
|
1304
|
+
} finally {
|
|
1305
|
+
setIsLoading(false);
|
|
1306
|
+
}
|
|
1307
|
+
}, [client]);
|
|
1308
|
+
const getContent = useCallback8(async (contentId, options) => {
|
|
1309
|
+
setIsLoading(true);
|
|
1310
|
+
setError(undefined);
|
|
1311
|
+
try {
|
|
1312
|
+
return await client.getKnowledgeContent(contentId, options);
|
|
1313
|
+
} catch (err) {
|
|
1314
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1315
|
+
setError(errorMessage);
|
|
1316
|
+
throw err;
|
|
1317
|
+
} finally {
|
|
1318
|
+
setIsLoading(false);
|
|
1319
|
+
}
|
|
1320
|
+
}, [client]);
|
|
1321
|
+
const getContentStatus = useCallback8(async (contentId, options) => {
|
|
1322
|
+
setIsLoading(true);
|
|
1323
|
+
setError(undefined);
|
|
1324
|
+
try {
|
|
1325
|
+
return await client.getKnowledgeContentStatus(contentId, options);
|
|
1326
|
+
} catch (err) {
|
|
1327
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1328
|
+
setError(errorMessage);
|
|
1329
|
+
throw err;
|
|
1330
|
+
} finally {
|
|
1331
|
+
setIsLoading(false);
|
|
1332
|
+
}
|
|
1333
|
+
}, [client]);
|
|
1334
|
+
const search = useCallback8(async (request, options) => {
|
|
1335
|
+
setIsLoading(true);
|
|
1336
|
+
setError(undefined);
|
|
1337
|
+
try {
|
|
1338
|
+
return await client.searchKnowledge(request, options);
|
|
1339
|
+
} catch (err) {
|
|
1340
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1341
|
+
setError(errorMessage);
|
|
1342
|
+
throw err;
|
|
1343
|
+
} finally {
|
|
1344
|
+
setIsLoading(false);
|
|
1345
|
+
}
|
|
1346
|
+
}, [client]);
|
|
1347
|
+
const uploadContent = useCallback8(async (data, options) => {
|
|
1348
|
+
setIsLoading(true);
|
|
1349
|
+
setError(undefined);
|
|
1350
|
+
try {
|
|
1351
|
+
const result = await client.uploadKnowledgeContent(data, options);
|
|
1352
|
+
setContent((prev) => [result, ...prev]);
|
|
1353
|
+
return result;
|
|
1354
|
+
} catch (err) {
|
|
1355
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1356
|
+
setError(errorMessage);
|
|
1357
|
+
throw err;
|
|
1358
|
+
} finally {
|
|
1359
|
+
setIsLoading(false);
|
|
1360
|
+
}
|
|
1361
|
+
}, [client]);
|
|
1362
|
+
const updateContent = useCallback8(async (contentId, request, options) => {
|
|
1363
|
+
setIsLoading(true);
|
|
1364
|
+
setError(undefined);
|
|
1365
|
+
try {
|
|
1366
|
+
const result = await client.updateKnowledgeContent(contentId, request, options);
|
|
1367
|
+
setContent((prev) => prev.map((c) => c.id === contentId ? result : c));
|
|
1368
|
+
return result;
|
|
1369
|
+
} catch (err) {
|
|
1370
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1371
|
+
setError(errorMessage);
|
|
1372
|
+
throw err;
|
|
1373
|
+
} finally {
|
|
1374
|
+
setIsLoading(false);
|
|
1375
|
+
}
|
|
1376
|
+
}, [client]);
|
|
1377
|
+
const deleteAllContent = useCallback8(async (options) => {
|
|
1378
|
+
setIsLoading(true);
|
|
1379
|
+
setError(undefined);
|
|
1380
|
+
try {
|
|
1381
|
+
await client.deleteAllKnowledgeContent(options);
|
|
1382
|
+
setContent([]);
|
|
1383
|
+
} catch (err) {
|
|
1384
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1385
|
+
setError(errorMessage);
|
|
1386
|
+
throw err;
|
|
1387
|
+
} finally {
|
|
1388
|
+
setIsLoading(false);
|
|
1389
|
+
}
|
|
1390
|
+
}, [client]);
|
|
1391
|
+
const deleteContent = useCallback8(async (contentId, options) => {
|
|
1392
|
+
setIsLoading(true);
|
|
1393
|
+
setError(undefined);
|
|
1394
|
+
try {
|
|
1395
|
+
const result = await client.deleteKnowledgeContent(contentId, options);
|
|
1396
|
+
setContent((prev) => prev.filter((c) => c.id !== contentId));
|
|
1397
|
+
return result;
|
|
1398
|
+
} catch (err) {
|
|
1399
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1400
|
+
setError(errorMessage);
|
|
1401
|
+
throw err;
|
|
1402
|
+
} finally {
|
|
1403
|
+
setIsLoading(false);
|
|
1404
|
+
}
|
|
1405
|
+
}, [client]);
|
|
1449
1406
|
return {
|
|
1450
|
-
// State
|
|
1451
1407
|
config,
|
|
1452
1408
|
content,
|
|
1453
1409
|
isLoading,
|
|
1454
1410
|
error,
|
|
1455
|
-
// Methods
|
|
1456
1411
|
getConfig,
|
|
1457
1412
|
listContent,
|
|
1458
1413
|
getContent,
|
|
@@ -1464,7 +1419,6 @@ function useAgnoKnowledge() {
|
|
|
1464
1419
|
deleteContent
|
|
1465
1420
|
};
|
|
1466
1421
|
}
|
|
1467
|
-
|
|
1468
1422
|
// src/hooks/useAgnoMetrics.ts
|
|
1469
1423
|
import { useState as useState9, useCallback as useCallback9 } from "react";
|
|
1470
1424
|
function useAgnoMetrics() {
|
|
@@ -1473,59 +1427,49 @@ function useAgnoMetrics() {
|
|
|
1473
1427
|
const [isRefreshing, setIsRefreshing] = useState9(false);
|
|
1474
1428
|
const [error, setError] = useState9();
|
|
1475
1429
|
const [metrics, setMetrics] = useState9();
|
|
1476
|
-
const fetchMetrics = useCallback9(
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
} finally {
|
|
1506
|
-
setIsRefreshing(false);
|
|
1507
|
-
}
|
|
1508
|
-
},
|
|
1509
|
-
[client]
|
|
1510
|
-
);
|
|
1430
|
+
const fetchMetrics = useCallback9(async (options) => {
|
|
1431
|
+
setIsLoading(true);
|
|
1432
|
+
setError(undefined);
|
|
1433
|
+
try {
|
|
1434
|
+
const result = await client.fetchMetrics(options);
|
|
1435
|
+
setMetrics(result);
|
|
1436
|
+
return result;
|
|
1437
|
+
} catch (err) {
|
|
1438
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1439
|
+
setError(errorMessage);
|
|
1440
|
+
throw err;
|
|
1441
|
+
} finally {
|
|
1442
|
+
setIsLoading(false);
|
|
1443
|
+
}
|
|
1444
|
+
}, [client]);
|
|
1445
|
+
const refreshMetrics = useCallback9(async (options) => {
|
|
1446
|
+
setIsRefreshing(true);
|
|
1447
|
+
setError(undefined);
|
|
1448
|
+
try {
|
|
1449
|
+
const result = await client.refreshMetrics(options);
|
|
1450
|
+
return result;
|
|
1451
|
+
} catch (err) {
|
|
1452
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1453
|
+
setError(errorMessage);
|
|
1454
|
+
throw err;
|
|
1455
|
+
} finally {
|
|
1456
|
+
setIsRefreshing(false);
|
|
1457
|
+
}
|
|
1458
|
+
}, [client]);
|
|
1511
1459
|
const clearMetrics = useCallback9(() => {
|
|
1512
|
-
setMetrics(
|
|
1513
|
-
setError(
|
|
1460
|
+
setMetrics(undefined);
|
|
1461
|
+
setError(undefined);
|
|
1514
1462
|
}, []);
|
|
1515
1463
|
return {
|
|
1516
|
-
// Data
|
|
1517
1464
|
metrics,
|
|
1518
|
-
// Actions
|
|
1519
1465
|
fetchMetrics,
|
|
1520
1466
|
refreshMetrics,
|
|
1521
1467
|
clearMetrics,
|
|
1522
|
-
// State
|
|
1523
1468
|
isLoading,
|
|
1524
1469
|
isRefreshing,
|
|
1525
1470
|
error
|
|
1526
1471
|
};
|
|
1527
1472
|
}
|
|
1528
|
-
|
|
1529
1473
|
// src/hooks/useAgnoEvals.ts
|
|
1530
1474
|
import { useState as useState10, useCallback as useCallback10 } from "react";
|
|
1531
1475
|
function useAgnoEvals() {
|
|
@@ -1534,110 +1478,88 @@ function useAgnoEvals() {
|
|
|
1534
1478
|
const [pagination, setPagination] = useState10();
|
|
1535
1479
|
const [isLoading, setIsLoading] = useState10(false);
|
|
1536
1480
|
const [error, setError] = useState10();
|
|
1537
|
-
const listEvalRuns = useCallback10(
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
setError(
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
}
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
try {
|
|
1615
|
-
await client.deleteEvalRuns(evalRunIds, options);
|
|
1616
|
-
const deletedSet = new Set(evalRunIds);
|
|
1617
|
-
setEvalRuns((prev) => prev.filter((evalRun) => !deletedSet.has(evalRun.id)));
|
|
1618
|
-
} catch (err) {
|
|
1619
|
-
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1620
|
-
setError(errorMessage);
|
|
1621
|
-
throw err;
|
|
1622
|
-
} finally {
|
|
1623
|
-
setIsLoading(false);
|
|
1624
|
-
}
|
|
1625
|
-
},
|
|
1626
|
-
[client]
|
|
1627
|
-
);
|
|
1628
|
-
const renameEvalRun = useCallback10(
|
|
1629
|
-
async (evalRunId, newName, options) => {
|
|
1630
|
-
return updateEvalRun(evalRunId, { name: newName }, options);
|
|
1631
|
-
},
|
|
1632
|
-
[updateEvalRun]
|
|
1633
|
-
);
|
|
1481
|
+
const listEvalRuns = useCallback10(async (listParams = {}, options) => {
|
|
1482
|
+
setIsLoading(true);
|
|
1483
|
+
setError(undefined);
|
|
1484
|
+
try {
|
|
1485
|
+
const response = await client.listEvalRuns(listParams, options);
|
|
1486
|
+
setEvalRuns(response.data);
|
|
1487
|
+
setPagination(response.meta);
|
|
1488
|
+
return response;
|
|
1489
|
+
} catch (err) {
|
|
1490
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1491
|
+
setError(errorMessage);
|
|
1492
|
+
throw err;
|
|
1493
|
+
} finally {
|
|
1494
|
+
setIsLoading(false);
|
|
1495
|
+
}
|
|
1496
|
+
}, [client]);
|
|
1497
|
+
const getEvalRun = useCallback10(async (evalRunId, options) => {
|
|
1498
|
+
setIsLoading(true);
|
|
1499
|
+
setError(undefined);
|
|
1500
|
+
try {
|
|
1501
|
+
return await client.getEvalRun(evalRunId, options);
|
|
1502
|
+
} catch (err) {
|
|
1503
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1504
|
+
setError(errorMessage);
|
|
1505
|
+
throw err;
|
|
1506
|
+
} finally {
|
|
1507
|
+
setIsLoading(false);
|
|
1508
|
+
}
|
|
1509
|
+
}, [client]);
|
|
1510
|
+
const executeEval = useCallback10(async (request, options) => {
|
|
1511
|
+
setIsLoading(true);
|
|
1512
|
+
setError(undefined);
|
|
1513
|
+
try {
|
|
1514
|
+
const result = await client.executeEval(request, options);
|
|
1515
|
+
setEvalRuns((prev) => [result, ...prev]);
|
|
1516
|
+
return result;
|
|
1517
|
+
} catch (err) {
|
|
1518
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1519
|
+
setError(errorMessage);
|
|
1520
|
+
throw err;
|
|
1521
|
+
} finally {
|
|
1522
|
+
setIsLoading(false);
|
|
1523
|
+
}
|
|
1524
|
+
}, [client]);
|
|
1525
|
+
const updateEvalRun = useCallback10(async (evalRunId, request, options) => {
|
|
1526
|
+
setIsLoading(true);
|
|
1527
|
+
setError(undefined);
|
|
1528
|
+
try {
|
|
1529
|
+
const result = await client.updateEvalRun(evalRunId, request, options);
|
|
1530
|
+
setEvalRuns((prev) => prev.map((evalRun) => evalRun.id === evalRunId ? result : evalRun));
|
|
1531
|
+
return result;
|
|
1532
|
+
} catch (err) {
|
|
1533
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1534
|
+
setError(errorMessage);
|
|
1535
|
+
throw err;
|
|
1536
|
+
} finally {
|
|
1537
|
+
setIsLoading(false);
|
|
1538
|
+
}
|
|
1539
|
+
}, [client]);
|
|
1540
|
+
const deleteEvalRuns = useCallback10(async (evalRunIds, options) => {
|
|
1541
|
+
setIsLoading(true);
|
|
1542
|
+
setError(undefined);
|
|
1543
|
+
try {
|
|
1544
|
+
await client.deleteEvalRuns(evalRunIds, options);
|
|
1545
|
+
const deletedSet = new Set(evalRunIds);
|
|
1546
|
+
setEvalRuns((prev) => prev.filter((evalRun) => !deletedSet.has(evalRun.id)));
|
|
1547
|
+
} catch (err) {
|
|
1548
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1549
|
+
setError(errorMessage);
|
|
1550
|
+
throw err;
|
|
1551
|
+
} finally {
|
|
1552
|
+
setIsLoading(false);
|
|
1553
|
+
}
|
|
1554
|
+
}, [client]);
|
|
1555
|
+
const renameEvalRun = useCallback10(async (evalRunId, newName, options) => {
|
|
1556
|
+
return updateEvalRun(evalRunId, { name: newName }, options);
|
|
1557
|
+
}, [updateEvalRun]);
|
|
1634
1558
|
return {
|
|
1635
|
-
// State
|
|
1636
1559
|
evalRuns,
|
|
1637
1560
|
pagination,
|
|
1638
1561
|
isLoading,
|
|
1639
1562
|
error,
|
|
1640
|
-
// Methods
|
|
1641
1563
|
listEvalRuns,
|
|
1642
1564
|
getEvalRun,
|
|
1643
1565
|
executeEval,
|
|
@@ -1646,7 +1568,6 @@ function useAgnoEvals() {
|
|
|
1646
1568
|
renameEvalRun
|
|
1647
1569
|
};
|
|
1648
1570
|
}
|
|
1649
|
-
|
|
1650
1571
|
// src/hooks/useAgnoTraces.ts
|
|
1651
1572
|
import { useState as useState11, useEffect as useEffect7, useCallback as useCallback11 } from "react";
|
|
1652
1573
|
function useAgnoTraces() {
|
|
@@ -1669,110 +1590,96 @@ function useAgnoTraces() {
|
|
|
1669
1590
|
client.off("state:change", handleStateChange);
|
|
1670
1591
|
};
|
|
1671
1592
|
}, [client]);
|
|
1672
|
-
const fetchTraces = useCallback11(
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
setError(
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1716
|
-
setError(errorMessage);
|
|
1717
|
-
throw err;
|
|
1718
|
-
} finally {
|
|
1719
|
-
setIsLoading(false);
|
|
1720
|
-
}
|
|
1721
|
-
},
|
|
1722
|
-
[client]
|
|
1723
|
-
);
|
|
1593
|
+
const fetchTraces = useCallback11(async (options = {}, requestOptions) => {
|
|
1594
|
+
setIsLoading(true);
|
|
1595
|
+
setError(undefined);
|
|
1596
|
+
try {
|
|
1597
|
+
const result = await client.fetchTraces(options, requestOptions);
|
|
1598
|
+
setTraces(result.traces);
|
|
1599
|
+
return result;
|
|
1600
|
+
} catch (err) {
|
|
1601
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1602
|
+
setError(errorMessage);
|
|
1603
|
+
throw err;
|
|
1604
|
+
} finally {
|
|
1605
|
+
setIsLoading(false);
|
|
1606
|
+
}
|
|
1607
|
+
}, [client]);
|
|
1608
|
+
const getTraceDetail = useCallback11(async (traceId, options = {}, requestOptions) => {
|
|
1609
|
+
setIsLoading(true);
|
|
1610
|
+
setError(undefined);
|
|
1611
|
+
try {
|
|
1612
|
+
return await client.getTraceDetail(traceId, options, requestOptions);
|
|
1613
|
+
} catch (err) {
|
|
1614
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1615
|
+
setError(errorMessage);
|
|
1616
|
+
throw err;
|
|
1617
|
+
} finally {
|
|
1618
|
+
setIsLoading(false);
|
|
1619
|
+
}
|
|
1620
|
+
}, [client]);
|
|
1621
|
+
const fetchTraceSessionStats = useCallback11(async (options = {}, requestOptions) => {
|
|
1622
|
+
setIsLoading(true);
|
|
1623
|
+
setError(undefined);
|
|
1624
|
+
try {
|
|
1625
|
+
const result = await client.fetchTraceSessionStats(options, requestOptions);
|
|
1626
|
+
setTraceSessionStats(result.stats);
|
|
1627
|
+
return result;
|
|
1628
|
+
} catch (err) {
|
|
1629
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1630
|
+
setError(errorMessage);
|
|
1631
|
+
throw err;
|
|
1632
|
+
} finally {
|
|
1633
|
+
setIsLoading(false);
|
|
1634
|
+
}
|
|
1635
|
+
}, [client]);
|
|
1724
1636
|
return {
|
|
1725
|
-
/** Current list of traces (from last fetchTraces call) */
|
|
1726
1637
|
traces,
|
|
1727
|
-
/** Current trace session statistics (from last fetchTraceSessionStats call) */
|
|
1728
1638
|
traceSessionStats,
|
|
1729
|
-
/** Fetch traces with optional filters and pagination */
|
|
1730
1639
|
fetchTraces,
|
|
1731
|
-
/** Get trace detail or specific span */
|
|
1732
1640
|
getTraceDetail,
|
|
1733
|
-
/** Fetch trace session statistics */
|
|
1734
1641
|
fetchTraceSessionStats,
|
|
1735
|
-
/** Loading state */
|
|
1736
1642
|
isLoading,
|
|
1737
|
-
/** Error message if last operation failed */
|
|
1738
1643
|
error
|
|
1739
1644
|
};
|
|
1740
1645
|
}
|
|
1741
1646
|
export {
|
|
1742
|
-
|
|
1743
|
-
ComponentRegistry,
|
|
1744
|
-
GenerativeUIRenderer,
|
|
1745
|
-
ToolHandlerProvider,
|
|
1746
|
-
createAreaChart,
|
|
1747
|
-
createArtifact,
|
|
1748
|
-
createBarChart,
|
|
1749
|
-
createCard,
|
|
1750
|
-
createCardGrid,
|
|
1751
|
-
createColumn,
|
|
1752
|
-
createLineChart,
|
|
1753
|
-
createMarkdown,
|
|
1754
|
-
createPieChart,
|
|
1755
|
-
createSmartChart,
|
|
1756
|
-
createTable,
|
|
1757
|
-
createToolResult,
|
|
1758
|
-
getChartComponent,
|
|
1759
|
-
getComponentRegistry,
|
|
1760
|
-
getCustomRender,
|
|
1761
|
-
registerChartComponent,
|
|
1762
|
-
resultWithBarChart,
|
|
1763
|
-
resultWithCardGrid,
|
|
1764
|
-
resultWithSmartChart,
|
|
1765
|
-
resultWithTable,
|
|
1766
|
-
useAgnoActions,
|
|
1767
|
-
useAgnoChat,
|
|
1768
|
-
useAgnoClient,
|
|
1769
|
-
useAgnoCustomEvents,
|
|
1770
|
-
useAgnoEvals,
|
|
1771
|
-
useAgnoKnowledge,
|
|
1772
|
-
useAgnoMemory,
|
|
1773
|
-
useAgnoMetrics,
|
|
1774
|
-
useAgnoSession,
|
|
1775
|
-
useAgnoToolExecution,
|
|
1647
|
+
useToolHandlers,
|
|
1776
1648
|
useAgnoTraces,
|
|
1777
|
-
|
|
1649
|
+
useAgnoToolExecution,
|
|
1650
|
+
useAgnoSession,
|
|
1651
|
+
useAgnoMetrics,
|
|
1652
|
+
useAgnoMemory,
|
|
1653
|
+
useAgnoKnowledge,
|
|
1654
|
+
useAgnoEvals,
|
|
1655
|
+
useAgnoCustomEvents,
|
|
1656
|
+
useAgnoClient,
|
|
1657
|
+
useAgnoChat,
|
|
1658
|
+
useAgnoActions,
|
|
1659
|
+
resultWithTable,
|
|
1660
|
+
resultWithSmartChart,
|
|
1661
|
+
resultWithCardGrid,
|
|
1662
|
+
resultWithBarChart,
|
|
1663
|
+
registerChartComponent,
|
|
1664
|
+
getCustomRender,
|
|
1665
|
+
getComponentRegistry,
|
|
1666
|
+
getChartComponent,
|
|
1667
|
+
createToolResult,
|
|
1668
|
+
createTable,
|
|
1669
|
+
createSmartChart,
|
|
1670
|
+
createPieChart,
|
|
1671
|
+
createMarkdown,
|
|
1672
|
+
createLineChart,
|
|
1673
|
+
createColumn,
|
|
1674
|
+
createCardGrid,
|
|
1675
|
+
createCard,
|
|
1676
|
+
createBarChart,
|
|
1677
|
+
createArtifact,
|
|
1678
|
+
createAreaChart,
|
|
1679
|
+
ToolHandlerProvider,
|
|
1680
|
+
GenerativeUIRenderer,
|
|
1681
|
+
ComponentRegistry,
|
|
1682
|
+
AgnoProvider
|
|
1778
1683
|
};
|
|
1684
|
+
|
|
1685
|
+
//# debugId=1246E6D11194364664756E2164756E21
|