mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-29 16:35:16 +00:00
54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
export function applyMockOpenAiModelConfig(cfg, params) {
|
|
const modelRef = params.modelRef ?? "openai/gpt-5.5";
|
|
const modelId = modelRef.split("/").at(-1) ?? "gpt-5.5";
|
|
const cost = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
|
cfg.models = {
|
|
...cfg.models,
|
|
mode: "merge",
|
|
providers: {
|
|
...cfg.models?.providers,
|
|
openai: {
|
|
...cfg.models?.providers?.openai,
|
|
baseUrl: `http://127.0.0.1:${params.mockPort}/v1`,
|
|
apiKey: { source: "env", provider: "default", id: "OPENAI_API_KEY" },
|
|
api: "openai-responses",
|
|
request: { ...cfg.models?.providers?.openai?.request, allowPrivateNetwork: true },
|
|
models: [
|
|
{
|
|
id: modelId,
|
|
name: modelId,
|
|
api: "openai-responses",
|
|
reasoning: false,
|
|
input: ["text", "image"],
|
|
cost,
|
|
contextWindow: 128000,
|
|
contextTokens: 96000,
|
|
maxTokens: 4096,
|
|
},
|
|
],
|
|
},
|
|
},
|
|
};
|
|
cfg.agents = {
|
|
...cfg.agents,
|
|
defaults: {
|
|
...cfg.agents?.defaults,
|
|
model: { primary: modelRef },
|
|
...(params.includeImageDefaults
|
|
? {
|
|
imageModel: { primary: modelRef, timeoutMs: 30_000 },
|
|
imageGenerationModel: { primary: "openai/gpt-image-1", timeoutMs: 30_000 },
|
|
}
|
|
: {}),
|
|
models: {
|
|
...cfg.agents?.defaults?.models,
|
|
[modelRef]: { params: { transport: "sse", openaiWsWarmup: false } },
|
|
},
|
|
},
|
|
};
|
|
cfg.plugins = {
|
|
...cfg.plugins,
|
|
enabled: true,
|
|
};
|
|
}
|