diff --git a/CHANGELOG.md b/CHANGELOG.md index b8adab1..034fd22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ All notable changes to Flynn are documented in this file. ### Added +- **Zhipu AI (GLM) Provider** -- Support for Zhipu AI's GLM models (glm-4.5, glm-4.7, etc.) + via their OpenAI-compatible API at `https://api.z.ai/api/paas/v4`. Uses `provider: zhipuai` + in config with `api_key` or `ZHIPUAI_API_KEY` env var. + - **Agent Tool: file.patch** -- Multi-file, multi-hunk structured patch tool. Apply line-based replacements, insertions, and deletions across multiple files in a single tool call. Hunks are applied bottom-up to preserve line numbers. 10 tests. diff --git a/README.md b/README.md index af2a470..64b8da5 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Self-hosted personal AI assistant with Telegram and Terminal interfaces. ## Features - **Multi-Frontend**: Telegram bot + Terminal UI (minimal & fullscreen modes) + Web UI dashboard -- **Multi-Model**: Anthropic Claude, OpenAI, GitHub Copilot, Gemini, Bedrock, Ollama, llama.cpp with intelligent routing +- **Multi-Model**: Anthropic Claude, OpenAI, GitHub Copilot, Gemini, Bedrock, Zhipu AI (GLM), Ollama, llama.cpp with intelligent routing - **Multi-Channel**: Telegram, Discord, Slack, WhatsApp with unified adapter interface - **Web Dashboard**: SPA control panel with health monitoring, chat, session browser, and settings editor - **Model Switching**: Switch between cloud/local models on demand @@ -113,6 +113,7 @@ hooks: | Gemini | `provider: gemini`, `api_key` | | Bedrock | `provider: bedrock`, AWS credentials | | Ollama | `provider: ollama`, `model`, optional `endpoint` | +| Zhipu AI (GLM) | `provider: zhipuai`, `api_key` or `ZHIPUAI_API_KEY`, optional `endpoint` | | llama.cpp | `provider: llamacpp`, `endpoint` | ### Model Tiers diff --git a/src/config/schema.ts b/src/config/schema.ts index 92c4d49..d889494 100644 --- a/src/config/schema.ts +++ b/src/config/schema.ts @@ -19,7 +19,7 @@ const serverSchema = z.object({ }); const modelConfigBaseSchema = z.object({ - provider: z.enum(['anthropic', 'openai', 'gemini', 'ollama', 'llamacpp', 'openrouter', 'bedrock', 'github']), + provider: z.enum(['anthropic', 'openai', 'gemini', 'ollama', 'llamacpp', 'openrouter', 'bedrock', 'github', 'zhipuai']), model: z.string(), endpoint: z.string().optional(), api_key: z.string().optional(), diff --git a/src/daemon/clientFactory.test.ts b/src/daemon/clientFactory.test.ts index f98cdee..1f450b0 100644 --- a/src/daemon/clientFactory.test.ts +++ b/src/daemon/clientFactory.test.ts @@ -87,6 +87,15 @@ describe('createClientFromConfig', () => { expect(client).toBeInstanceOf(OpenAIClient); }); + it('creates OpenAIClient with Zhipu AI baseURL for zhipuai provider', () => { + const client = createClientFromConfig({ + provider: 'zhipuai', + model: 'glm-4.5', + api_key: 'test-key', + }); + expect(client).toBeInstanceOf(OpenAIClient); + }); + it('creates BedrockClient for bedrock provider', () => { const client = createClientFromConfig({ provider: 'bedrock', diff --git a/src/daemon/index.ts b/src/daemon/index.ts index 97c5a77..79b1b47 100644 --- a/src/daemon/index.ts +++ b/src/daemon/index.ts @@ -108,6 +108,12 @@ export function createClientFromConfig(cfg: ModelConfig): ModelClient { apiKey: cfg.api_key ?? process.env.OPENROUTER_API_KEY, baseURL: cfg.endpoint ?? 'https://openrouter.ai/api/v1', }); + case 'zhipuai': + return new OpenAIClient({ + model: cfg.model, + apiKey: cfg.api_key ?? process.env.ZHIPUAI_API_KEY, + baseURL: cfg.endpoint ?? 'https://api.z.ai/api/paas/v4', + }); case 'bedrock': return new BedrockClient({ model: cfg.model,