sam-coder-cli 1.0.10 → 1.0.11
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/bin/agi-cli.js +17 -6
- package/package.json +1 -1
package/bin/agi-cli.js
CHANGED
|
@@ -382,6 +382,22 @@ function extractJsonFromMarkdown(text) {
|
|
|
382
382
|
// Call OpenRouter API with tool calling
|
|
383
383
|
async function callOpenRouter(messages, currentModel, useJson = false) {
|
|
384
384
|
const apiKey = OPENROUTER_API_KEY;
|
|
385
|
+
const isCustomEndpoint = API_BASE_URL !== 'https://openrouter.ai/api/v1';
|
|
386
|
+
|
|
387
|
+
let body = {
|
|
388
|
+
model: currentModel,
|
|
389
|
+
messages: messages,
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
// For standard OpenRouter calls that are not legacy, add tool parameters.
|
|
393
|
+
if (!isCustomEndpoint && !useJson) {
|
|
394
|
+
body.tools = tools;
|
|
395
|
+
body.tool_choice = 'auto';
|
|
396
|
+
}
|
|
397
|
+
// For custom endpoints (like vllm), ensure no tool-related parameters are sent.
|
|
398
|
+
else if (isCustomEndpoint) {
|
|
399
|
+
// The body is already clean for vLLM, containing only model and messages.
|
|
400
|
+
}
|
|
385
401
|
|
|
386
402
|
try {
|
|
387
403
|
const response = await fetch(`${API_BASE_URL}/chat/completions`, {
|
|
@@ -390,12 +406,7 @@ async function callOpenRouter(messages, currentModel, useJson = false) {
|
|
|
390
406
|
'Authorization': `Bearer ${apiKey}`,
|
|
391
407
|
'Content-Type': 'application/json'
|
|
392
408
|
},
|
|
393
|
-
body: JSON.stringify(
|
|
394
|
-
model: currentModel,
|
|
395
|
-
messages: messages,
|
|
396
|
-
tools: useJson ? undefined : tools,
|
|
397
|
-
tool_choice: useJson ? undefined : 'auto'
|
|
398
|
-
})
|
|
409
|
+
body: JSON.stringify(body)
|
|
399
410
|
});
|
|
400
411
|
|
|
401
412
|
if (!response.ok) {
|