@ai.ntellect/core 0.6.0 → 0.6.2

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.
Files changed (37) hide show
  1. package/create-llm-to-select-multiple-graph copy.ts +243 -0
  2. package/create-llm-to-select-multiple-graph.ts +148 -0
  3. package/dist/create-llm-to-select-multiple-graph copy.js +201 -0
  4. package/dist/create-llm-to-select-multiple-graph.js +142 -0
  5. package/dist/graph/controller.js +6 -6
  6. package/dist/graph/engine.js +198 -135
  7. package/dist/index copy.js +76 -0
  8. package/dist/utils/setup-graphs.js +28 -0
  9. package/dist/utils/stringifiy-zod-schema.js +41 -0
  10. package/graph/controller.ts +11 -9
  11. package/graph/engine.ts +244 -166
  12. package/index copy.ts +81 -0
  13. package/index.ts +1 -1
  14. package/package.json +1 -1
  15. package/test/graph/engine.test.ts +27 -44
  16. package/tsconfig.json +1 -1
  17. package/types/index.ts +11 -3
  18. package/utils/setup-graphs.ts +45 -0
  19. package/utils/stringifiy-zod-schema.ts +45 -0
  20. package/dist/test/graph/controller.test.js +0 -170
  21. package/dist/test/graph/engine.test.js +0 -465
  22. package/dist/test/memory/adapters/meilisearch.test.js +0 -250
  23. package/dist/test/memory/adapters/redis.test.js +0 -143
  24. package/dist/test/memory/base.test.js +0 -209
  25. package/dist/test/services/agenda.test.js +0 -230
  26. package/dist/test/services/queue.test.js +0 -258
  27. package/dist/utils/schema-generator.js +0 -46
  28. package/dist/utils/state-manager.js +0 -20
  29. package/utils/generate-object.js +0 -111
  30. package/utils/header-builder.js +0 -34
  31. package/utils/inject-actions.js +0 -16
  32. package/utils/queue-item-transformer.js +0 -24
  33. package/utils/sanitize-results.js +0 -60
  34. package/utils/schema-generator.js +0 -46
  35. package/utils/schema-generator.ts +0 -73
  36. package/utils/state-manager.js +0 -20
  37. package/utils/state-manager.ts +0 -30
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRouterAddress = exports.ROUTER_ADDRESSES = exports.getNetworkProvider = exports.networkConfigs = void 0;
4
+ exports.networkConfigs = {
5
+ ethereum: {
6
+ name: "Ethereum Mainnet",
7
+ id: 1,
8
+ rpc: "https://eth.llamarpc.com",
9
+ explorerUrl: "https://etherscan.io",
10
+ nativeToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
11
+ },
12
+ polygon: {
13
+ name: "Polygon Mainnet",
14
+ id: 137,
15
+ rpc: "https://polygon.llamarpc.com",
16
+ explorerUrl: "https://polygonscan.com",
17
+ nativeToken: "0x0000000000000000000000000000000000001010",
18
+ },
19
+ arbitrum: {
20
+ name: "Arbitrum Mainnet",
21
+ id: 42161,
22
+ rpc: "https://arbitrum.llamarpc.com",
23
+ explorerUrl: "https://arbiscan.io",
24
+ nativeToken: "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
25
+ },
26
+ base: {
27
+ name: "Base Mainnet",
28
+ id: 8453,
29
+ rpc: "https://base.llamarpc.com",
30
+ explorerUrl: "https://basescan.org",
31
+ nativeToken: "0x4200000000000000000000000000000000000006",
32
+ },
33
+ solana: {
34
+ name: "Solana Mainnet",
35
+ rpc: "https://api.mainnet-beta.solana.com",
36
+ explorerUrl: "https://solscan.io",
37
+ nativeToken: "So11111111111111111111111111111111111111112",
38
+ },
39
+ sepolia: {
40
+ name: "Sepolia Testnet",
41
+ id: 11155111,
42
+ rpc: "https://rpc.sepolia.ethpandaops.io",
43
+ explorerUrl: "https://sepolia.etherscan.io",
44
+ nativeToken: "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14",
45
+ },
46
+ baseSepolia: {
47
+ name: "Base Sepolia Testnet",
48
+ id: 84532,
49
+ rpc: "https://base-sepolia-rpc.publicnode.com",
50
+ explorerUrl: "https://sepolia.basescan.org",
51
+ nativeToken: "0x4200000000000000000000000000000000000006",
52
+ },
53
+ };
54
+ const getNetworkProvider = (networkName) => {
55
+ const config = exports.networkConfigs[networkName.toLowerCase()];
56
+ if (!config) {
57
+ throw new Error(`Network ${networkName} not supported`);
58
+ }
59
+ return { config };
60
+ };
61
+ exports.getNetworkProvider = getNetworkProvider;
62
+ exports.ROUTER_ADDRESSES = {
63
+ ethereum: "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D",
64
+ sepolia: "0xeE567Fe1712Faf6149d80dA1E6934E354124CfE3",
65
+ arbitrum: "0x4752ba5dbc23f44d87826276bf6fd6b1c372ad24",
66
+ polygon: "0xedf6066a2b290C185783862C7F4776A2C8077AD1",
67
+ base: "0x4752ba5dbc23f44d87826276bf6fd6b1c372ad24",
68
+ optimism: "0x4A7b5Da61326A6379179b40d00F57E5bbDC962c2",
69
+ blast: "0xBB66Eb1c5e875933D44DAe661dbD80e5D9B03035",
70
+ zora: "0xa00F34A632630EFd15223B1968358bA4845bEEC7",
71
+ worldchain: "0x541aB7c31A119441eF3575F6973277DE0eF460bd",
72
+ };
73
+ const getRouterAddress = (networkName) => {
74
+ return exports.ROUTER_ADDRESSES[networkName.toLowerCase()];
75
+ };
76
+ exports.getRouterAddress = getRouterAddress;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setupGraphsWithActions = setupGraphsWithActions;
4
+ const engine_1 = require("../graph/engine");
5
+ function setupGraphsWithActions(actions, baseStateMapping, graphMaps) {
6
+ const initialStates = actions.map((action) => {
7
+ const parametersObject = Object.fromEntries(action.parameters.map((param) => [
8
+ param.name,
9
+ param.value !== undefined ? param.value : null,
10
+ ]) // Handle optional values
11
+ );
12
+ const baseState = baseStateMapping[action.name] || {};
13
+ return Object.assign(Object.assign({}, baseState), parametersObject);
14
+ });
15
+ const selectedGraphs = actions
16
+ .map((action) => graphMaps.find((graph) => graph.name === action.name))
17
+ .filter((graph) => graph !== undefined);
18
+ if (selectedGraphs.length !== actions.length) {
19
+ throw new Error("Graph not found");
20
+ }
21
+ const startNodes = selectedGraphs.map((graph) => graph.entryNode);
22
+ const graphEngines = selectedGraphs.map((graph) => new engine_1.GraphEngine(graph));
23
+ return {
24
+ initialStates: initialStates,
25
+ graphs: graphEngines,
26
+ startNodes,
27
+ };
28
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stringifyZodSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const stringifyZodSchema = (nodes) => {
6
+ return nodes
7
+ .map((node) => {
8
+ const schemaStr = node.schema
9
+ ? getSchemaString(node.schema)
10
+ : "No parameters";
11
+ return `Workflow: ${node.name}\nDescription: ${node.description}\nParameters: ${schemaStr}`;
12
+ })
13
+ .join("\n\n");
14
+ };
15
+ exports.stringifyZodSchema = stringifyZodSchema;
16
+ const getSchemaString = (schema) => {
17
+ if (schema instanceof zod_1.z.ZodObject) {
18
+ const entries = Object.entries(schema.shape);
19
+ const fields = entries.map(([key, value]) => {
20
+ const description = value._def.description;
21
+ const schemaStr = getSchemaString(value);
22
+ return description
23
+ ? `${key}: ${schemaStr} // ${description}`
24
+ : `${key}: ${schemaStr}`;
25
+ });
26
+ return `z.object({${fields.join(", ")}})`;
27
+ }
28
+ if (schema instanceof zod_1.z.ZodArray) {
29
+ return `z.array(${getSchemaString(schema.element)})`;
30
+ }
31
+ if (schema instanceof zod_1.z.ZodString) {
32
+ return "z.string()";
33
+ }
34
+ if (schema instanceof zod_1.z.ZodNumber) {
35
+ return "z.number()";
36
+ }
37
+ if (schema instanceof zod_1.z.ZodBoolean) {
38
+ return "z.boolean()";
39
+ }
40
+ return `z.unknown()`;
41
+ };
@@ -34,16 +34,18 @@ export class GraphController<T> {
34
34
  autoDetectCycles: true,
35
35
  });
36
36
 
37
+ console.log("graph", graph);
38
+
37
39
  // Construct the initial state from action parameters.
38
- const initialState = {
39
- context: action.parameters.reduce(
40
- (acc: Record<string, any>, param: { name: string; value: any }) => {
41
- acc[param.name] = param.value;
42
- return acc;
43
- },
44
- {}
45
- ),
46
- };
40
+ const initialState = action.parameters.reduce(
41
+ (acc: Record<string, any>, param: { name: string; value: any }) => {
42
+ acc[param.name] = param.value;
43
+ return acc;
44
+ },
45
+ {}
46
+ );
47
+
48
+ console.log("initialState", initialState);
47
49
 
48
50
  // Execute the graph starting from the defined entry node.
49
51
  await graph.execute(initialState, graphDefinition.entryNode);