llmjs2 1.3.6 → 1.3.8
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/index.js +6 -4
- package/package.json +1 -1
- package/providers/openai.js +1 -1
- package/providers/openrouter.js +1 -1
package/index.js
CHANGED
|
@@ -138,7 +138,7 @@ class LLMJS2 {
|
|
|
138
138
|
return {
|
|
139
139
|
model: null,
|
|
140
140
|
messages: [{ role: 'user', content: input }],
|
|
141
|
-
options: {}
|
|
141
|
+
options: { final: true }
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
144
|
|
|
@@ -175,7 +175,8 @@ class LLMJS2 {
|
|
|
175
175
|
tools: input.tools,
|
|
176
176
|
toolChoice: input.tool_choice || input.toolChoice,
|
|
177
177
|
apiKey: input.apiKey,
|
|
178
|
-
timeout: input.timeout
|
|
178
|
+
timeout: input.timeout,
|
|
179
|
+
final: input.final ?? true
|
|
179
180
|
}
|
|
180
181
|
};
|
|
181
182
|
}
|
|
@@ -189,6 +190,7 @@ class LLMJS2 {
|
|
|
189
190
|
async completion(input) {
|
|
190
191
|
try {
|
|
191
192
|
const { model, messages, options } = this.validateInput(input);
|
|
193
|
+
const { final, ...providerOptions } = options;
|
|
192
194
|
|
|
193
195
|
let provider, finalModel;
|
|
194
196
|
|
|
@@ -224,7 +226,7 @@ class LLMJS2 {
|
|
|
224
226
|
messages: messages
|
|
225
227
|
});
|
|
226
228
|
|
|
227
|
-
const result = await provider.createCompletion(messages, { ...
|
|
229
|
+
const result = await provider.createCompletion(messages, { ...providerOptions, model: finalModel });
|
|
228
230
|
|
|
229
231
|
// Log response information
|
|
230
232
|
logger.info('LLMJS2 📥 Received from LLM provider', {
|
|
@@ -232,7 +234,7 @@ class LLMJS2 {
|
|
|
232
234
|
...result
|
|
233
235
|
});
|
|
234
236
|
|
|
235
|
-
return result.content;
|
|
237
|
+
return final ? result.content : result;
|
|
236
238
|
|
|
237
239
|
} catch (error) {
|
|
238
240
|
// Sanitize error message to avoid leaking sensitive information
|
package/package.json
CHANGED
package/providers/openai.js
CHANGED
|
@@ -93,7 +93,7 @@ class OpenAIProvider {
|
|
|
93
93
|
return {
|
|
94
94
|
content: response.choices[0]?.message?.content || '',
|
|
95
95
|
role: response.choices[0]?.message?.role || 'assistant',
|
|
96
|
-
|
|
96
|
+
tool_calls: response.choices[0]?.message?.tool_calls,
|
|
97
97
|
usage: response.usage,
|
|
98
98
|
model: response.model,
|
|
99
99
|
finishReason: response.choices[0]?.finish_reason
|
package/providers/openrouter.js
CHANGED
|
@@ -102,7 +102,7 @@ class OpenRouterProvider {
|
|
|
102
102
|
return {
|
|
103
103
|
content: response.choices[0]?.message?.content || '',
|
|
104
104
|
role: response.choices[0]?.message?.role || 'assistant',
|
|
105
|
-
|
|
105
|
+
tool_calls: response.choices[0]?.message?.tool_calls,
|
|
106
106
|
usage: response.usage,
|
|
107
107
|
model: response.model,
|
|
108
108
|
finishReason: response.choices[0]?.finish_reason
|