@librechat/agents 2.4.35 → 2.4.37
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/llm/anthropic/utils/message_inputs.cjs +5 -1
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -1
- package/dist/cjs/stream.cjs +2 -2
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/tools/search/firecrawl.cjs +1 -1
- package/dist/cjs/tools/search/firecrawl.cjs.map +1 -1
- package/dist/cjs/tools/search/tool.cjs +2 -1
- package/dist/cjs/tools/search/tool.cjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs +5 -1
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -1
- package/dist/esm/stream.mjs +2 -2
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/tools/search/firecrawl.mjs +1 -1
- package/dist/esm/tools/search/firecrawl.mjs.map +1 -1
- package/dist/esm/tools/search/tool.mjs +2 -1
- package/dist/esm/tools/search/tool.mjs.map +1 -1
- package/dist/types/tools/search/types.d.ts +1 -0
- package/package.json +10 -10
- package/src/llm/anthropic/utils/message_inputs.ts +5 -1
- package/src/scripts/tools.ts +42 -13
- package/src/stream.ts +2 -2
- package/src/tools/search/firecrawl.ts +1 -1
- package/src/tools/search/tool.ts +2 -0
- package/src/tools/search/types.ts +1 -0
- package/src/utils/llmConfig.ts +3 -1
package/src/scripts/tools.ts
CHANGED
|
@@ -8,7 +8,6 @@ import type * as t from '@/types';
|
|
|
8
8
|
import { ChatModelStreamHandler, createContentAggregator } from '@/stream';
|
|
9
9
|
import { ToolEndHandler, ModelEndHandler } from '@/events';
|
|
10
10
|
|
|
11
|
-
|
|
12
11
|
import { getArgs } from '@/scripts/args';
|
|
13
12
|
import { Run } from '@/run';
|
|
14
13
|
import { GraphEvents, Callback } from '@/common';
|
|
@@ -23,38 +22,67 @@ async function testStandardStreaming(): Promise<void> {
|
|
|
23
22
|
[GraphEvents.CHAT_MODEL_END]: new ModelEndHandler(),
|
|
24
23
|
[GraphEvents.CHAT_MODEL_STREAM]: new ChatModelStreamHandler(),
|
|
25
24
|
[GraphEvents.ON_RUN_STEP_COMPLETED]: {
|
|
26
|
-
handle: (
|
|
25
|
+
handle: (
|
|
26
|
+
event: GraphEvents.ON_RUN_STEP_COMPLETED,
|
|
27
|
+
data: t.StreamEventData
|
|
28
|
+
): void => {
|
|
27
29
|
console.log('====== ON_RUN_STEP_COMPLETED ======');
|
|
28
30
|
// console.dir(data, { depth: null });
|
|
29
|
-
aggregateContent({
|
|
30
|
-
|
|
31
|
+
aggregateContent({
|
|
32
|
+
event,
|
|
33
|
+
data: data as unknown as { result: t.ToolEndEvent },
|
|
34
|
+
});
|
|
35
|
+
},
|
|
31
36
|
},
|
|
32
37
|
[GraphEvents.ON_RUN_STEP]: {
|
|
33
|
-
handle: (
|
|
38
|
+
handle: (
|
|
39
|
+
event: GraphEvents.ON_RUN_STEP,
|
|
40
|
+
data: t.StreamEventData
|
|
41
|
+
): void => {
|
|
34
42
|
console.log('====== ON_RUN_STEP ======');
|
|
35
43
|
console.dir(data, { depth: null });
|
|
36
44
|
aggregateContent({ event, data: data as t.RunStep });
|
|
37
|
-
}
|
|
45
|
+
},
|
|
38
46
|
},
|
|
39
47
|
[GraphEvents.ON_RUN_STEP_DELTA]: {
|
|
40
|
-
handle: (
|
|
48
|
+
handle: (
|
|
49
|
+
event: GraphEvents.ON_RUN_STEP_DELTA,
|
|
50
|
+
data: t.StreamEventData
|
|
51
|
+
): void => {
|
|
41
52
|
console.log('====== ON_RUN_STEP_DELTA ======');
|
|
42
53
|
console.dir(data, { depth: null });
|
|
43
54
|
aggregateContent({ event, data: data as t.RunStepDeltaEvent });
|
|
44
|
-
}
|
|
55
|
+
},
|
|
45
56
|
},
|
|
46
57
|
[GraphEvents.ON_MESSAGE_DELTA]: {
|
|
47
|
-
handle: (
|
|
58
|
+
handle: (
|
|
59
|
+
event: GraphEvents.ON_MESSAGE_DELTA,
|
|
60
|
+
data: t.StreamEventData
|
|
61
|
+
): void => {
|
|
48
62
|
console.log('====== ON_MESSAGE_DELTA ======');
|
|
49
63
|
console.dir(data, { depth: null });
|
|
50
64
|
aggregateContent({ event, data: data as t.MessageDeltaEvent });
|
|
51
|
-
}
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
[GraphEvents.ON_REASONING_DELTA]: {
|
|
68
|
+
handle: (
|
|
69
|
+
event: GraphEvents.ON_REASONING_DELTA,
|
|
70
|
+
data: t.StreamEventData
|
|
71
|
+
) => {
|
|
72
|
+
console.log('====== ON_REASONING_DELTA ======');
|
|
73
|
+
console.dir(data, { depth: null });
|
|
74
|
+
aggregateContent({ event, data: data as t.ReasoningDeltaEvent });
|
|
75
|
+
},
|
|
52
76
|
},
|
|
53
77
|
[GraphEvents.TOOL_START]: {
|
|
54
|
-
handle: (
|
|
78
|
+
handle: (
|
|
79
|
+
_event: string,
|
|
80
|
+
data: t.StreamEventData,
|
|
81
|
+
metadata?: Record<string, unknown>
|
|
82
|
+
): void => {
|
|
55
83
|
console.log('====== TOOL_START ======');
|
|
56
84
|
// console.dir(data, { depth: null });
|
|
57
|
-
}
|
|
85
|
+
},
|
|
58
86
|
},
|
|
59
87
|
};
|
|
60
88
|
|
|
@@ -66,7 +94,8 @@ async function testStandardStreaming(): Promise<void> {
|
|
|
66
94
|
type: 'standard',
|
|
67
95
|
llmConfig,
|
|
68
96
|
tools: [new TavilySearchResults()],
|
|
69
|
-
instructions:
|
|
97
|
+
instructions:
|
|
98
|
+
'You are a friendly AI assistant. Always address the user by their name.',
|
|
70
99
|
additional_instructions: `The user's name is ${userName} and they are located in ${location}.`,
|
|
71
100
|
},
|
|
72
101
|
returnContent: true,
|
package/src/stream.ts
CHANGED
|
@@ -282,8 +282,8 @@ hasToolCallChunks: ${hasToolCallChunks}
|
|
|
282
282
|
} else if (
|
|
283
283
|
graph.tokenTypeSwitch === 'reasoning' &&
|
|
284
284
|
graph.currentTokenType !== ContentTypes.TEXT &&
|
|
285
|
-
chunk.content != null &&
|
|
286
|
-
|
|
285
|
+
((chunk.content != null && chunk.content !== '') ||
|
|
286
|
+
(chunk.tool_calls?.length ?? 0) > 0)
|
|
287
287
|
) {
|
|
288
288
|
graph.currentTokenType = ContentTypes.TEXT;
|
|
289
289
|
graph.tokenTypeSwitch = 'content';
|
|
@@ -24,7 +24,7 @@ export class FirecrawlScraper {
|
|
|
24
24
|
this.apiUrl = `${baseUrl.replace(/\/+$/, '')}/v1/scrape`;
|
|
25
25
|
|
|
26
26
|
this.defaultFormats = config.formats ?? ['markdown', 'html'];
|
|
27
|
-
this.timeout = config.timeout ??
|
|
27
|
+
this.timeout = config.timeout ?? 7500;
|
|
28
28
|
|
|
29
29
|
this.logger = config.logger || createDefaultLogger();
|
|
30
30
|
|
package/src/tools/search/tool.ts
CHANGED
|
@@ -347,6 +347,7 @@ export const createSearchTool = (
|
|
|
347
347
|
firecrawlApiKey,
|
|
348
348
|
firecrawlApiUrl,
|
|
349
349
|
firecrawlFormats = ['markdown', 'html'],
|
|
350
|
+
scraperTimeout,
|
|
350
351
|
jinaApiKey,
|
|
351
352
|
cohereApiKey,
|
|
352
353
|
onSearchResults: _onSearchResults,
|
|
@@ -386,6 +387,7 @@ export const createSearchTool = (
|
|
|
386
387
|
const firecrawlScraper = createFirecrawlScraper({
|
|
387
388
|
apiKey: firecrawlApiKey ?? process.env.FIRECRAWL_API_KEY,
|
|
388
389
|
apiUrl: firecrawlApiUrl,
|
|
390
|
+
timeout: scraperTimeout,
|
|
389
391
|
formats: firecrawlFormats,
|
|
390
392
|
});
|
|
391
393
|
|
package/src/utils/llmConfig.ts
CHANGED
|
@@ -107,7 +107,9 @@ export const llmConfigs: Record<string, t.LLMConfig | undefined> = {
|
|
|
107
107
|
[Providers.BEDROCK]: {
|
|
108
108
|
provider: Providers.BEDROCK,
|
|
109
109
|
// model: 'anthropic.claude-3-sonnet-20240229-v1:0',
|
|
110
|
-
model: 'us.anthropic.claude-3-5-sonnet-20241022-v2:0',
|
|
110
|
+
// model: 'us.anthropic.claude-3-5-sonnet-20241022-v2:0',
|
|
111
|
+
model: 'us.anthropic.claude-sonnet-4-20250514-v1:0',
|
|
112
|
+
// additionalModelRequestFields: { thinking: { type: 'enabled', budget_tokens: 2000 } },
|
|
111
113
|
region: process.env.BEDROCK_AWS_REGION,
|
|
112
114
|
credentials: {
|
|
113
115
|
accessKeyId: process.env.BEDROCK_AWS_ACCESS_KEY_ID!,
|