wirejs-resources 0.1.150-llm → 0.1.151-llm
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/services/llm.d.ts +19 -7
- package/dist/services/llm.js +14 -5
- package/package.json +1 -1
package/dist/services/llm.d.ts
CHANGED
|
@@ -10,15 +10,25 @@ export type ToolCall = {
|
|
|
10
10
|
arguments: Record<string, any>;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
/** User message in conversation */
|
|
14
|
+
export type UserMessage = {
|
|
15
|
+
/** Always 'user' for user messages */
|
|
16
|
+
role: 'user';
|
|
16
17
|
/** Text content of the message */
|
|
17
18
|
content: string;
|
|
18
|
-
|
|
19
|
+
};
|
|
20
|
+
/** Assistant message type - what LLM methods actually return */
|
|
21
|
+
export type AssistantMessage = {
|
|
22
|
+
/** Always 'assistant' for LLM responses */
|
|
23
|
+
role: 'assistant';
|
|
24
|
+
/** Text content of the message */
|
|
25
|
+
content: string;
|
|
26
|
+
/** Tool calls requested by the assistant */
|
|
19
27
|
tool_calls?: ToolCall[];
|
|
20
|
-
}
|
|
21
|
-
|
|
28
|
+
};
|
|
29
|
+
/** Tool execution result message */
|
|
30
|
+
export type ToolMessage = {
|
|
31
|
+
/** Always 'tool' for tool execution results */
|
|
22
32
|
role: 'tool';
|
|
23
33
|
/** Result content from the tool execution */
|
|
24
34
|
content: string;
|
|
@@ -27,6 +37,8 @@ export type LLMMessage = {
|
|
|
27
37
|
/** ID linking this result to the original tool call */
|
|
28
38
|
tool_call_id: string;
|
|
29
39
|
};
|
|
40
|
+
/** Union of all possible message types in conversation history */
|
|
41
|
+
export type LLMMessage = UserMessage | AssistantMessage | ToolMessage;
|
|
30
42
|
export type LLMChunk = {
|
|
31
43
|
created_at: string;
|
|
32
44
|
message: LLMMessage;
|
|
@@ -88,6 +100,6 @@ export declare class LLM extends Resource {
|
|
|
88
100
|
private checkOllamaAvailable;
|
|
89
101
|
private checkModelExists;
|
|
90
102
|
private createStreamedString;
|
|
91
|
-
continueConversation({ history, onChunk, timeoutSeconds, systemPrompt, targetContextSize, models, tools, }: ContinueConversationOptions): Promise<
|
|
103
|
+
continueConversation({ history, onChunk, timeoutSeconds, systemPrompt, targetContextSize, models, tools, }: ContinueConversationOptions): Promise<AssistantMessage>;
|
|
92
104
|
}
|
|
93
105
|
export {};
|
package/dist/services/llm.js
CHANGED
|
@@ -40,11 +40,9 @@ export class LLM extends Resource {
|
|
|
40
40
|
tool_calls = chunk.message.tool_calls;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
//
|
|
44
|
-
const finalRole = (role === 'user' || role === 'assistant') ? role : 'assistant';
|
|
45
|
-
// Build the result message
|
|
43
|
+
// Build the assistant result message
|
|
46
44
|
const result = {
|
|
47
|
-
role:
|
|
45
|
+
role: 'assistant',
|
|
48
46
|
content
|
|
49
47
|
};
|
|
50
48
|
if (tool_calls) {
|
|
@@ -161,7 +159,18 @@ export class LLM extends Resource {
|
|
|
161
159
|
}
|
|
162
160
|
else {
|
|
163
161
|
const chunk = await response.json();
|
|
164
|
-
return
|
|
162
|
+
// Ensure we return an assistant message
|
|
163
|
+
const message = chunk.message;
|
|
164
|
+
if (message.role === 'assistant') {
|
|
165
|
+
return message;
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
// Fallback: create assistant message
|
|
169
|
+
return {
|
|
170
|
+
role: 'assistant',
|
|
171
|
+
content: message.content
|
|
172
|
+
};
|
|
173
|
+
}
|
|
165
174
|
}
|
|
166
175
|
}
|
|
167
176
|
}
|