@ai.ntellect/core 0.1.8 → 0.1.81

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai.ntellect/core",
3
- "version": "0.1.8",
3
+ "version": "0.1.81",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -14,6 +14,7 @@
14
14
  "dependencies": {
15
15
  "@ai-sdk/openai": "1.0.6",
16
16
  "ai": "^3.0.0",
17
+ "langchain": "^0.3.11",
17
18
  "redis": "^4.7.0",
18
19
  "zod": "^3.24.1"
19
20
  },
package/dist/test.d.ts DELETED
@@ -1,40 +0,0 @@
1
- import { z } from "zod";
2
- export declare const getChainsTVL: {
3
- name: string;
4
- description: string;
5
- parameters: z.ZodObject<{
6
- limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
7
- }, "strip", z.ZodTypeAny, {
8
- limit: number;
9
- }, {
10
- limit?: number | undefined;
11
- }>;
12
- execute: ({ limit }: {
13
- limit: number;
14
- }) => Promise<{
15
- summary: {
16
- totalTVL: number;
17
- numberOfChains: number;
18
- };
19
- topChains: {
20
- name: string;
21
- tvl: number;
22
- tokenSymbol: string | null;
23
- }[];
24
- }>;
25
- };
26
- export declare const getRssNews: {
27
- name: string;
28
- description: string;
29
- parameters: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
30
- execute: () => Promise<{
31
- status: string;
32
- items: {
33
- title: any;
34
- content: string;
35
- link: any;
36
- date: any;
37
- source: any;
38
- }[];
39
- }>;
40
- };
package/dist/test.js DELETED
@@ -1,127 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getRssNews = exports.getChainsTVL = void 0;
7
- const rss_parser_1 = __importDefault(require("rss-parser"));
8
- const zod_1 = require("zod");
9
- const agent_1 = require("./agent");
10
- const orchestrator_1 = require("./llm/orchestrator");
11
- const persistent_1 = require("./memory/persistent");
12
- exports.getChainsTVL = {
13
- name: "get_chains_tvl",
14
- description: "Get current TVL (Total Value Locked) of all chains from DeFiLlama",
15
- parameters: zod_1.z.object({
16
- limit: zod_1.z
17
- .number()
18
- .optional()
19
- .default(10)
20
- .describe("Number of top chains to return (default: 10)"),
21
- }),
22
- execute: async ({ limit }) => {
23
- try {
24
- const response = await fetch("https://api.llama.fi/v2/chains", {
25
- headers: { accept: "*/*" },
26
- });
27
- if (!response.ok) {
28
- throw new Error(`HTTP error! status: ${response.status}`);
29
- }
30
- const chains = (await response.json());
31
- // Sort chains by TVL in descending order and take top N
32
- const topChains = chains
33
- .sort((a, b) => b.tvl - a.tvl)
34
- .slice(0, limit)
35
- .map((chain) => ({
36
- name: chain.name,
37
- tvl: chain.tvl,
38
- tokenSymbol: chain.tokenSymbol,
39
- }));
40
- const totalTVL = chains.reduce((sum, chain) => sum + chain.tvl, 0);
41
- return {
42
- summary: {
43
- totalTVL,
44
- numberOfChains: chains.length,
45
- },
46
- topChains,
47
- };
48
- }
49
- catch (error) {
50
- console.error("Error retrieving chains TVL data:", error);
51
- throw new Error(`Failed to fetch chains TVL data: ${error.message}`);
52
- }
53
- },
54
- };
55
- const RSS_FEEDS = ["https://www.investing.com/rss/news_301.rss"];
56
- const parser = new rss_parser_1.default();
57
- function stripHtmlTags(content) {
58
- if (!content)
59
- return "";
60
- return content
61
- .replace(/<[^>]*>/g, "")
62
- .replace(/\n/g, "")
63
- .replace(" ", "");
64
- }
65
- exports.getRssNews = {
66
- name: "get-news-rss",
67
- description: "Get latest news about on website",
68
- parameters: zod_1.z.object({}),
69
- execute: async () => {
70
- const itemsPerSource = 5;
71
- try {
72
- const feedPromises = RSS_FEEDS.map((url) => parser.parseURL(url));
73
- const results = await Promise.allSettled(feedPromises);
74
- const successfulFeeds = results
75
- .filter((result) => {
76
- return (result.status === "fulfilled" && result.value?.items?.length > 0);
77
- })
78
- .map((result) => result.value);
79
- const allItems = successfulFeeds
80
- .flatMap((feed) => feed.items.slice(0, itemsPerSource))
81
- .sort((a, b) => {
82
- const dateA = a.pubDate ? new Date(a.pubDate).getTime() : 0;
83
- const dateB = b.pubDate ? new Date(b.pubDate).getTime() : 0;
84
- return dateB - dateA;
85
- })
86
- .slice(0, 5)
87
- .map((item) => ({
88
- title: item.title,
89
- content: stripHtmlTags(item.content),
90
- link: item.link,
91
- date: item.pubDate,
92
- source: item.creator || new URL(item.link).hostname,
93
- }));
94
- const result = {
95
- status: "success",
96
- items: allItems,
97
- };
98
- return result;
99
- }
100
- catch (error) {
101
- throw error;
102
- }
103
- },
104
- };
105
- (async () => {
106
- const memory = new persistent_1.PersistentMemory({
107
- host: "http://localhost:7700",
108
- apiKey: "aSampleMasterKey",
109
- });
110
- const orchestrator = new orchestrator_1.Orchestrator([], memory);
111
- const agent = new agent_1.Agent({
112
- user: {
113
- id: "1",
114
- },
115
- orchestrator,
116
- persistentMemory: memory,
117
- stream: false,
118
- maxEvaluatorIteration: 1,
119
- });
120
- const prompt = "fais moi une analyse ethereum";
121
- const context = prompt;
122
- const result = await agent.process(prompt, context, {
123
- onMessage: (message) => {
124
- console.log({ message });
125
- },
126
- });
127
- })();
package/test.ts DELETED
@@ -1,148 +0,0 @@
1
- import Parser from "rss-parser";
2
- import { z } from "zod";
3
- import { Agent } from "./agent";
4
- import { Orchestrator } from "./llm/orchestrator";
5
- import { PersistentMemory } from "./memory/persistent";
6
-
7
- interface ChainTVL {
8
- name: string;
9
- tvl: number;
10
- tokenSymbol: string | null;
11
- chainId: number | string | null;
12
- gecko_id: string | null;
13
- cmcId: string | null;
14
- }
15
-
16
- export const getChainsTVL = {
17
- name: "get_chains_tvl",
18
- description:
19
- "Get current TVL (Total Value Locked) of all chains from DeFiLlama",
20
- parameters: z.object({
21
- limit: z
22
- .number()
23
- .optional()
24
- .default(10)
25
- .describe("Number of top chains to return (default: 10)"),
26
- }),
27
- execute: async ({ limit }: { limit: number }) => {
28
- try {
29
- const response = await fetch("https://api.llama.fi/v2/chains", {
30
- headers: { accept: "*/*" },
31
- });
32
-
33
- if (!response.ok) {
34
- throw new Error(`HTTP error! status: ${response.status}`);
35
- }
36
-
37
- const chains = (await response.json()) as ChainTVL[];
38
-
39
- // Sort chains by TVL in descending order and take top N
40
- const topChains = chains
41
- .sort((a, b) => b.tvl - a.tvl)
42
- .slice(0, limit)
43
- .map((chain) => ({
44
- name: chain.name,
45
- tvl: chain.tvl,
46
- tokenSymbol: chain.tokenSymbol,
47
- }));
48
-
49
- const totalTVL = chains.reduce((sum, chain) => sum + chain.tvl, 0);
50
-
51
- return {
52
- summary: {
53
- totalTVL,
54
- numberOfChains: chains.length,
55
- },
56
- topChains,
57
- };
58
- } catch (error) {
59
- console.error("Error retrieving chains TVL data:", error);
60
- throw new Error(
61
- `Failed to fetch chains TVL data: ${(error as Error).message}`
62
- );
63
- }
64
- },
65
- };
66
-
67
- const RSS_FEEDS = ["https://www.investing.com/rss/news_301.rss"];
68
-
69
- const parser = new Parser();
70
-
71
- function stripHtmlTags(content: string): string {
72
- if (!content) return "";
73
- return content
74
- .replace(/<[^>]*>/g, "")
75
- .replace(/\n/g, "")
76
- .replace(" ", "");
77
- }
78
-
79
- export const getRssNews = {
80
- name: "get-news-rss",
81
- description: "Get latest news about on website",
82
- parameters: z.object({}),
83
- execute: async () => {
84
- const itemsPerSource = 5;
85
-
86
- try {
87
- const feedPromises = RSS_FEEDS.map((url) => parser.parseURL(url));
88
- const results = await Promise.allSettled(feedPromises);
89
- const successfulFeeds = results
90
- .filter(
91
- (result): result is PromiseFulfilledResult<Parser.Output<any>> => {
92
- return (
93
- result.status === "fulfilled" && result.value?.items?.length > 0
94
- );
95
- }
96
- )
97
- .map((result) => result.value);
98
- const allItems = successfulFeeds
99
- .flatMap((feed) => feed.items.slice(0, itemsPerSource))
100
- .sort((a, b) => {
101
- const dateA = a.pubDate ? new Date(a.pubDate).getTime() : 0;
102
- const dateB = b.pubDate ? new Date(b.pubDate).getTime() : 0;
103
- return dateB - dateA;
104
- })
105
- .slice(0, 5)
106
- .map((item) => ({
107
- title: item.title,
108
- content: stripHtmlTags(item.content),
109
- link: item.link,
110
- date: item.pubDate,
111
- source: item.creator || new URL(item.link).hostname,
112
- }));
113
-
114
- const result = {
115
- status: "success",
116
- items: allItems,
117
- };
118
- return result;
119
- } catch (error: any) {
120
- throw error;
121
- }
122
- },
123
- };
124
-
125
- (async () => {
126
- const memory = new PersistentMemory({
127
- host: "http://localhost:7700",
128
- apiKey: "aSampleMasterKey",
129
- });
130
- const orchestrator = new Orchestrator([], memory);
131
- const agent = new Agent({
132
- user: {
133
- id: "1",
134
- },
135
- orchestrator,
136
- persistentMemory: memory,
137
- stream: false,
138
- maxEvaluatorIteration: 1,
139
- });
140
-
141
- const prompt = "fais moi une analyse ethereum";
142
- const context = prompt;
143
- const result = await agent.process(prompt, context, {
144
- onMessage: (message) => {
145
- console.log({ message });
146
- },
147
- });
148
- })();