@antipopp/agno-react 0.4.0 → 0.5.1

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/dist/index.js CHANGED
@@ -70,6 +70,9 @@ var import_jsx_runtime = require("react/jsx-runtime");
70
70
  var AgnoContext = (0, import_react.createContext)(null);
71
71
  function AgnoProvider({ config, children }) {
72
72
  const client = (0, import_react.useMemo)(() => new import_agno_client.AgnoClient(config), []);
73
+ (0, import_react.useEffect)(() => {
74
+ client.updateConfig(config);
75
+ }, [client, config]);
73
76
  (0, import_react.useEffect)(() => {
74
77
  return () => {
75
78
  client.removeAllListeners();
@@ -699,10 +702,37 @@ function createSmartChart(data, options) {
699
702
  ) || keys[0];
700
703
  const numericKeys = keys.filter((k) => k !== xKey && typeof firstItem[k] === "number");
701
704
  const yKeys = options?.yKeys || numericKeys;
702
- if ((options?.preferredType === "pie" || yKeys.length === 1) && typeof firstItem[xKey] === "string") {
705
+ if (options?.preferredType) {
706
+ switch (options.preferredType) {
707
+ case "bar":
708
+ return createBarChart(
709
+ data,
710
+ xKey,
711
+ yKeys.map((key) => ({ key })),
712
+ options
713
+ );
714
+ case "line":
715
+ return createLineChart(
716
+ data,
717
+ xKey,
718
+ yKeys.map((key) => ({ key })),
719
+ options
720
+ );
721
+ case "area":
722
+ return createAreaChart(
723
+ data,
724
+ xKey,
725
+ yKeys.map((key) => ({ key })),
726
+ options
727
+ );
728
+ case "pie":
729
+ return createPieChart(data, yKeys[0], xKey, options);
730
+ }
731
+ }
732
+ if (yKeys.length === 1 && typeof firstItem[xKey] === "string") {
703
733
  return createPieChart(data, yKeys[0], xKey, options);
704
734
  }
705
- if (options?.preferredType === "line" || xKey.toLowerCase().includes("date") || xKey.toLowerCase().includes("time") || xKey.toLowerCase().includes("month") || xKey.toLowerCase().includes("year")) {
735
+ if (xKey.toLowerCase().includes("date") || xKey.toLowerCase().includes("time") || xKey.toLowerCase().includes("month") || xKey.toLowerCase().includes("year")) {
706
736
  return createLineChart(
707
737
  data,
708
738
  xKey,
package/dist/index.mjs CHANGED
@@ -5,6 +5,9 @@ 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), []);
8
+ useEffect(() => {
9
+ client.updateConfig(config);
10
+ }, [client, config]);
8
11
  useEffect(() => {
9
12
  return () => {
10
13
  client.removeAllListeners();
@@ -634,10 +637,37 @@ function createSmartChart(data, options) {
634
637
  ) || keys[0];
635
638
  const numericKeys = keys.filter((k) => k !== xKey && typeof firstItem[k] === "number");
636
639
  const yKeys = options?.yKeys || numericKeys;
637
- if ((options?.preferredType === "pie" || yKeys.length === 1) && typeof firstItem[xKey] === "string") {
640
+ if (options?.preferredType) {
641
+ switch (options.preferredType) {
642
+ case "bar":
643
+ return createBarChart(
644
+ data,
645
+ xKey,
646
+ yKeys.map((key) => ({ key })),
647
+ options
648
+ );
649
+ case "line":
650
+ return createLineChart(
651
+ data,
652
+ xKey,
653
+ yKeys.map((key) => ({ key })),
654
+ options
655
+ );
656
+ case "area":
657
+ return createAreaChart(
658
+ data,
659
+ xKey,
660
+ yKeys.map((key) => ({ key })),
661
+ options
662
+ );
663
+ case "pie":
664
+ return createPieChart(data, yKeys[0], xKey, options);
665
+ }
666
+ }
667
+ if (yKeys.length === 1 && typeof firstItem[xKey] === "string") {
638
668
  return createPieChart(data, yKeys[0], xKey, options);
639
669
  }
640
- if (options?.preferredType === "line" || xKey.toLowerCase().includes("date") || xKey.toLowerCase().includes("time") || xKey.toLowerCase().includes("month") || xKey.toLowerCase().includes("year")) {
670
+ if (xKey.toLowerCase().includes("date") || xKey.toLowerCase().includes("time") || xKey.toLowerCase().includes("month") || xKey.toLowerCase().includes("year")) {
641
671
  return createLineChart(
642
672
  data,
643
673
  xKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antipopp/agno-react",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "React hooks for Agno client with frontend tool execution (HITL) support",
5
5
  "author": "antipopp",
6
6
  "license": "MIT",
@@ -34,8 +34,8 @@
34
34
  "README.md"
35
35
  ],
36
36
  "dependencies": {
37
- "@antipopp/agno-client": "0.4.0",
38
- "@antipopp/agno-types": "0.4.0"
37
+ "@antipopp/agno-client": "0.5.0",
38
+ "@antipopp/agno-types": "0.5.0"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "react": "^18.0.0"