@rodrigocoliveira/agno-react 1.1.6 → 1.3.0
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 +0 -3
- package/dist/hooks/useAgnoComponents.d.ts +54 -0
- package/dist/hooks/useAgnoComponents.d.ts.map +1 -0
- package/dist/hooks/useAgnoSessionState.d.ts +28 -0
- package/dist/hooks/useAgnoSessionState.d.ts.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +384 -130
- package/dist/index.js.map +6 -4
- package/dist/index.mjs +384 -130
- package/dist/index.mjs.map +6 -4
- package/dist/ui/composed/agno-chat/index.d.ts +0 -4
- package/dist/ui/composed/agno-chat/index.d.ts.map +1 -1
- package/dist/ui/composed/index.d.ts +2 -2
- package/dist/ui/composed/index.d.ts.map +1 -1
- package/dist/ui/index.d.ts +2 -2
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui.js +947 -1011
- package/dist/ui.js.map +4 -5
- package/dist/ui.mjs +947 -1011
- package/dist/ui.mjs.map +4 -5
- package/package.json +4 -4
- package/dist/ui/composed/agno-chat/tool-status.d.ts +0 -5
- package/dist/ui/composed/agno-chat/tool-status.d.ts.map +0 -1
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 { jsx } from "react/jsx-runtime";
|
|
5
5
|
var AgnoContext = createContext(null);
|
|
6
6
|
function AgnoProvider({ config, children }) {
|
|
7
7
|
const client = useMemo(() => new AgnoClient(config), []);
|
|
@@ -13,10 +13,10 @@ function AgnoProvider({ config, children }) {
|
|
|
13
13
|
client.removeAllListeners();
|
|
14
14
|
};
|
|
15
15
|
}, [client]);
|
|
16
|
-
return /* @__PURE__ */
|
|
16
|
+
return /* @__PURE__ */ jsx(AgnoContext.Provider, {
|
|
17
17
|
value: client,
|
|
18
18
|
children
|
|
19
|
-
}
|
|
19
|
+
});
|
|
20
20
|
}
|
|
21
21
|
function useAgnoClient() {
|
|
22
22
|
const client = useContext(AgnoContext);
|
|
@@ -27,7 +27,7 @@ function useAgnoClient() {
|
|
|
27
27
|
}
|
|
28
28
|
// src/context/ToolHandlerContext.tsx
|
|
29
29
|
import { createContext as createContext2, useContext as useContext2, useState, useCallback } from "react";
|
|
30
|
-
import {
|
|
30
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
31
31
|
var ToolHandlerContext = createContext2(null);
|
|
32
32
|
function ToolHandlerProvider({ handlers: initialHandlers = {}, children }) {
|
|
33
33
|
const [handlers, setHandlers] = useState(initialHandlers);
|
|
@@ -45,10 +45,10 @@ function ToolHandlerProvider({ handlers: initialHandlers = {}, children }) {
|
|
|
45
45
|
registerHandler,
|
|
46
46
|
unregisterHandler
|
|
47
47
|
};
|
|
48
|
-
return /* @__PURE__ */
|
|
48
|
+
return /* @__PURE__ */ jsx2(ToolHandlerContext.Provider, {
|
|
49
49
|
value,
|
|
50
50
|
children
|
|
51
|
-
}
|
|
51
|
+
});
|
|
52
52
|
}
|
|
53
53
|
function useToolHandlers() {
|
|
54
54
|
return useContext2(ToolHandlerContext);
|
|
@@ -334,7 +334,7 @@ function useAgnoToolExecution(handlers = {}, autoExecute = true, options) {
|
|
|
334
334
|
}
|
|
335
335
|
|
|
336
336
|
// src/components/GenerativeUIRenderer.tsx
|
|
337
|
-
import {
|
|
337
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
338
338
|
|
|
339
339
|
class UIErrorBoundary extends React3.Component {
|
|
340
340
|
constructor(props) {
|
|
@@ -350,19 +350,19 @@ class UIErrorBoundary extends React3.Component {
|
|
|
350
350
|
}
|
|
351
351
|
render() {
|
|
352
352
|
if (this.state.hasError) {
|
|
353
|
-
return this.props.fallback || /* @__PURE__ */
|
|
353
|
+
return this.props.fallback || /* @__PURE__ */ jsxs("div", {
|
|
354
354
|
className: "p-4 border border-red-300 rounded-md bg-red-50 text-red-800",
|
|
355
355
|
children: [
|
|
356
|
-
/* @__PURE__ */
|
|
356
|
+
/* @__PURE__ */ jsx3("p", {
|
|
357
357
|
className: "font-semibold",
|
|
358
358
|
children: "Failed to render UI component"
|
|
359
|
-
}
|
|
360
|
-
/* @__PURE__ */
|
|
359
|
+
}),
|
|
360
|
+
/* @__PURE__ */ jsx3("p", {
|
|
361
361
|
className: "text-sm mt-1",
|
|
362
362
|
children: this.state.error?.message || "Unknown error"
|
|
363
|
-
}
|
|
363
|
+
})
|
|
364
364
|
]
|
|
365
|
-
}
|
|
365
|
+
});
|
|
366
366
|
}
|
|
367
367
|
return this.props.children;
|
|
368
368
|
}
|
|
@@ -378,183 +378,183 @@ function GenerativeUIRenderer({
|
|
|
378
378
|
if (customSpec.renderKey) {
|
|
379
379
|
const renderFn = getCustomRender(customSpec.renderKey);
|
|
380
380
|
if (renderFn) {
|
|
381
|
-
return /* @__PURE__ */
|
|
381
|
+
return /* @__PURE__ */ jsx3(UIErrorBoundary, {
|
|
382
382
|
onError,
|
|
383
|
-
children: /* @__PURE__ */
|
|
383
|
+
children: /* @__PURE__ */ jsx3("div", {
|
|
384
384
|
className,
|
|
385
385
|
children: renderFn(customSpec.props || {})
|
|
386
|
-
}
|
|
387
|
-
}
|
|
386
|
+
})
|
|
387
|
+
});
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
|
-
return /* @__PURE__ */
|
|
390
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
391
391
|
className: `p-4 border border-yellow-300 rounded-md bg-yellow-50 text-yellow-800 ${className || ""}`,
|
|
392
392
|
children: [
|
|
393
|
-
/* @__PURE__ */
|
|
393
|
+
/* @__PURE__ */ jsx3("p", {
|
|
394
394
|
className: "font-semibold",
|
|
395
395
|
children: "Custom component not available"
|
|
396
|
-
}
|
|
397
|
-
/* @__PURE__ */
|
|
396
|
+
}),
|
|
397
|
+
/* @__PURE__ */ jsx3("p", {
|
|
398
398
|
className: "text-sm mt-1",
|
|
399
399
|
children: "The custom render function for this component is not available."
|
|
400
|
-
}
|
|
400
|
+
})
|
|
401
401
|
]
|
|
402
|
-
}
|
|
402
|
+
});
|
|
403
403
|
}
|
|
404
404
|
if (spec.type === "chart") {
|
|
405
405
|
const chartSpec = spec;
|
|
406
406
|
const chartType = `chart:${chartSpec.component}`;
|
|
407
407
|
if (registry.has(chartType)) {
|
|
408
408
|
const ChartRenderer = registry.get(chartType);
|
|
409
|
-
return /* @__PURE__ */
|
|
409
|
+
return /* @__PURE__ */ jsx3(UIErrorBoundary, {
|
|
410
410
|
onError,
|
|
411
|
-
children: /* @__PURE__ */
|
|
411
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
412
412
|
className,
|
|
413
413
|
children: [
|
|
414
|
-
chartSpec.title && /* @__PURE__ */
|
|
414
|
+
chartSpec.title && /* @__PURE__ */ jsx3("h3", {
|
|
415
415
|
className: "font-semibold mb-2",
|
|
416
416
|
children: chartSpec.title
|
|
417
|
-
}
|
|
418
|
-
chartSpec.description && /* @__PURE__ */
|
|
417
|
+
}),
|
|
418
|
+
chartSpec.description && /* @__PURE__ */ jsx3("p", {
|
|
419
419
|
className: "text-sm text-gray-600 mb-4",
|
|
420
420
|
children: chartSpec.description
|
|
421
|
-
}
|
|
422
|
-
/* @__PURE__ */
|
|
421
|
+
}),
|
|
422
|
+
/* @__PURE__ */ jsx3(ChartRenderer, {
|
|
423
423
|
...chartSpec.props
|
|
424
|
-
}
|
|
424
|
+
})
|
|
425
425
|
]
|
|
426
|
-
}
|
|
427
|
-
}
|
|
426
|
+
})
|
|
427
|
+
});
|
|
428
428
|
}
|
|
429
|
-
return /* @__PURE__ */
|
|
429
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
430
430
|
className: `p-4 border border-gray-300 rounded-md ${className || ""}`,
|
|
431
431
|
children: [
|
|
432
|
-
/* @__PURE__ */
|
|
432
|
+
/* @__PURE__ */ jsx3("p", {
|
|
433
433
|
className: "font-semibold mb-2",
|
|
434
434
|
children: chartSpec.title || "Chart Data"
|
|
435
|
-
}
|
|
436
|
-
chartSpec.description && /* @__PURE__ */
|
|
435
|
+
}),
|
|
436
|
+
chartSpec.description && /* @__PURE__ */ jsx3("p", {
|
|
437
437
|
className: "text-sm text-gray-600 mb-2",
|
|
438
438
|
children: chartSpec.description
|
|
439
|
-
}
|
|
440
|
-
/* @__PURE__ */
|
|
439
|
+
}),
|
|
440
|
+
/* @__PURE__ */ jsx3("pre", {
|
|
441
441
|
className: "text-xs bg-gray-100 p-2 rounded overflow-auto",
|
|
442
442
|
children: JSON.stringify(chartSpec.props.data, null, 2)
|
|
443
|
-
}
|
|
443
|
+
})
|
|
444
444
|
]
|
|
445
|
-
}
|
|
445
|
+
});
|
|
446
446
|
}
|
|
447
447
|
if (spec.type === "card-grid") {
|
|
448
448
|
const cardGridSpec = spec;
|
|
449
449
|
if (registry.has("card-grid")) {
|
|
450
450
|
const CardGridRenderer = registry.get("card-grid");
|
|
451
|
-
return /* @__PURE__ */
|
|
451
|
+
return /* @__PURE__ */ jsx3(UIErrorBoundary, {
|
|
452
452
|
onError,
|
|
453
|
-
children: /* @__PURE__ */
|
|
453
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
454
454
|
className,
|
|
455
455
|
children: [
|
|
456
|
-
cardGridSpec.title && /* @__PURE__ */
|
|
456
|
+
cardGridSpec.title && /* @__PURE__ */ jsx3("h3", {
|
|
457
457
|
className: "font-semibold mb-2",
|
|
458
458
|
children: cardGridSpec.title
|
|
459
|
-
}
|
|
460
|
-
cardGridSpec.description && /* @__PURE__ */
|
|
459
|
+
}),
|
|
460
|
+
cardGridSpec.description && /* @__PURE__ */ jsx3("p", {
|
|
461
461
|
className: "text-sm text-gray-600 mb-4",
|
|
462
462
|
children: cardGridSpec.description
|
|
463
|
-
}
|
|
464
|
-
/* @__PURE__ */
|
|
463
|
+
}),
|
|
464
|
+
/* @__PURE__ */ jsx3(CardGridRenderer, {
|
|
465
465
|
...cardGridSpec.props
|
|
466
|
-
}
|
|
466
|
+
})
|
|
467
467
|
]
|
|
468
|
-
}
|
|
469
|
-
}
|
|
468
|
+
})
|
|
469
|
+
});
|
|
470
470
|
}
|
|
471
471
|
}
|
|
472
472
|
if (spec.type === "table") {
|
|
473
473
|
const tableSpec = spec;
|
|
474
474
|
if (registry.has("table")) {
|
|
475
475
|
const TableRenderer = registry.get("table");
|
|
476
|
-
return /* @__PURE__ */
|
|
476
|
+
return /* @__PURE__ */ jsx3(UIErrorBoundary, {
|
|
477
477
|
onError,
|
|
478
|
-
children: /* @__PURE__ */
|
|
478
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
479
479
|
className,
|
|
480
480
|
children: [
|
|
481
|
-
tableSpec.title && /* @__PURE__ */
|
|
481
|
+
tableSpec.title && /* @__PURE__ */ jsx3("h3", {
|
|
482
482
|
className: "font-semibold mb-2",
|
|
483
483
|
children: tableSpec.title
|
|
484
|
-
}
|
|
485
|
-
tableSpec.description && /* @__PURE__ */
|
|
484
|
+
}),
|
|
485
|
+
tableSpec.description && /* @__PURE__ */ jsx3("p", {
|
|
486
486
|
className: "text-sm text-gray-600 mb-4",
|
|
487
487
|
children: tableSpec.description
|
|
488
|
-
}
|
|
489
|
-
/* @__PURE__ */
|
|
488
|
+
}),
|
|
489
|
+
/* @__PURE__ */ jsx3(TableRenderer, {
|
|
490
490
|
...tableSpec.props
|
|
491
|
-
}
|
|
491
|
+
})
|
|
492
492
|
]
|
|
493
|
-
}
|
|
494
|
-
}
|
|
493
|
+
})
|
|
494
|
+
});
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
497
|
if (spec.type === "markdown") {
|
|
498
498
|
const markdownSpec = spec;
|
|
499
499
|
if (registry.has("markdown")) {
|
|
500
500
|
const MarkdownRenderer = registry.get("markdown");
|
|
501
|
-
return /* @__PURE__ */
|
|
501
|
+
return /* @__PURE__ */ jsx3(UIErrorBoundary, {
|
|
502
502
|
onError,
|
|
503
|
-
children: /* @__PURE__ */
|
|
503
|
+
children: /* @__PURE__ */ jsx3("div", {
|
|
504
504
|
className,
|
|
505
|
-
children: /* @__PURE__ */
|
|
505
|
+
children: /* @__PURE__ */ jsx3(MarkdownRenderer, {
|
|
506
506
|
...markdownSpec.props
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
}
|
|
507
|
+
})
|
|
508
|
+
})
|
|
509
|
+
});
|
|
510
510
|
}
|
|
511
|
-
return /* @__PURE__ */
|
|
511
|
+
return /* @__PURE__ */ jsx3("div", {
|
|
512
512
|
className,
|
|
513
513
|
children: markdownSpec.props.content
|
|
514
|
-
}
|
|
514
|
+
});
|
|
515
515
|
}
|
|
516
516
|
if (spec.type === "artifact") {
|
|
517
517
|
const artifactSpec = spec;
|
|
518
|
-
return /* @__PURE__ */
|
|
518
|
+
return /* @__PURE__ */ jsx3(UIErrorBoundary, {
|
|
519
519
|
onError,
|
|
520
|
-
children: /* @__PURE__ */
|
|
520
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
521
521
|
className: `p-4 border rounded-md ${className || ""}`,
|
|
522
522
|
children: [
|
|
523
|
-
artifactSpec.title && /* @__PURE__ */
|
|
523
|
+
artifactSpec.title && /* @__PURE__ */ jsx3("h3", {
|
|
524
524
|
className: "font-semibold mb-4",
|
|
525
525
|
children: artifactSpec.title
|
|
526
|
-
}
|
|
527
|
-
artifactSpec.description && /* @__PURE__ */
|
|
526
|
+
}),
|
|
527
|
+
artifactSpec.description && /* @__PURE__ */ jsx3("p", {
|
|
528
528
|
className: "text-sm text-gray-600 mb-4",
|
|
529
529
|
children: artifactSpec.description
|
|
530
|
-
}
|
|
531
|
-
/* @__PURE__ */
|
|
530
|
+
}),
|
|
531
|
+
/* @__PURE__ */ jsx3("div", {
|
|
532
532
|
className: "space-y-4",
|
|
533
|
-
children: artifactSpec.props.content?.map((childSpec, index) => /* @__PURE__ */
|
|
533
|
+
children: artifactSpec.props.content?.map((childSpec, index) => /* @__PURE__ */ jsx3(GenerativeUIRenderer, {
|
|
534
534
|
spec: childSpec,
|
|
535
535
|
onError
|
|
536
|
-
}, index
|
|
537
|
-
}
|
|
536
|
+
}, index))
|
|
537
|
+
})
|
|
538
538
|
]
|
|
539
|
-
}
|
|
540
|
-
}
|
|
539
|
+
})
|
|
540
|
+
});
|
|
541
541
|
}
|
|
542
|
-
return /* @__PURE__ */
|
|
542
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
543
543
|
className: `p-4 border border-gray-300 rounded-md ${className || ""}`,
|
|
544
544
|
children: [
|
|
545
|
-
/* @__PURE__ */
|
|
545
|
+
/* @__PURE__ */ jsx3("p", {
|
|
546
546
|
className: "font-semibold",
|
|
547
547
|
children: "Unsupported UI component"
|
|
548
|
-
}
|
|
549
|
-
/* @__PURE__ */
|
|
548
|
+
}),
|
|
549
|
+
/* @__PURE__ */ jsxs("p", {
|
|
550
550
|
className: "text-sm text-gray-600 mt-1",
|
|
551
551
|
children: [
|
|
552
552
|
"Component type: ",
|
|
553
553
|
spec.type
|
|
554
554
|
]
|
|
555
|
-
}
|
|
555
|
+
})
|
|
556
556
|
]
|
|
557
|
-
}
|
|
557
|
+
});
|
|
558
558
|
}
|
|
559
559
|
// src/utils/ui-helpers.ts
|
|
560
560
|
function createBarChart(data, xKey, bars, options) {
|
|
@@ -1253,15 +1253,59 @@ function useAgnoMemory() {
|
|
|
1253
1253
|
deleteMultipleMemories
|
|
1254
1254
|
};
|
|
1255
1255
|
}
|
|
1256
|
+
// src/hooks/useAgnoSessionState.ts
|
|
1257
|
+
import { useCallback as useCallback8, useEffect as useEffect7, useState as useState8 } from "react";
|
|
1258
|
+
function useAgnoSessionState() {
|
|
1259
|
+
const client = useAgnoClient();
|
|
1260
|
+
const [sessionState, setLocalSessionState] = useState8(() => client.getSessionState());
|
|
1261
|
+
const [isRefreshing, setIsRefreshing] = useState8(() => client.getState().isSessionStateRefreshing ?? false);
|
|
1262
|
+
useEffect7(() => {
|
|
1263
|
+
const handleStateChange = (state) => {
|
|
1264
|
+
setLocalSessionState(state);
|
|
1265
|
+
};
|
|
1266
|
+
const handleRefreshStart = () => setIsRefreshing(true);
|
|
1267
|
+
const handleRefreshEnd = () => setIsRefreshing(false);
|
|
1268
|
+
client.on("session-state:change", handleStateChange);
|
|
1269
|
+
client.on("session-state:refresh:start", handleRefreshStart);
|
|
1270
|
+
client.on("session-state:refresh:end", handleRefreshEnd);
|
|
1271
|
+
setLocalSessionState(client.getSessionState());
|
|
1272
|
+
setIsRefreshing(client.getState().isSessionStateRefreshing ?? false);
|
|
1273
|
+
return () => {
|
|
1274
|
+
client.off("session-state:change", handleStateChange);
|
|
1275
|
+
client.off("session-state:refresh:start", handleRefreshStart);
|
|
1276
|
+
client.off("session-state:refresh:end", handleRefreshEnd);
|
|
1277
|
+
};
|
|
1278
|
+
}, [client]);
|
|
1279
|
+
const setSessionState = useCallback8(async (next) => {
|
|
1280
|
+
const resolved = typeof next === "function" ? next(client.getSessionState()) : next;
|
|
1281
|
+
await client.setSessionState(resolved);
|
|
1282
|
+
}, [client]);
|
|
1283
|
+
const mergeSessionState = useCallback8(async (partial) => {
|
|
1284
|
+
const current = client.getSessionState() ?? {};
|
|
1285
|
+
const merged = { ...current, ...partial };
|
|
1286
|
+
await client.setSessionState(merged);
|
|
1287
|
+
}, [client]);
|
|
1288
|
+
const refreshSessionState = useCallback8(async () => {
|
|
1289
|
+
const result = await client.refreshSessionState();
|
|
1290
|
+
return result ?? null;
|
|
1291
|
+
}, [client]);
|
|
1292
|
+
return {
|
|
1293
|
+
sessionState,
|
|
1294
|
+
isRefreshing,
|
|
1295
|
+
setSessionState,
|
|
1296
|
+
mergeSessionState,
|
|
1297
|
+
refreshSessionState
|
|
1298
|
+
};
|
|
1299
|
+
}
|
|
1256
1300
|
// src/hooks/useAgnoKnowledge.ts
|
|
1257
|
-
import { useState as
|
|
1301
|
+
import { useState as useState9, useCallback as useCallback9 } from "react";
|
|
1258
1302
|
function useAgnoKnowledge() {
|
|
1259
1303
|
const client = useAgnoClient();
|
|
1260
|
-
const [isLoading, setIsLoading] =
|
|
1261
|
-
const [error, setError] =
|
|
1262
|
-
const [config, setConfig] =
|
|
1263
|
-
const [content, setContent] =
|
|
1264
|
-
const getConfig =
|
|
1304
|
+
const [isLoading, setIsLoading] = useState9(false);
|
|
1305
|
+
const [error, setError] = useState9();
|
|
1306
|
+
const [config, setConfig] = useState9();
|
|
1307
|
+
const [content, setContent] = useState9([]);
|
|
1308
|
+
const getConfig = useCallback9(async (options) => {
|
|
1265
1309
|
setIsLoading(true);
|
|
1266
1310
|
setError(undefined);
|
|
1267
1311
|
try {
|
|
@@ -1276,7 +1320,7 @@ function useAgnoKnowledge() {
|
|
|
1276
1320
|
setIsLoading(false);
|
|
1277
1321
|
}
|
|
1278
1322
|
}, [client]);
|
|
1279
|
-
const listContent =
|
|
1323
|
+
const listContent = useCallback9(async (listOptions, options) => {
|
|
1280
1324
|
setIsLoading(true);
|
|
1281
1325
|
setError(undefined);
|
|
1282
1326
|
try {
|
|
@@ -1291,7 +1335,7 @@ function useAgnoKnowledge() {
|
|
|
1291
1335
|
setIsLoading(false);
|
|
1292
1336
|
}
|
|
1293
1337
|
}, [client]);
|
|
1294
|
-
const getContent =
|
|
1338
|
+
const getContent = useCallback9(async (contentId, options) => {
|
|
1295
1339
|
setIsLoading(true);
|
|
1296
1340
|
setError(undefined);
|
|
1297
1341
|
try {
|
|
@@ -1304,7 +1348,7 @@ function useAgnoKnowledge() {
|
|
|
1304
1348
|
setIsLoading(false);
|
|
1305
1349
|
}
|
|
1306
1350
|
}, [client]);
|
|
1307
|
-
const getContentStatus =
|
|
1351
|
+
const getContentStatus = useCallback9(async (contentId, options) => {
|
|
1308
1352
|
setIsLoading(true);
|
|
1309
1353
|
setError(undefined);
|
|
1310
1354
|
try {
|
|
@@ -1317,7 +1361,7 @@ function useAgnoKnowledge() {
|
|
|
1317
1361
|
setIsLoading(false);
|
|
1318
1362
|
}
|
|
1319
1363
|
}, [client]);
|
|
1320
|
-
const search =
|
|
1364
|
+
const search = useCallback9(async (request, options) => {
|
|
1321
1365
|
setIsLoading(true);
|
|
1322
1366
|
setError(undefined);
|
|
1323
1367
|
try {
|
|
@@ -1330,7 +1374,7 @@ function useAgnoKnowledge() {
|
|
|
1330
1374
|
setIsLoading(false);
|
|
1331
1375
|
}
|
|
1332
1376
|
}, [client]);
|
|
1333
|
-
const uploadContent =
|
|
1377
|
+
const uploadContent = useCallback9(async (data, options) => {
|
|
1334
1378
|
setIsLoading(true);
|
|
1335
1379
|
setError(undefined);
|
|
1336
1380
|
try {
|
|
@@ -1345,7 +1389,7 @@ function useAgnoKnowledge() {
|
|
|
1345
1389
|
setIsLoading(false);
|
|
1346
1390
|
}
|
|
1347
1391
|
}, [client]);
|
|
1348
|
-
const updateContent =
|
|
1392
|
+
const updateContent = useCallback9(async (contentId, request, options) => {
|
|
1349
1393
|
setIsLoading(true);
|
|
1350
1394
|
setError(undefined);
|
|
1351
1395
|
try {
|
|
@@ -1360,7 +1404,7 @@ function useAgnoKnowledge() {
|
|
|
1360
1404
|
setIsLoading(false);
|
|
1361
1405
|
}
|
|
1362
1406
|
}, [client]);
|
|
1363
|
-
const deleteAllContent =
|
|
1407
|
+
const deleteAllContent = useCallback9(async (options) => {
|
|
1364
1408
|
setIsLoading(true);
|
|
1365
1409
|
setError(undefined);
|
|
1366
1410
|
try {
|
|
@@ -1374,7 +1418,7 @@ function useAgnoKnowledge() {
|
|
|
1374
1418
|
setIsLoading(false);
|
|
1375
1419
|
}
|
|
1376
1420
|
}, [client]);
|
|
1377
|
-
const deleteContent =
|
|
1421
|
+
const deleteContent = useCallback9(async (contentId, options) => {
|
|
1378
1422
|
setIsLoading(true);
|
|
1379
1423
|
setError(undefined);
|
|
1380
1424
|
try {
|
|
@@ -1406,14 +1450,14 @@ function useAgnoKnowledge() {
|
|
|
1406
1450
|
};
|
|
1407
1451
|
}
|
|
1408
1452
|
// src/hooks/useAgnoMetrics.ts
|
|
1409
|
-
import { useState as
|
|
1453
|
+
import { useState as useState10, useCallback as useCallback10 } from "react";
|
|
1410
1454
|
function useAgnoMetrics() {
|
|
1411
1455
|
const client = useAgnoClient();
|
|
1412
|
-
const [isLoading, setIsLoading] =
|
|
1413
|
-
const [isRefreshing, setIsRefreshing] =
|
|
1414
|
-
const [error, setError] =
|
|
1415
|
-
const [metrics, setMetrics] =
|
|
1416
|
-
const fetchMetrics =
|
|
1456
|
+
const [isLoading, setIsLoading] = useState10(false);
|
|
1457
|
+
const [isRefreshing, setIsRefreshing] = useState10(false);
|
|
1458
|
+
const [error, setError] = useState10();
|
|
1459
|
+
const [metrics, setMetrics] = useState10();
|
|
1460
|
+
const fetchMetrics = useCallback10(async (options) => {
|
|
1417
1461
|
setIsLoading(true);
|
|
1418
1462
|
setError(undefined);
|
|
1419
1463
|
try {
|
|
@@ -1428,7 +1472,7 @@ function useAgnoMetrics() {
|
|
|
1428
1472
|
setIsLoading(false);
|
|
1429
1473
|
}
|
|
1430
1474
|
}, [client]);
|
|
1431
|
-
const refreshMetrics =
|
|
1475
|
+
const refreshMetrics = useCallback10(async (options) => {
|
|
1432
1476
|
setIsRefreshing(true);
|
|
1433
1477
|
setError(undefined);
|
|
1434
1478
|
try {
|
|
@@ -1442,7 +1486,7 @@ function useAgnoMetrics() {
|
|
|
1442
1486
|
setIsRefreshing(false);
|
|
1443
1487
|
}
|
|
1444
1488
|
}, [client]);
|
|
1445
|
-
const clearMetrics =
|
|
1489
|
+
const clearMetrics = useCallback10(() => {
|
|
1446
1490
|
setMetrics(undefined);
|
|
1447
1491
|
setError(undefined);
|
|
1448
1492
|
}, []);
|
|
@@ -1457,14 +1501,14 @@ function useAgnoMetrics() {
|
|
|
1457
1501
|
};
|
|
1458
1502
|
}
|
|
1459
1503
|
// src/hooks/useAgnoEvals.ts
|
|
1460
|
-
import { useState as
|
|
1504
|
+
import { useState as useState11, useCallback as useCallback11 } from "react";
|
|
1461
1505
|
function useAgnoEvals() {
|
|
1462
1506
|
const client = useAgnoClient();
|
|
1463
|
-
const [evalRuns, setEvalRuns] =
|
|
1464
|
-
const [pagination, setPagination] =
|
|
1465
|
-
const [isLoading, setIsLoading] =
|
|
1466
|
-
const [error, setError] =
|
|
1467
|
-
const listEvalRuns =
|
|
1507
|
+
const [evalRuns, setEvalRuns] = useState11([]);
|
|
1508
|
+
const [pagination, setPagination] = useState11();
|
|
1509
|
+
const [isLoading, setIsLoading] = useState11(false);
|
|
1510
|
+
const [error, setError] = useState11();
|
|
1511
|
+
const listEvalRuns = useCallback11(async (listParams = {}, options) => {
|
|
1468
1512
|
setIsLoading(true);
|
|
1469
1513
|
setError(undefined);
|
|
1470
1514
|
try {
|
|
@@ -1480,7 +1524,7 @@ function useAgnoEvals() {
|
|
|
1480
1524
|
setIsLoading(false);
|
|
1481
1525
|
}
|
|
1482
1526
|
}, [client]);
|
|
1483
|
-
const getEvalRun =
|
|
1527
|
+
const getEvalRun = useCallback11(async (evalRunId, options) => {
|
|
1484
1528
|
setIsLoading(true);
|
|
1485
1529
|
setError(undefined);
|
|
1486
1530
|
try {
|
|
@@ -1493,7 +1537,7 @@ function useAgnoEvals() {
|
|
|
1493
1537
|
setIsLoading(false);
|
|
1494
1538
|
}
|
|
1495
1539
|
}, [client]);
|
|
1496
|
-
const executeEval =
|
|
1540
|
+
const executeEval = useCallback11(async (request, options) => {
|
|
1497
1541
|
setIsLoading(true);
|
|
1498
1542
|
setError(undefined);
|
|
1499
1543
|
try {
|
|
@@ -1508,7 +1552,7 @@ function useAgnoEvals() {
|
|
|
1508
1552
|
setIsLoading(false);
|
|
1509
1553
|
}
|
|
1510
1554
|
}, [client]);
|
|
1511
|
-
const updateEvalRun =
|
|
1555
|
+
const updateEvalRun = useCallback11(async (evalRunId, request, options) => {
|
|
1512
1556
|
setIsLoading(true);
|
|
1513
1557
|
setError(undefined);
|
|
1514
1558
|
try {
|
|
@@ -1523,7 +1567,7 @@ function useAgnoEvals() {
|
|
|
1523
1567
|
setIsLoading(false);
|
|
1524
1568
|
}
|
|
1525
1569
|
}, [client]);
|
|
1526
|
-
const deleteEvalRuns =
|
|
1570
|
+
const deleteEvalRuns = useCallback11(async (evalRunIds, options) => {
|
|
1527
1571
|
setIsLoading(true);
|
|
1528
1572
|
setError(undefined);
|
|
1529
1573
|
try {
|
|
@@ -1538,7 +1582,7 @@ function useAgnoEvals() {
|
|
|
1538
1582
|
setIsLoading(false);
|
|
1539
1583
|
}
|
|
1540
1584
|
}, [client]);
|
|
1541
|
-
const renameEvalRun =
|
|
1585
|
+
const renameEvalRun = useCallback11(async (evalRunId, newName, options) => {
|
|
1542
1586
|
return updateEvalRun(evalRunId, { name: newName }, options);
|
|
1543
1587
|
}, [updateEvalRun]);
|
|
1544
1588
|
return {
|
|
@@ -1555,14 +1599,14 @@ function useAgnoEvals() {
|
|
|
1555
1599
|
};
|
|
1556
1600
|
}
|
|
1557
1601
|
// src/hooks/useAgnoTraces.ts
|
|
1558
|
-
import { useState as
|
|
1602
|
+
import { useState as useState12, useEffect as useEffect8, useCallback as useCallback12 } from "react";
|
|
1559
1603
|
function useAgnoTraces() {
|
|
1560
1604
|
const client = useAgnoClient();
|
|
1561
|
-
const [traces, setTraces] =
|
|
1562
|
-
const [traceSessionStats, setTraceSessionStats] =
|
|
1563
|
-
const [isLoading, setIsLoading] =
|
|
1564
|
-
const [error, setError] =
|
|
1565
|
-
|
|
1605
|
+
const [traces, setTraces] = useState12([]);
|
|
1606
|
+
const [traceSessionStats, setTraceSessionStats] = useState12([]);
|
|
1607
|
+
const [isLoading, setIsLoading] = useState12(false);
|
|
1608
|
+
const [error, setError] = useState12();
|
|
1609
|
+
useEffect8(() => {
|
|
1566
1610
|
const handleStateChange = () => {
|
|
1567
1611
|
const state2 = client.getState();
|
|
1568
1612
|
setTraces(state2.traces);
|
|
@@ -1576,7 +1620,7 @@ function useAgnoTraces() {
|
|
|
1576
1620
|
client.off("state:change", handleStateChange);
|
|
1577
1621
|
};
|
|
1578
1622
|
}, [client]);
|
|
1579
|
-
const fetchTraces =
|
|
1623
|
+
const fetchTraces = useCallback12(async (options = {}, requestOptions) => {
|
|
1580
1624
|
setIsLoading(true);
|
|
1581
1625
|
setError(undefined);
|
|
1582
1626
|
try {
|
|
@@ -1591,7 +1635,7 @@ function useAgnoTraces() {
|
|
|
1591
1635
|
setIsLoading(false);
|
|
1592
1636
|
}
|
|
1593
1637
|
}, [client]);
|
|
1594
|
-
const getTraceDetail =
|
|
1638
|
+
const getTraceDetail = useCallback12(async (traceId, options = {}, requestOptions) => {
|
|
1595
1639
|
setIsLoading(true);
|
|
1596
1640
|
setError(undefined);
|
|
1597
1641
|
try {
|
|
@@ -1604,7 +1648,7 @@ function useAgnoTraces() {
|
|
|
1604
1648
|
setIsLoading(false);
|
|
1605
1649
|
}
|
|
1606
1650
|
}, [client]);
|
|
1607
|
-
const fetchTraceSessionStats =
|
|
1651
|
+
const fetchTraceSessionStats = useCallback12(async (options = {}, requestOptions) => {
|
|
1608
1652
|
setIsLoading(true);
|
|
1609
1653
|
setError(undefined);
|
|
1610
1654
|
try {
|
|
@@ -1629,16 +1673,226 @@ function useAgnoTraces() {
|
|
|
1629
1673
|
error
|
|
1630
1674
|
};
|
|
1631
1675
|
}
|
|
1676
|
+
// src/hooks/useAgnoComponents.ts
|
|
1677
|
+
import { useState as useState13, useEffect as useEffect9, useCallback as useCallback13 } from "react";
|
|
1678
|
+
function useAgnoComponents() {
|
|
1679
|
+
const client = useAgnoClient();
|
|
1680
|
+
const [components, setComponents] = useState13([]);
|
|
1681
|
+
const [isLoading, setIsLoading] = useState13(false);
|
|
1682
|
+
const [error, setError] = useState13();
|
|
1683
|
+
useEffect9(() => {
|
|
1684
|
+
const handleComponentCreated = (component) => {
|
|
1685
|
+
setComponents((prev) => [component, ...prev]);
|
|
1686
|
+
};
|
|
1687
|
+
const handleComponentUpdated = (component) => {
|
|
1688
|
+
setComponents((prev) => prev.map((c) => c.component_id === component.component_id ? component : c));
|
|
1689
|
+
};
|
|
1690
|
+
const handleComponentDeleted = ({ componentId }) => {
|
|
1691
|
+
setComponents((prev) => prev.filter((c) => c.component_id !== componentId));
|
|
1692
|
+
};
|
|
1693
|
+
const handleStateChange = () => {
|
|
1694
|
+
setComponents(client.getState().components);
|
|
1695
|
+
};
|
|
1696
|
+
client.on("component:created", handleComponentCreated);
|
|
1697
|
+
client.on("component:updated", handleComponentUpdated);
|
|
1698
|
+
client.on("component:deleted", handleComponentDeleted);
|
|
1699
|
+
client.on("state:change", handleStateChange);
|
|
1700
|
+
setComponents(client.getState().components);
|
|
1701
|
+
return () => {
|
|
1702
|
+
client.off("component:created", handleComponentCreated);
|
|
1703
|
+
client.off("component:updated", handleComponentUpdated);
|
|
1704
|
+
client.off("component:deleted", handleComponentDeleted);
|
|
1705
|
+
client.off("state:change", handleStateChange);
|
|
1706
|
+
};
|
|
1707
|
+
}, [client]);
|
|
1708
|
+
const fetchComponents = useCallback13(async (queryParams, options) => {
|
|
1709
|
+
setIsLoading(true);
|
|
1710
|
+
setError(undefined);
|
|
1711
|
+
try {
|
|
1712
|
+
const response = await client.fetchComponents(queryParams, options);
|
|
1713
|
+
setComponents(response.data);
|
|
1714
|
+
return response;
|
|
1715
|
+
} catch (err) {
|
|
1716
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1717
|
+
setError(errorMessage);
|
|
1718
|
+
throw err;
|
|
1719
|
+
} finally {
|
|
1720
|
+
setIsLoading(false);
|
|
1721
|
+
}
|
|
1722
|
+
}, [client]);
|
|
1723
|
+
const getComponentById = useCallback13(async (componentId, options) => {
|
|
1724
|
+
setIsLoading(true);
|
|
1725
|
+
setError(undefined);
|
|
1726
|
+
try {
|
|
1727
|
+
return await client.getComponentById(componentId, options);
|
|
1728
|
+
} catch (err) {
|
|
1729
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1730
|
+
setError(errorMessage);
|
|
1731
|
+
throw err;
|
|
1732
|
+
} finally {
|
|
1733
|
+
setIsLoading(false);
|
|
1734
|
+
}
|
|
1735
|
+
}, [client]);
|
|
1736
|
+
const createComponent = useCallback13(async (request, options) => {
|
|
1737
|
+
setIsLoading(true);
|
|
1738
|
+
setError(undefined);
|
|
1739
|
+
try {
|
|
1740
|
+
return await client.createComponent(request, options);
|
|
1741
|
+
} catch (err) {
|
|
1742
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1743
|
+
setError(errorMessage);
|
|
1744
|
+
throw err;
|
|
1745
|
+
} finally {
|
|
1746
|
+
setIsLoading(false);
|
|
1747
|
+
}
|
|
1748
|
+
}, [client]);
|
|
1749
|
+
const updateComponent = useCallback13(async (componentId, request, options) => {
|
|
1750
|
+
setIsLoading(true);
|
|
1751
|
+
setError(undefined);
|
|
1752
|
+
try {
|
|
1753
|
+
return await client.updateComponent(componentId, request, options);
|
|
1754
|
+
} catch (err) {
|
|
1755
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1756
|
+
setError(errorMessage);
|
|
1757
|
+
throw err;
|
|
1758
|
+
} finally {
|
|
1759
|
+
setIsLoading(false);
|
|
1760
|
+
}
|
|
1761
|
+
}, [client]);
|
|
1762
|
+
const deleteComponent = useCallback13(async (componentId, options) => {
|
|
1763
|
+
setIsLoading(true);
|
|
1764
|
+
setError(undefined);
|
|
1765
|
+
try {
|
|
1766
|
+
await client.deleteComponent(componentId, options);
|
|
1767
|
+
} catch (err) {
|
|
1768
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1769
|
+
setError(errorMessage);
|
|
1770
|
+
throw err;
|
|
1771
|
+
} finally {
|
|
1772
|
+
setIsLoading(false);
|
|
1773
|
+
}
|
|
1774
|
+
}, [client]);
|
|
1775
|
+
const fetchComponentConfigs = useCallback13(async (componentId, options) => {
|
|
1776
|
+
setIsLoading(true);
|
|
1777
|
+
setError(undefined);
|
|
1778
|
+
try {
|
|
1779
|
+
return await client.fetchComponentConfigs(componentId, options);
|
|
1780
|
+
} catch (err) {
|
|
1781
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1782
|
+
setError(errorMessage);
|
|
1783
|
+
throw err;
|
|
1784
|
+
} finally {
|
|
1785
|
+
setIsLoading(false);
|
|
1786
|
+
}
|
|
1787
|
+
}, [client]);
|
|
1788
|
+
const createComponentConfig = useCallback13(async (componentId, request, options) => {
|
|
1789
|
+
setIsLoading(true);
|
|
1790
|
+
setError(undefined);
|
|
1791
|
+
try {
|
|
1792
|
+
return await client.createComponentConfig(componentId, request, options);
|
|
1793
|
+
} catch (err) {
|
|
1794
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1795
|
+
setError(errorMessage);
|
|
1796
|
+
throw err;
|
|
1797
|
+
} finally {
|
|
1798
|
+
setIsLoading(false);
|
|
1799
|
+
}
|
|
1800
|
+
}, [client]);
|
|
1801
|
+
const getCurrentComponentConfig = useCallback13(async (componentId, options) => {
|
|
1802
|
+
setIsLoading(true);
|
|
1803
|
+
setError(undefined);
|
|
1804
|
+
try {
|
|
1805
|
+
return await client.getCurrentComponentConfig(componentId, options);
|
|
1806
|
+
} catch (err) {
|
|
1807
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1808
|
+
setError(errorMessage);
|
|
1809
|
+
throw err;
|
|
1810
|
+
} finally {
|
|
1811
|
+
setIsLoading(false);
|
|
1812
|
+
}
|
|
1813
|
+
}, [client]);
|
|
1814
|
+
const getComponentConfigByVersion = useCallback13(async (componentId, version, options) => {
|
|
1815
|
+
setIsLoading(true);
|
|
1816
|
+
setError(undefined);
|
|
1817
|
+
try {
|
|
1818
|
+
return await client.getComponentConfigByVersion(componentId, version, options);
|
|
1819
|
+
} catch (err) {
|
|
1820
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1821
|
+
setError(errorMessage);
|
|
1822
|
+
throw err;
|
|
1823
|
+
} finally {
|
|
1824
|
+
setIsLoading(false);
|
|
1825
|
+
}
|
|
1826
|
+
}, [client]);
|
|
1827
|
+
const updateComponentConfig = useCallback13(async (componentId, version, request, options) => {
|
|
1828
|
+
setIsLoading(true);
|
|
1829
|
+
setError(undefined);
|
|
1830
|
+
try {
|
|
1831
|
+
return await client.updateComponentConfig(componentId, version, request, options);
|
|
1832
|
+
} catch (err) {
|
|
1833
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1834
|
+
setError(errorMessage);
|
|
1835
|
+
throw err;
|
|
1836
|
+
} finally {
|
|
1837
|
+
setIsLoading(false);
|
|
1838
|
+
}
|
|
1839
|
+
}, [client]);
|
|
1840
|
+
const deleteComponentConfig = useCallback13(async (componentId, version, options) => {
|
|
1841
|
+
setIsLoading(true);
|
|
1842
|
+
setError(undefined);
|
|
1843
|
+
try {
|
|
1844
|
+
await client.deleteComponentConfig(componentId, version, options);
|
|
1845
|
+
} catch (err) {
|
|
1846
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1847
|
+
setError(errorMessage);
|
|
1848
|
+
throw err;
|
|
1849
|
+
} finally {
|
|
1850
|
+
setIsLoading(false);
|
|
1851
|
+
}
|
|
1852
|
+
}, [client]);
|
|
1853
|
+
const setCurrentComponentConfig = useCallback13(async (componentId, version, options) => {
|
|
1854
|
+
setIsLoading(true);
|
|
1855
|
+
setError(undefined);
|
|
1856
|
+
try {
|
|
1857
|
+
return await client.setCurrentComponentConfig(componentId, version, options);
|
|
1858
|
+
} catch (err) {
|
|
1859
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1860
|
+
setError(errorMessage);
|
|
1861
|
+
throw err;
|
|
1862
|
+
} finally {
|
|
1863
|
+
setIsLoading(false);
|
|
1864
|
+
}
|
|
1865
|
+
}, [client]);
|
|
1866
|
+
return {
|
|
1867
|
+
components,
|
|
1868
|
+
isLoading,
|
|
1869
|
+
error,
|
|
1870
|
+
fetchComponents,
|
|
1871
|
+
getComponentById,
|
|
1872
|
+
createComponent,
|
|
1873
|
+
updateComponent,
|
|
1874
|
+
deleteComponent,
|
|
1875
|
+
fetchComponentConfigs,
|
|
1876
|
+
createComponentConfig,
|
|
1877
|
+
getCurrentComponentConfig,
|
|
1878
|
+
getComponentConfigByVersion,
|
|
1879
|
+
updateComponentConfig,
|
|
1880
|
+
deleteComponentConfig,
|
|
1881
|
+
setCurrentComponentConfig
|
|
1882
|
+
};
|
|
1883
|
+
}
|
|
1632
1884
|
export {
|
|
1633
1885
|
useToolHandlers,
|
|
1634
1886
|
useAgnoTraces,
|
|
1635
1887
|
useAgnoToolExecution,
|
|
1888
|
+
useAgnoSessionState,
|
|
1636
1889
|
useAgnoSession,
|
|
1637
1890
|
useAgnoMetrics,
|
|
1638
1891
|
useAgnoMemory,
|
|
1639
1892
|
useAgnoKnowledge,
|
|
1640
1893
|
useAgnoEvals,
|
|
1641
1894
|
useAgnoCustomEvents,
|
|
1895
|
+
useAgnoComponents,
|
|
1642
1896
|
useAgnoClient,
|
|
1643
1897
|
useAgnoChat,
|
|
1644
1898
|
useAgnoActions,
|
|
@@ -1668,4 +1922,4 @@ export {
|
|
|
1668
1922
|
AgnoProvider
|
|
1669
1923
|
};
|
|
1670
1924
|
|
|
1671
|
-
//# debugId=
|
|
1925
|
+
//# debugId=001BF048D0CD48E164756E2164756E21
|