@librechat/agents 3.0.1 → 3.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/dist/cjs/common/enum.cjs +0 -1
- package/dist/cjs/common/enum.cjs.map +1 -1
- package/dist/cjs/llm/providers.cjs +0 -2
- package/dist/cjs/llm/providers.cjs.map +1 -1
- package/dist/cjs/main.cjs +2 -0
- package/dist/cjs/main.cjs.map +1 -1
- package/dist/cjs/tools/Calculator.cjs +45 -0
- package/dist/cjs/tools/Calculator.cjs.map +1 -0
- package/dist/esm/common/enum.mjs +0 -1
- package/dist/esm/common/enum.mjs.map +1 -1
- package/dist/esm/llm/providers.mjs +0 -2
- package/dist/esm/llm/providers.mjs.map +1 -1
- package/dist/esm/main.mjs +1 -0
- package/dist/esm/main.mjs.map +1 -1
- package/dist/esm/tools/Calculator.mjs +24 -0
- package/dist/esm/tools/Calculator.mjs.map +1 -0
- package/dist/types/common/enum.d.ts +0 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/tools/Calculator.d.ts +8 -0
- package/dist/types/types/llm.d.ts +1 -6
- package/package.json +6 -4
- package/src/common/enum.ts +0 -1
- package/src/index.ts +1 -0
- package/src/llm/providers.ts +0 -2
- package/src/scripts/abort.ts +34 -15
- package/src/scripts/cli.ts +25 -20
- package/src/scripts/cli2.ts +23 -15
- package/src/scripts/cli3.ts +35 -29
- package/src/scripts/cli4.ts +1 -2
- package/src/scripts/cli5.ts +1 -2
- package/src/scripts/code_exec.ts +1 -2
- package/src/scripts/code_exec_simple.ts +1 -2
- package/src/scripts/content.ts +33 -15
- package/src/scripts/simple.ts +1 -2
- package/src/scripts/stream.ts +33 -15
- package/src/scripts/test-tools-before-handoff.ts +17 -28
- package/src/scripts/tools.ts +4 -6
- package/src/specs/anthropic.simple.test.ts +1 -1
- package/src/specs/azure.simple.test.ts +1 -1
- package/src/specs/openai.simple.test.ts +1 -1
- package/src/specs/openrouter.simple.test.ts +1 -1
- package/src/tools/Calculator.test.ts +278 -0
- package/src/tools/Calculator.ts +25 -0
- package/src/types/llm.ts +0 -6
- package/dist/types/tools/example.d.ts +0 -78
- package/src/proto/CollabGraph.ts +0 -269
- package/src/proto/TaskManager.ts +0 -243
- package/src/proto/collab.ts +0 -200
- package/src/proto/collab_design.ts +0 -184
- package/src/proto/collab_design_v2.ts +0 -224
- package/src/proto/collab_design_v3.ts +0 -255
- package/src/proto/collab_design_v4.ts +0 -220
- package/src/proto/collab_design_v5.ts +0 -251
- package/src/proto/collab_graph.ts +0 -181
- package/src/proto/collab_original.ts +0 -123
- package/src/proto/example.ts +0 -93
- package/src/proto/example_new.ts +0 -68
- package/src/proto/example_old.ts +0 -201
- package/src/proto/example_test.ts +0 -152
- package/src/proto/example_test_anthropic.ts +0 -100
- package/src/proto/log_stream.ts +0 -202
- package/src/proto/main_collab_community_event.ts +0 -133
- package/src/proto/main_collab_design_v2.ts +0 -96
- package/src/proto/main_collab_design_v4.ts +0 -100
- package/src/proto/main_collab_design_v5.ts +0 -135
- package/src/proto/main_collab_global_analysis.ts +0 -122
- package/src/proto/main_collab_hackathon_event.ts +0 -153
- package/src/proto/main_collab_space_mission.ts +0 -153
- package/src/proto/main_philosophy.ts +0 -210
- package/src/proto/original_script.ts +0 -126
- package/src/proto/standard.ts +0 -100
- package/src/proto/stream.ts +0 -56
- package/src/proto/tasks.ts +0 -118
- package/src/proto/tools/global_analysis_tools.ts +0 -86
- package/src/proto/tools/space_mission_tools.ts +0 -60
- package/src/proto/vertexai.ts +0 -54
- package/src/tools/example.ts +0 -129
package/src/tools/example.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { TavilySearchResults } from '@langchain/community/tools/tavily_search';
|
|
2
|
-
import { DynamicStructuredTool , tool } from '@langchain/core/tools';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
import { config } from 'dotenv';
|
|
5
|
-
|
|
6
|
-
config();
|
|
7
|
-
|
|
8
|
-
import fetch from 'node-fetch';
|
|
9
|
-
import { Constants } from '@/common';
|
|
10
|
-
|
|
11
|
-
const fetchImageSchema = z.object({ input: z.string().optional() });
|
|
12
|
-
|
|
13
|
-
export const fetchRandomImageTool = tool(
|
|
14
|
-
async () => {
|
|
15
|
-
try {
|
|
16
|
-
// Lorem Picsum provides random images at any size
|
|
17
|
-
const imageUrl = 'https://picsum.photos/200/300';
|
|
18
|
-
|
|
19
|
-
const imageResponse = await fetch(imageUrl);
|
|
20
|
-
// eslint-disable-next-line no-console
|
|
21
|
-
console.log(imageResponse);
|
|
22
|
-
const arrayBuffer = await imageResponse.arrayBuffer();
|
|
23
|
-
const base64 = Buffer.from(arrayBuffer).toString('base64');
|
|
24
|
-
const content = [{
|
|
25
|
-
type: 'image_url',
|
|
26
|
-
image_url: {
|
|
27
|
-
url: `data:image/jpeg;base64,${base64}`,
|
|
28
|
-
},
|
|
29
|
-
}];
|
|
30
|
-
|
|
31
|
-
const response = [
|
|
32
|
-
{
|
|
33
|
-
type: 'text',
|
|
34
|
-
text: 'Random image from Lorem Picsum, taken at 800x600',
|
|
35
|
-
},
|
|
36
|
-
];
|
|
37
|
-
return [response, { content }];
|
|
38
|
-
} catch (error) {
|
|
39
|
-
return [`Error fetching image: ${(error as Error).message}`, undefined];
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: 'fetchRandomImage',
|
|
44
|
-
description: 'Fetches a random image from Lorem Picsum',
|
|
45
|
-
schema: fetchImageSchema,
|
|
46
|
-
responseFormat: Constants.CONTENT_AND_ARTIFACT,
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
export const fetchRandomImageURL = tool(
|
|
51
|
-
async () => {
|
|
52
|
-
try {
|
|
53
|
-
const imageUrl = 'https://picsum.photos/200/300';
|
|
54
|
-
|
|
55
|
-
const imageResponse = await fetch(imageUrl);
|
|
56
|
-
const content = [{
|
|
57
|
-
type: 'image_url',
|
|
58
|
-
image_url: {
|
|
59
|
-
url: imageResponse.url,
|
|
60
|
-
},
|
|
61
|
-
}];
|
|
62
|
-
|
|
63
|
-
// eslint-disable-next-line no-console
|
|
64
|
-
console.log('URL RESPONSE', imageResponse.url);
|
|
65
|
-
|
|
66
|
-
const response = [
|
|
67
|
-
{
|
|
68
|
-
type: 'text',
|
|
69
|
-
text: 'Random image from Lorem Picsum, taken at 800x600',
|
|
70
|
-
},
|
|
71
|
-
];
|
|
72
|
-
return [response, { content }];
|
|
73
|
-
} catch (error) {
|
|
74
|
-
return [`Error fetching image: ${(error as Error).message}`, undefined];
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
name: 'fetchRandomImage',
|
|
79
|
-
description: 'Fetches a random image from Lorem Picsum',
|
|
80
|
-
schema: fetchImageSchema,
|
|
81
|
-
responseFormat: Constants.CONTENT_AND_ARTIFACT,
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
export const chartTool = new DynamicStructuredTool({
|
|
86
|
-
name: 'generate_bar_chart',
|
|
87
|
-
description:
|
|
88
|
-
'Generates a text-based bar chart from an array of data points and returns it as a string.',
|
|
89
|
-
schema: z.object({
|
|
90
|
-
data: z.array(
|
|
91
|
-
z.object({
|
|
92
|
-
label: z.string(),
|
|
93
|
-
value: z.number(),
|
|
94
|
-
})
|
|
95
|
-
),
|
|
96
|
-
}),
|
|
97
|
-
func: async ({ data }): Promise<string> => {
|
|
98
|
-
const maxValue = Math.max(...data.map(d => d.value));
|
|
99
|
-
const chartHeight = 20;
|
|
100
|
-
const chartWidth = 50;
|
|
101
|
-
|
|
102
|
-
let chart = '';
|
|
103
|
-
|
|
104
|
-
// Generate Y-axis labels and bars
|
|
105
|
-
for (let i = chartHeight; i >= 0; i--) {
|
|
106
|
-
const row = data.map(d => {
|
|
107
|
-
const barHeight = Math.round((d.value / maxValue) * chartHeight);
|
|
108
|
-
return barHeight >= i ? '█' : ' ';
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
const yLabel = i === chartHeight ? maxValue.toString().padStart(4) :
|
|
112
|
-
i === 0 ? '0'.padStart(4) :
|
|
113
|
-
i % 5 === 0 ? Math.round((i / chartHeight) * maxValue).toString().padStart(4) : ' ';
|
|
114
|
-
|
|
115
|
-
chart += `${yLabel} │${row.join(' ')} \n`;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Generate X-axis
|
|
119
|
-
chart += ' ├' + '─'.repeat(chartWidth) + '\n';
|
|
120
|
-
|
|
121
|
-
// Generate X-axis labels
|
|
122
|
-
const xLabels = data.map(d => d.label.padEnd(5).substring(0, 5)).join(' ');
|
|
123
|
-
chart += ` ${xLabels}`;
|
|
124
|
-
|
|
125
|
-
return chart;
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
export const tavilyTool = new TavilySearchResults();
|