feat: add Zhipu AI (GLM) model provider support
Adds zhipuai as a new provider using the OpenAI-compatible API at api.z.ai. Supports api_key config or ZHIPUAI_API_KEY env var, with optional endpoint override. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user