graphlit-client 1.0.20250613002 ā 1.0.20250613004
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/client.js +10 -3
- package/dist/model-mapping.js +46 -4
- package/dist/streaming/ui-event-adapter.js +62 -2
- package/package.json +1 -1
package/dist/client.js
CHANGED
@@ -1851,6 +1851,12 @@ class Graphlit {
|
|
1851
1851
|
}
|
1852
1852
|
// Execute tools and prepare for next round
|
1853
1853
|
if (toolHandlers && toolCalls.length > 0) {
|
1854
|
+
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
1855
|
+
console.log(`\nš§ [executeStreamingAgent] Round ${currentRound}: Processing ${toolCalls.length} tool calls`);
|
1856
|
+
toolCalls.forEach((tc, idx) => {
|
1857
|
+
console.log(` ${idx + 1}. ${tc.name} (${tc.id}) - Args length: ${tc.arguments.length}`);
|
1858
|
+
});
|
1859
|
+
}
|
1854
1860
|
// Add assistant message with tool calls to conversation
|
1855
1861
|
const assistantMessage = {
|
1856
1862
|
__typename: "ConversationMessage",
|
@@ -1944,17 +1950,18 @@ class Graphlit {
|
|
1944
1950
|
continue;
|
1945
1951
|
}
|
1946
1952
|
}
|
1947
|
-
// Update UI
|
1953
|
+
// Update UI - emit the full tool call with arguments
|
1948
1954
|
uiAdapter.handleEvent({
|
1949
|
-
type: "
|
1955
|
+
type: "tool_call_complete",
|
1950
1956
|
toolCall: {
|
1951
1957
|
id: toolCall.id,
|
1952
1958
|
name: toolCall.name,
|
1959
|
+
arguments: toolCall.arguments,
|
1953
1960
|
},
|
1954
1961
|
});
|
1955
1962
|
// Execute tool
|
1956
1963
|
const result = await handler(args);
|
1957
|
-
// Update UI
|
1964
|
+
// Update UI with result
|
1958
1965
|
uiAdapter.setToolResult(toolCall.id, result);
|
1959
1966
|
// Add tool response to messages
|
1960
1967
|
messages.push({
|
package/dist/model-mapping.js
CHANGED
@@ -5,38 +5,80 @@ import * as Types from "./generated/graphql-types.js";
|
|
5
5
|
*/
|
6
6
|
// OpenAI model mappings
|
7
7
|
const OPENAI_MODEL_MAP = {
|
8
|
-
|
8
|
+
// GPT-4 Turbo models
|
9
9
|
[Types.OpenAiModels.Gpt4Turbo_128K]: "gpt-4-turbo",
|
10
|
+
[Types.OpenAiModels.Gpt4Turbo_128K_0125]: "gpt-4-0125-preview",
|
11
|
+
[Types.OpenAiModels.Gpt4Turbo_128K_1106]: "gpt-4-1106-preview",
|
12
|
+
[Types.OpenAiModels.Gpt4Turbo_128K_20240409]: "gpt-4-turbo-2024-04-09",
|
13
|
+
// GPT-4o models
|
10
14
|
[Types.OpenAiModels.Gpt4O_128K]: "gpt-4o",
|
11
|
-
[Types.OpenAiModels.
|
15
|
+
[Types.OpenAiModels.Gpt4O_128K_20240513]: "gpt-4o-2024-05-13",
|
16
|
+
[Types.OpenAiModels.Gpt4O_128K_20240806]: "gpt-4o-2024-08-06",
|
17
|
+
[Types.OpenAiModels.Gpt4O_128K_20241120]: "gpt-4o-2024-11-20",
|
12
18
|
[Types.OpenAiModels.Gpt4OChat_128K]: "chatgpt-4o-latest",
|
13
|
-
|
14
|
-
[Types.OpenAiModels.
|
19
|
+
// GPT-4o Mini models
|
20
|
+
[Types.OpenAiModels.Gpt4OMini_128K]: "gpt-4o-mini",
|
21
|
+
[Types.OpenAiModels.Gpt4OMini_128K_20240718]: "gpt-4o-mini-2024-07-18",
|
22
|
+
// GPT 4.1 models
|
15
23
|
[Types.OpenAiModels.Gpt41_1024K]: "gpt-4.1",
|
24
|
+
[Types.OpenAiModels.Gpt41_1024K_20250414]: "gpt-4.1-2025-04-14",
|
16
25
|
[Types.OpenAiModels.Gpt41Mini_1024K]: "gpt-4.1-mini",
|
26
|
+
[Types.OpenAiModels.Gpt41Mini_1024K_20250414]: "gpt-4.1-mini-2025-04-14",
|
17
27
|
[Types.OpenAiModels.Gpt41Nano_1024K]: "gpt-4.1-nano",
|
28
|
+
// O1 models
|
29
|
+
[Types.OpenAiModels.O1Mini_128K]: "o1-mini",
|
30
|
+
[Types.OpenAiModels.O1Mini_128K_20240912]: "o1-mini-2024-09-12",
|
31
|
+
[Types.OpenAiModels.O1Preview_128K]: "o1-preview",
|
32
|
+
[Types.OpenAiModels.O1Preview_128K_20240912]: "o1-preview-2024-09-12",
|
33
|
+
// O3 models
|
18
34
|
[Types.OpenAiModels.O3Mini_200K]: "o3-mini",
|
35
|
+
[Types.OpenAiModels.O3Mini_200K_20250131]: "o3-mini-2025-01-31",
|
19
36
|
[Types.OpenAiModels.O3_200K]: "o3",
|
37
|
+
[Types.OpenAiModels.O3_200K_20250416]: "o3-2025-04-16",
|
38
|
+
// O4 models
|
20
39
|
[Types.OpenAiModels.O4Mini_200K]: "o4-mini",
|
40
|
+
[Types.OpenAiModels.O4Mini_200K_20250416]: "o4-mini-2025-04-16",
|
21
41
|
};
|
22
42
|
// Anthropic model mappings
|
23
43
|
const ANTHROPIC_MODEL_MAP = {
|
44
|
+
// Claude 3 models
|
24
45
|
[Types.AnthropicModels.Claude_3Opus]: "claude-3-opus-20240229",
|
46
|
+
[Types.AnthropicModels.Claude_3Opus_20240229]: "claude-3-opus-20240229",
|
25
47
|
[Types.AnthropicModels.Claude_3Sonnet]: "claude-3-sonnet-20240229",
|
48
|
+
[Types.AnthropicModels.Claude_3Sonnet_20240229]: "claude-3-sonnet-20240229",
|
26
49
|
[Types.AnthropicModels.Claude_3Haiku]: "claude-3-haiku-20240307",
|
50
|
+
[Types.AnthropicModels.Claude_3Haiku_20240307]: "claude-3-haiku-20240307",
|
51
|
+
// Claude 3.5 models
|
27
52
|
[Types.AnthropicModels.Claude_3_5Sonnet]: "claude-3-5-sonnet-20241022",
|
53
|
+
[Types.AnthropicModels.Claude_3_5Sonnet_20240620]: "claude-3-5-sonnet-20240620",
|
54
|
+
[Types.AnthropicModels.Claude_3_5Sonnet_20241022]: "claude-3-5-sonnet-20241022",
|
28
55
|
[Types.AnthropicModels.Claude_3_5Haiku]: "claude-3-5-haiku-20241022",
|
56
|
+
[Types.AnthropicModels.Claude_3_5Haiku_20241022]: "claude-3-5-haiku-20241022",
|
57
|
+
// Claude 3.7 models
|
29
58
|
[Types.AnthropicModels.Claude_3_7Sonnet]: "claude-3-7-sonnet-20250219",
|
59
|
+
[Types.AnthropicModels.Claude_3_7Sonnet_20250219]: "claude-3-7-sonnet-20250219",
|
60
|
+
// Claude 4 models
|
30
61
|
[Types.AnthropicModels.Claude_4Opus]: "claude-4-opus-20250514",
|
31
62
|
[Types.AnthropicModels.Claude_4Sonnet]: "claude-4-sonnet-20250514",
|
32
63
|
};
|
33
64
|
// Google model mappings
|
34
65
|
const GOOGLE_MODEL_MAP = {
|
66
|
+
// Gemini 1.5 Pro models
|
35
67
|
[Types.GoogleModels.Gemini_1_5Pro]: "gemini-1.5-pro",
|
68
|
+
[Types.GoogleModels.Gemini_1_5Pro_001]: "gemini-1.5-pro-001",
|
69
|
+
[Types.GoogleModels.Gemini_1_5Pro_002]: "gemini-1.5-pro-002",
|
70
|
+
// Gemini 1.5 Flash models
|
36
71
|
[Types.GoogleModels.Gemini_1_5Flash]: "gemini-1.5-flash",
|
72
|
+
[Types.GoogleModels.Gemini_1_5Flash_001]: "gemini-1.5-flash-001",
|
73
|
+
[Types.GoogleModels.Gemini_1_5Flash_002]: "gemini-1.5-flash-002",
|
74
|
+
// Gemini 1.5 Flash 8B models
|
37
75
|
[Types.GoogleModels.Gemini_1_5Flash_8B]: "gemini-1.5-flash-8b",
|
76
|
+
[Types.GoogleModels.Gemini_1_5Flash_8B_001]: "gemini-1.5-flash-8b-001",
|
77
|
+
// Gemini 2.0 Flash models
|
38
78
|
[Types.GoogleModels.Gemini_2_0Flash]: "gemini-2.0-flash-exp",
|
79
|
+
[Types.GoogleModels.Gemini_2_0Flash_001]: "gemini-2.0-flash-001",
|
39
80
|
[Types.GoogleModels.Gemini_2_0FlashExperimental]: "gemini-2.0-flash-exp",
|
81
|
+
// Gemini 2.5 models
|
40
82
|
[Types.GoogleModels.Gemini_2_5FlashPreview]: "gemini-2.5-flash-preview-05-20",
|
41
83
|
[Types.GoogleModels.Gemini_2_5ProPreview]: "gemini-2.5-pro-preview-06-05",
|
42
84
|
};
|
@@ -92,6 +92,10 @@ export class UIEventAdapter {
|
|
92
92
|
}
|
93
93
|
}
|
94
94
|
handleStart(conversationId) {
|
95
|
+
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
96
|
+
console.log(`š [UIEventAdapter] Handle start - Conversation ID: ${conversationId}`);
|
97
|
+
console.log(`š [UIEventAdapter] Active tool calls at start: ${this.activeToolCalls.size}`);
|
98
|
+
}
|
95
99
|
this.conversationId = conversationId;
|
96
100
|
this.isStreaming = true;
|
97
101
|
this.streamStartTime = Date.now();
|
@@ -99,6 +103,12 @@ export class UIEventAdapter {
|
|
99
103
|
this.lastTokenTime = 0;
|
100
104
|
this.tokenCount = 0;
|
101
105
|
this.tokenDelays = [];
|
106
|
+
// Note: We only clear tool calls here if this is truly a new conversation start
|
107
|
+
// For multi-round tool calling, handleStart is only called once at the beginning
|
108
|
+
if (this.activeToolCalls.size > 0) {
|
109
|
+
console.log(`š [UIEventAdapter] Warning: ${this.activeToolCalls.size} tool calls still active at start`);
|
110
|
+
}
|
111
|
+
this.activeToolCalls.clear();
|
102
112
|
this.emitUIEvent({
|
103
113
|
type: "conversation_started",
|
104
114
|
conversationId,
|
@@ -135,6 +145,10 @@ export class UIEventAdapter {
|
|
135
145
|
this.emitMessageUpdate(false);
|
136
146
|
}
|
137
147
|
handleToolCallStart(toolCall) {
|
148
|
+
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
149
|
+
console.log(`š§ [UIEventAdapter] Tool call start - ID: ${toolCall.id}, Name: ${toolCall.name}`);
|
150
|
+
console.log(`š§ [UIEventAdapter] Active tool calls before: ${this.activeToolCalls.size}`);
|
151
|
+
}
|
138
152
|
const conversationToolCall = {
|
139
153
|
__typename: "ConversationToolCall",
|
140
154
|
id: toolCall.id,
|
@@ -145,6 +159,9 @@ export class UIEventAdapter {
|
|
145
159
|
toolCall: conversationToolCall,
|
146
160
|
status: "preparing",
|
147
161
|
});
|
162
|
+
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
163
|
+
console.log(`š§ [UIEventAdapter] Active tool calls after: ${this.activeToolCalls.size}`);
|
164
|
+
}
|
148
165
|
this.emitUIEvent({
|
149
166
|
type: "tool_update",
|
150
167
|
toolCall: conversationToolCall,
|
@@ -152,20 +169,38 @@ export class UIEventAdapter {
|
|
152
169
|
});
|
153
170
|
}
|
154
171
|
handleToolCallDelta(toolCallId, argumentDelta) {
|
172
|
+
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
173
|
+
console.log(`š§ [UIEventAdapter] Tool call delta - ID: ${toolCallId}, Delta length: ${argumentDelta.length}`);
|
174
|
+
console.log(`š§ [UIEventAdapter] Delta content: ${argumentDelta.substring(0, 100)}...`);
|
175
|
+
}
|
155
176
|
const toolData = this.activeToolCalls.get(toolCallId);
|
156
|
-
if (toolData
|
177
|
+
if (toolData) {
|
157
178
|
toolData.toolCall.arguments += argumentDelta;
|
158
|
-
|
179
|
+
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
180
|
+
console.log(`š§ [UIEventAdapter] Tool ${toolCallId} accumulated args length: ${toolData.toolCall.arguments.length}`);
|
181
|
+
}
|
182
|
+
if (toolData.status === "preparing") {
|
183
|
+
toolData.status = "executing";
|
184
|
+
}
|
159
185
|
this.emitUIEvent({
|
160
186
|
type: "tool_update",
|
161
187
|
toolCall: toolData.toolCall,
|
162
188
|
status: "executing",
|
163
189
|
});
|
164
190
|
}
|
191
|
+
else {
|
192
|
+
console.warn(`š§ [UIEventAdapter] WARNING: Tool call delta for unknown tool ID: ${toolCallId}`);
|
193
|
+
}
|
165
194
|
}
|
166
195
|
handleToolCallComplete(toolCall) {
|
196
|
+
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
197
|
+
console.log(`š§ [UIEventAdapter] Tool call complete - ID: ${toolCall.id}, Name: ${toolCall.name}`);
|
198
|
+
console.log(`š§ [UIEventAdapter] Final arguments length: ${toolCall.arguments.length}`);
|
199
|
+
console.log(`š§ [UIEventAdapter] Final arguments: ${toolCall.arguments.substring(0, 200)}...`);
|
200
|
+
}
|
167
201
|
const toolData = this.activeToolCalls.get(toolCall.id);
|
168
202
|
if (toolData) {
|
203
|
+
// Update the arguments with the final complete version
|
169
204
|
toolData.toolCall.arguments = toolCall.arguments;
|
170
205
|
toolData.status = "completed";
|
171
206
|
this.emitUIEvent({
|
@@ -174,8 +209,33 @@ export class UIEventAdapter {
|
|
174
209
|
status: "completed",
|
175
210
|
});
|
176
211
|
}
|
212
|
+
else {
|
213
|
+
// If we don't have this tool call tracked, create it now
|
214
|
+
console.warn(`š§ [UIEventAdapter] Tool call complete for untracked tool ID: ${toolCall.id}, creating entry`);
|
215
|
+
const conversationToolCall = {
|
216
|
+
__typename: "ConversationToolCall",
|
217
|
+
id: toolCall.id,
|
218
|
+
name: toolCall.name,
|
219
|
+
arguments: toolCall.arguments,
|
220
|
+
};
|
221
|
+
this.activeToolCalls.set(toolCall.id, {
|
222
|
+
toolCall: conversationToolCall,
|
223
|
+
status: "completed",
|
224
|
+
});
|
225
|
+
this.emitUIEvent({
|
226
|
+
type: "tool_update",
|
227
|
+
toolCall: conversationToolCall,
|
228
|
+
status: "completed",
|
229
|
+
});
|
230
|
+
}
|
177
231
|
}
|
178
232
|
handleComplete(tokens) {
|
233
|
+
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
234
|
+
console.log(`š [UIEventAdapter] Handle complete - Active tool calls: ${this.activeToolCalls.size}`);
|
235
|
+
this.activeToolCalls.forEach((toolData, id) => {
|
236
|
+
console.log(`š [UIEventAdapter] Tool ${id}: ${toolData.toolCall.name}, Status: ${toolData.status}, Args length: ${toolData.toolCall.arguments.length}`);
|
237
|
+
});
|
238
|
+
}
|
179
239
|
// Clear any pending updates
|
180
240
|
if (this.updateTimer) {
|
181
241
|
globalThis.clearTimeout(this.updateTimer);
|