mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 13:04:08 +00:00
feat(ai): Add zAI provider support
- Add 'zai' as a KnownProvider type - Add ZAI_API_KEY environment variable mapping - Generate 4 zAI models (glm-4.5-air, glm-4.5v, etc.) using anthropic-messages API - Add comprehensive test coverage for zAI provider in generate.test.ts and empty.test.ts - Models support reasoning/thinking capabilities and tool calling
This commit is contained in:
parent
9230b83d94
commit
d073953ef7
6 changed files with 299 additions and 26 deletions
|
|
@ -259,6 +259,32 @@ async function loadModelsDevData(): Promise<Model<any>[]> {
|
|||
}
|
||||
}
|
||||
|
||||
// Process xAi models
|
||||
if (data.zai?.models) {
|
||||
for (const [modelId, model] of Object.entries(data.zai.models)) {
|
||||
const m = model as ModelsDevModel;
|
||||
if (m.tool_call !== true) continue;
|
||||
|
||||
models.push({
|
||||
id: modelId,
|
||||
name: m.name || modelId,
|
||||
api: "anthropic-messages",
|
||||
provider: "zai",
|
||||
baseUrl: "https://api.z.ai/api/anthropic",
|
||||
reasoning: m.reasoning === true,
|
||||
input: m.modalities?.input?.includes("image") ? ["text", "image"] : ["text"],
|
||||
cost: {
|
||||
input: m.cost?.input || 0,
|
||||
output: m.cost?.output || 0,
|
||||
cacheRead: m.cost?.cache_read || 0,
|
||||
cacheWrite: m.cost?.cache_write || 0,
|
||||
},
|
||||
contextWindow: m.limit?.context || 4096,
|
||||
maxTokens: m.limit?.output || 4096,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Loaded ${models.length} tool-capable models from models.dev`);
|
||||
return models;
|
||||
} catch (error) {
|
||||
|
|
@ -277,7 +303,7 @@ async function generateModels() {
|
|||
// Combine models (models.dev has priority)
|
||||
const allModels = [...modelsDevModels, ...openRouterModels];
|
||||
|
||||
// Add missing gpt models
|
||||
// Add missing gpt models (can't use tools)
|
||||
if (!allModels.some(m => m.provider === "openai" && m.id === "gpt-5-chat-latest")) {
|
||||
allModels.push({
|
||||
id: "gpt-5-chat-latest",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue