illuma-agents 1.0.9 → 1.0.10
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/events.cjs +11 -0
- package/dist/cjs/events.cjs.map +1 -1
- package/dist/cjs/graphs/Graph.cjs +2 -1
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/instrumentation.cjs +3 -1
- package/dist/cjs/instrumentation.cjs.map +1 -1
- package/dist/cjs/llm/openai/index.cjs +102 -0
- package/dist/cjs/llm/openai/index.cjs.map +1 -1
- package/dist/cjs/llm/openai/utils/index.cjs +87 -1
- package/dist/cjs/llm/openai/utils/index.cjs.map +1 -1
- package/dist/cjs/llm/openrouter/index.cjs +175 -1
- package/dist/cjs/llm/openrouter/index.cjs.map +1 -1
- package/dist/cjs/run.cjs +8 -0
- package/dist/cjs/run.cjs.map +1 -1
- package/dist/cjs/stream.cjs +20 -0
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +10 -0
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/search/schema.cjs +9 -7
- package/dist/cjs/tools/search/schema.cjs.map +1 -1
- package/dist/cjs/tools/search/tool.cjs +21 -1
- package/dist/cjs/tools/search/tool.cjs.map +1 -1
- package/dist/esm/events.mjs +11 -0
- package/dist/esm/events.mjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +2 -1
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/instrumentation.mjs +3 -1
- package/dist/esm/instrumentation.mjs.map +1 -1
- package/dist/esm/llm/openai/index.mjs +103 -1
- package/dist/esm/llm/openai/index.mjs.map +1 -1
- package/dist/esm/llm/openai/utils/index.mjs +88 -2
- package/dist/esm/llm/openai/utils/index.mjs.map +1 -1
- package/dist/esm/llm/openrouter/index.mjs +175 -1
- package/dist/esm/llm/openrouter/index.mjs.map +1 -1
- package/dist/esm/run.mjs +8 -0
- package/dist/esm/run.mjs.map +1 -1
- package/dist/esm/stream.mjs +20 -0
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +10 -0
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/search/schema.mjs +9 -7
- package/dist/esm/tools/search/schema.mjs.map +1 -1
- package/dist/esm/tools/search/tool.mjs +21 -1
- package/dist/esm/tools/search/tool.mjs.map +1 -1
- package/dist/types/llm/openai/index.d.ts +1 -0
- package/dist/types/llm/openai/utils/index.d.ts +10 -1
- package/dist/types/llm/openrouter/index.d.ts +4 -1
- package/package.json +2 -2
- package/src/events.ts +11 -0
- package/src/graphs/Graph.ts +2 -1
- package/src/instrumentation.ts +4 -1
- package/src/llm/google/llm.spec.ts +3 -1
- package/src/llm/openai/index.ts +126 -0
- package/src/llm/openai/utils/index.ts +116 -1
- package/src/llm/openrouter/index.ts +222 -1
- package/src/run.ts +9 -0
- package/src/scripts/test-tools-before-handoff.ts +1 -5
- package/src/scripts/tools.ts +1 -4
- package/src/stream.ts +26 -0
- package/src/tools/ToolNode.ts +12 -0
- package/src/tools/search/direct-url.test.ts +530 -530
- package/src/tools/search/schema.ts +9 -7
- package/src/tools/search/tool.ts +23 -1
- package/src/utils/llmConfig.ts +8 -2
- package/src/scripts/image.ts +0 -178
|
@@ -9,10 +9,17 @@ export enum DATE_RANGE {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export const DEFAULT_QUERY_DESCRIPTION = `
|
|
12
|
-
|
|
12
|
+
Search query OR a URL for direct content extraction.
|
|
13
|
+
|
|
14
|
+
**IMPORTANT - URL REQUESTS:**
|
|
15
|
+
If the user provides a URL to read, summarize, or analyze, you MUST include the complete URL in this field.
|
|
16
|
+
- User says: "Summarize https://example.com/article" → query: "https://example.com/article"
|
|
17
|
+
- User says: "What does this page say? https://news.site/story" → query: "https://news.site/story"
|
|
18
|
+
DO NOT convert URLs into search keywords. Pass the URL directly.
|
|
19
|
+
|
|
20
|
+
**SEARCH MODE GUIDELINES:**
|
|
13
21
|
- Start broad, then narrow: Begin with key concepts, then refine with specifics
|
|
14
22
|
- Think like sources: Use terminology experts would use in the field
|
|
15
|
-
- Consider perspective: Frame queries from different viewpoints for better results
|
|
16
23
|
- Quality over quantity: A precise 3-4 word query often beats lengthy sentences
|
|
17
24
|
|
|
18
25
|
TECHNIQUES (combine for power searches):
|
|
@@ -21,11 +28,6 @@ TECHNIQUES (combine for power searches):
|
|
|
21
28
|
- SITE-SPECIFIC: Restrict to websites (site:edu research)
|
|
22
29
|
- FILETYPE: Find specific documents (filetype:pdf study)
|
|
23
30
|
- OR OPERATOR: Find alternatives (electric OR hybrid cars)
|
|
24
|
-
- DATE RANGE: Recent information (data after:2020)
|
|
25
|
-
- WILDCARDS: Use * for unknown terms (how to * bread)
|
|
26
|
-
- SPECIFIC QUESTIONS: Use who/what/when/where/why/how
|
|
27
|
-
- DOMAIN TERMS: Include technical terminology for specialized topics
|
|
28
|
-
- CONCISE TERMS: Prioritize keywords over sentences
|
|
29
31
|
`.trim();
|
|
30
32
|
|
|
31
33
|
export const DEFAULT_COUNTRY_DESCRIPTION =
|
package/src/tools/search/tool.ts
CHANGED
|
@@ -424,6 +424,15 @@ function createTool({
|
|
|
424
424
|
async (params, runnableConfig) => {
|
|
425
425
|
const { query, date, country: _c, images, videos, news } = params;
|
|
426
426
|
const country = typeof _c === 'string' && _c ? _c : undefined;
|
|
427
|
+
|
|
428
|
+
// Log the incoming query for debugging URL detection
|
|
429
|
+
const toolLogger = createDefaultLogger();
|
|
430
|
+
toolLogger.debug(`[web_search] Received query: "${query}"`);
|
|
431
|
+
const detectedUrls = extractUrlsFromQuery(query);
|
|
432
|
+
if (detectedUrls.length > 0) {
|
|
433
|
+
toolLogger.debug(`[web_search] Detected URLs in query: ${detectedUrls.join(', ')}`);
|
|
434
|
+
}
|
|
435
|
+
|
|
427
436
|
const searchResult = await search({
|
|
428
437
|
query,
|
|
429
438
|
date,
|
|
@@ -443,7 +452,20 @@ function createTool({
|
|
|
443
452
|
},
|
|
444
453
|
{
|
|
445
454
|
name: Constants.WEB_SEARCH,
|
|
446
|
-
description: `Real-time search. Results have required citation anchors.
|
|
455
|
+
description: `Real-time web search and direct URL content extraction. Results have required citation anchors.
|
|
456
|
+
|
|
457
|
+
**CAPABILITIES:**
|
|
458
|
+
- Search: Query the web for information on any topic
|
|
459
|
+
- Direct URL: Fetch and extract content from a specific URL for summarization or analysis
|
|
460
|
+
|
|
461
|
+
**CRITICAL - URL HANDLING:**
|
|
462
|
+
When user provides a URL (e.g., "summarize https://example.com/article"), you MUST include the FULL URL in the query parameter.
|
|
463
|
+
- CORRECT: query = "https://example.com/article" or "summarize https://example.com/article"
|
|
464
|
+
- WRONG: query = "example article summary" (do NOT convert URLs to search terms)
|
|
465
|
+
|
|
466
|
+
**USAGE:**
|
|
467
|
+
- For search: Use concise search terms as query
|
|
468
|
+
- For URL extraction: Pass the complete URL in the query field
|
|
447
469
|
|
|
448
470
|
Note: Use ONCE per reply unless instructed otherwise.
|
|
449
471
|
|
package/src/utils/llmConfig.ts
CHANGED
|
@@ -56,8 +56,8 @@ export const llmConfigs: Record<string, t.LLMConfig | undefined> = {
|
|
|
56
56
|
provider: Providers.OPENROUTER,
|
|
57
57
|
streaming: true,
|
|
58
58
|
streamUsage: true,
|
|
59
|
-
model: '
|
|
60
|
-
|
|
59
|
+
model: 'anthropic/claude-sonnet-4',
|
|
60
|
+
apiKey: process.env.OPENROUTER_API_KEY,
|
|
61
61
|
configuration: {
|
|
62
62
|
baseURL: process.env.OPENROUTER_BASE_URL,
|
|
63
63
|
defaultHeaders: {
|
|
@@ -66,6 +66,12 @@ export const llmConfigs: Record<string, t.LLMConfig | undefined> = {
|
|
|
66
66
|
},
|
|
67
67
|
},
|
|
68
68
|
include_reasoning: true,
|
|
69
|
+
modelKwargs: {
|
|
70
|
+
reasoning: {
|
|
71
|
+
max_tokens: 8000,
|
|
72
|
+
},
|
|
73
|
+
max_tokens: 10000,
|
|
74
|
+
},
|
|
69
75
|
} as or.ChatOpenRouterCallOptions & t.LLMConfig,
|
|
70
76
|
[Providers.AZURE]: {
|
|
71
77
|
provider: Providers.AZURE,
|
package/src/scripts/image.ts
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
// src/scripts/cli.ts
|
|
2
|
-
import { config } from 'dotenv';
|
|
3
|
-
config();
|
|
4
|
-
import { HumanMessage, AIMessage, BaseMessage } from '@langchain/core/messages';
|
|
5
|
-
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
6
|
-
import type * as t from '@/types';
|
|
7
|
-
import { ChatModelStreamHandler, createContentAggregator } from '@/stream';
|
|
8
|
-
import {
|
|
9
|
-
ToolEndHandler,
|
|
10
|
-
ModelEndHandler,
|
|
11
|
-
createMetadataAggregator,
|
|
12
|
-
} from '@/events';
|
|
13
|
-
import { fetchRandomImageTool, fetchRandomImageURL } from '@/tools/example';
|
|
14
|
-
import { getLLMConfig } from '@/utils/llmConfig';
|
|
15
|
-
import { getArgs } from '@/scripts/args';
|
|
16
|
-
import { GraphEvents } from '@/common';
|
|
17
|
-
import { Run } from '@/run';
|
|
18
|
-
|
|
19
|
-
const conversationHistory: BaseMessage[] = [];
|
|
20
|
-
|
|
21
|
-
async function testCodeExecution(): Promise<void> {
|
|
22
|
-
const { userName, location, provider, currentDate } = await getArgs();
|
|
23
|
-
const { contentParts, aggregateContent } = createContentAggregator();
|
|
24
|
-
const customHandlers = {
|
|
25
|
-
[GraphEvents.TOOL_END]: new ToolEndHandler(),
|
|
26
|
-
[GraphEvents.CHAT_MODEL_END]: new ModelEndHandler(),
|
|
27
|
-
[GraphEvents.CHAT_MODEL_STREAM]: new ChatModelStreamHandler(),
|
|
28
|
-
[GraphEvents.ON_RUN_STEP_COMPLETED]: {
|
|
29
|
-
handle: (
|
|
30
|
-
event: GraphEvents.ON_RUN_STEP_COMPLETED,
|
|
31
|
-
data: t.StreamEventData
|
|
32
|
-
): void => {
|
|
33
|
-
console.log('====== ON_RUN_STEP_COMPLETED ======');
|
|
34
|
-
console.dir(data, { depth: null });
|
|
35
|
-
aggregateContent({
|
|
36
|
-
event,
|
|
37
|
-
data: data as unknown as { result: t.ToolEndEvent },
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
[GraphEvents.ON_RUN_STEP]: {
|
|
42
|
-
handle: (
|
|
43
|
-
event: GraphEvents.ON_RUN_STEP,
|
|
44
|
-
data: t.StreamEventData
|
|
45
|
-
): void => {
|
|
46
|
-
console.log('====== ON_RUN_STEP ======');
|
|
47
|
-
console.dir(data, { depth: null });
|
|
48
|
-
aggregateContent({ event, data: data as t.RunStep });
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
[GraphEvents.ON_RUN_STEP_DELTA]: {
|
|
52
|
-
handle: (
|
|
53
|
-
event: GraphEvents.ON_RUN_STEP_DELTA,
|
|
54
|
-
data: t.StreamEventData
|
|
55
|
-
): void => {
|
|
56
|
-
console.log('====== ON_RUN_STEP_DELTA ======');
|
|
57
|
-
console.dir(data, { depth: null });
|
|
58
|
-
aggregateContent({ event, data: data as t.RunStepDeltaEvent });
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
[GraphEvents.ON_MESSAGE_DELTA]: {
|
|
62
|
-
handle: (
|
|
63
|
-
event: GraphEvents.ON_MESSAGE_DELTA,
|
|
64
|
-
data: t.StreamEventData
|
|
65
|
-
): void => {
|
|
66
|
-
console.log('====== ON_MESSAGE_DELTA ======');
|
|
67
|
-
console.dir(data, { depth: null });
|
|
68
|
-
aggregateContent({ event, data: data as t.MessageDeltaEvent });
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
[GraphEvents.TOOL_START]: {
|
|
72
|
-
handle: (
|
|
73
|
-
_event: string,
|
|
74
|
-
data: t.StreamEventData,
|
|
75
|
-
metadata?: Record<string, unknown>
|
|
76
|
-
): void => {
|
|
77
|
-
console.log('====== TOOL_START ======');
|
|
78
|
-
console.dir(data, { depth: null });
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const llmConfig = getLLMConfig(provider);
|
|
84
|
-
|
|
85
|
-
const run = await Run.create<t.IState>({
|
|
86
|
-
runId: 'message-num-1',
|
|
87
|
-
graphConfig: {
|
|
88
|
-
type: 'standard',
|
|
89
|
-
llmConfig,
|
|
90
|
-
tools: [fetchRandomImageTool],
|
|
91
|
-
// tools: [fetchRandomImageURL],
|
|
92
|
-
instructions:
|
|
93
|
-
'You are a friendly AI assistant with internet capabilities. Always address the user by their name.',
|
|
94
|
-
additional_instructions: `The user's name is ${userName} and they are located in ${location}.`,
|
|
95
|
-
},
|
|
96
|
-
returnContent: true,
|
|
97
|
-
customHandlers,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
const config: Partial<RunnableConfig> & {
|
|
101
|
-
version: 'v1' | 'v2';
|
|
102
|
-
run_id?: string;
|
|
103
|
-
streamMode: string;
|
|
104
|
-
} = {
|
|
105
|
-
configurable: {
|
|
106
|
-
provider,
|
|
107
|
-
thread_id: 'conversation-num-1',
|
|
108
|
-
},
|
|
109
|
-
streamMode: 'values',
|
|
110
|
-
version: 'v2' as const,
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
console.log('Fetch Random Image');
|
|
114
|
-
|
|
115
|
-
const userMessage1 = `Hi ${userName} here. Please get me 2 random images. Describe them after you receive them.`;
|
|
116
|
-
|
|
117
|
-
conversationHistory.push(new HumanMessage(userMessage1));
|
|
118
|
-
|
|
119
|
-
let inputs = {
|
|
120
|
-
messages: conversationHistory,
|
|
121
|
-
};
|
|
122
|
-
const finalContentParts1 = await run.processStream(inputs, config);
|
|
123
|
-
const finalMessages1 = run.getRunMessages();
|
|
124
|
-
if (finalMessages1) {
|
|
125
|
-
conversationHistory.push(...finalMessages1);
|
|
126
|
-
}
|
|
127
|
-
console.log('\n\n====================\n\n');
|
|
128
|
-
console.dir(contentParts, { depth: null });
|
|
129
|
-
|
|
130
|
-
console.log('Test 2: Follow up with another message');
|
|
131
|
-
|
|
132
|
-
const userMessage2 = `thanks, you're the best!`;
|
|
133
|
-
|
|
134
|
-
conversationHistory.push(new HumanMessage(userMessage2));
|
|
135
|
-
|
|
136
|
-
inputs = {
|
|
137
|
-
messages: conversationHistory,
|
|
138
|
-
};
|
|
139
|
-
const finalContentParts2 = await run.processStream(inputs, config, {
|
|
140
|
-
keepContent: true,
|
|
141
|
-
});
|
|
142
|
-
const finalMessages2 = run.getRunMessages();
|
|
143
|
-
if (finalMessages2) {
|
|
144
|
-
conversationHistory.push(...finalMessages2);
|
|
145
|
-
}
|
|
146
|
-
console.log('\n\n====================\n\n');
|
|
147
|
-
console.dir(contentParts, { depth: null });
|
|
148
|
-
|
|
149
|
-
const { handleLLMEnd, collected } = createMetadataAggregator();
|
|
150
|
-
const titleResult = await run.generateTitle({
|
|
151
|
-
provider,
|
|
152
|
-
inputText: userMessage2,
|
|
153
|
-
contentParts,
|
|
154
|
-
chainOptions: {
|
|
155
|
-
callbacks: [
|
|
156
|
-
{
|
|
157
|
-
handleLLMEnd,
|
|
158
|
-
},
|
|
159
|
-
],
|
|
160
|
-
},
|
|
161
|
-
});
|
|
162
|
-
console.log('Generated Title:', titleResult);
|
|
163
|
-
console.log('Collected metadata:', collected);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
process.on('unhandledRejection', (reason, promise) => {
|
|
167
|
-
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
|
|
168
|
-
console.log('Conversation history:');
|
|
169
|
-
console.dir(conversationHistory, { depth: null });
|
|
170
|
-
process.exit(1);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
testCodeExecution().catch((err) => {
|
|
174
|
-
console.error(err);
|
|
175
|
-
console.log('Conversation history:');
|
|
176
|
-
console.dir(conversationHistory, { depth: null });
|
|
177
|
-
process.exit(1);
|
|
178
|
-
});
|