allow proxy auto model selection
This commit is contained in:
+20
-1
@@ -4,7 +4,7 @@ import axios from 'axios';
|
||||
import { extractBalancedJSON, extractJSONText, extractMeaningfulError, mapWithConcurrency } from '../llm.js';
|
||||
|
||||
const ENV_KEYS = [
|
||||
'CLI_PROXY_API', 'CLI_PROXY_API_KEY', 'MODEL', 'INPUT_MODEL', 'OPENCODE_MODEL',
|
||||
'CLI_PROXY_API', 'CLI_PROXY_API_KEY', 'CLI_PROXY_API_MODEL', 'MODEL', 'INPUT_MODEL', 'OPENCODE_MODEL',
|
||||
'AI_ASSISTANT_TIMEOUT_MS', 'AI_ASSISTANT_MAX_BUFFER',
|
||||
];
|
||||
|
||||
@@ -57,6 +57,25 @@ describe('chat - CLIProxyAPI', async () => {
|
||||
assert.equal(capturedOpts.headers.Authorization, 'Bearer secret');
|
||||
});
|
||||
|
||||
it('omits model from the request body when auto selection is allowed', async () => {
|
||||
process.env.CLI_PROXY_API = 'https://proxy.example';
|
||||
process.env.CLI_PROXY_API_KEY = 'secret';
|
||||
|
||||
let capturedBody;
|
||||
mock.method(axios, 'post', async (url, body) => {
|
||||
capturedBody = body;
|
||||
return {
|
||||
data: { choices: [{ message: { content: 'cli response' } }] },
|
||||
headers: {},
|
||||
};
|
||||
});
|
||||
|
||||
const result = await chat('sys', 'user');
|
||||
|
||||
assert.equal(result, 'cli response');
|
||||
assert.equal(Object.hasOwn(capturedBody, 'model'), false);
|
||||
});
|
||||
|
||||
it('throws an error when the API fails', async () => {
|
||||
process.env.CLI_PROXY_API = 'https://proxy.example';
|
||||
process.env.MODEL = 'gpt-5-mini';
|
||||
|
||||
Reference in New Issue
Block a user