Skip to content

Commit 2131537

Browse files
authored
docs: update documentation for model management module (#201)
- Update AGENTS.md with new Model Management section - Document model types (public/user) and resolution order - Add key API endpoints for model operations - Document bind_model configuration pattern - Update version to 1.0.8 - Update configuring-models.md (en/zh) - Add model types documentation (public/user) - Update configuration steps for new Model Management UI - Add connection test feature documentation - Add per-task model selection documentation - Document model resolution priority - Update creating-bots.md (en/zh) - Document bind_model as recommended model binding method - Make modelRef optional in spec section - Add bind_model_type for model type hints - Update managing-tasks.md (en/zh) - Add model_id and force_override_bot_model fields - Document per-task model selection feature These documentation updates reflect the changes from PR #194 which added the model management module with unified model view, connection testing, and per-task model selection. Co-authored-by: qdaxb <[email protected]>
1 parent b056366 commit 2131537

File tree

7 files changed

+279
-58
lines changed

7 files changed

+279
-58
lines changed

AGENTS.md

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,11 @@ alembic upgrade head --sql
456456
- Add component: Use/extend `src/components/ui/`
457457
- Add type: Define in `src/types/`
458458

459+
**Key feature modules:**
460+
- `src/features/settings/` - Settings page components including Models, Teams, Bots
461+
- `src/features/tasks/` - Task management and chat interface
462+
- `src/apis/models.ts` - Model API client (unified models, test connection)
463+
459464
**Environment:** `NEXT_PUBLIC_API_URL` for client-side API calls
460465

461466
### Executor
@@ -476,6 +481,52 @@ alembic upgrade head --sql
476481

477482
---
478483

484+
## 🔧 Model Management
485+
486+
### Model Types
487+
488+
Wegent supports two types of AI models:
489+
490+
| Type | Description | Storage |
491+
|------|-------------|---------|
492+
| **Public** | System-provided models, shared across all users | `public_models` table |
493+
| **User** | User-defined private models | `kinds` table (kind='Model') |
494+
495+
### Model Resolution Order
496+
497+
When a Bot executes a task, models are resolved in this order:
498+
1. Task-level model override (if `force_override_bot_model` is true)
499+
2. Bot's `bind_model` from `agent_config`
500+
3. Bot's `modelRef` (legacy)
501+
4. Default model
502+
503+
### Key APIs
504+
505+
- `GET /api/models/unified` - List all available models (public + user)
506+
- `GET /api/models/unified/{name}` - Get specific model by name
507+
- `POST /api/models/test-connection` - Test model API connection
508+
- `GET /api/models/compatible?agent_name=X` - Get models compatible with agent type
509+
510+
### Bot Model Binding
511+
512+
Two ways to bind models to Bots:
513+
514+
```yaml
515+
# Method 1: Using modelRef (legacy)
516+
spec:
517+
modelRef:
518+
name: model-name
519+
namespace: default
520+
521+
# Method 2: Using bind_model (recommended)
522+
spec:
523+
agent_config:
524+
bind_model: "my-model"
525+
bind_model_type: "user" # Optional: 'public' or 'user'
526+
```
527+
528+
---
529+
479530
## 🔒 Security
480531
481532
- Never commit credentials - use `.env` files (excluded from git)
@@ -549,6 +600,6 @@ docker-compose up -d --build [service]
549600

550601
---
551602

552-
**Last Updated**: 2025-01
553-
**Wegent Version**: 1.0.7
603+
**Last Updated**: 2025-07
604+
**Wegent Version**: 1.0.8
554605
**Maintained by**: WeCode-AI Team

docs/en/guides/user/configuring-models.md

Lines changed: 73 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,21 @@ Model determines "how strong the thinking ability is"
4545
### Relationship with Database
4646

4747
Model resources are stored in the following database tables:
48-
- `public_models`: Stores Model configuration information
49-
- `kinds`: Defines the resource type as `Model`
48+
- `public_models`: Stores public Model configurations shared across all users
49+
- `kinds`: Stores user-defined Model configurations (type='user')
50+
51+
### Model Types
52+
53+
Wegent supports two types of models:
54+
55+
| Type | Description | Storage |
56+
|------|-------------|---------|
57+
| **Public** | System-provided models shared across all users | `public_models` table |
58+
| **User** | User-defined private models | `kinds` table |
59+
60+
When binding models to Bots, the system resolves models in this order:
61+
1. User's private models (type='user')
62+
2. Public models (type='public')
5063

5164
---
5265

@@ -432,45 +445,52 @@ When using OpenAI GPT models, you need to configure the following environment va
432445

433446
### Method 1: Configure via Web Interface (Recommended for Beginners)
434447

435-
#### Step 1: Go to Model Configuration Page
448+
#### Step 1: Go to Model Management Page
436449

437450
1. Log in to Wegent Web interface (http://localhost:3000)
438-
2. Go to **Resource Management****Model Configuration**
439-
3. Click **Create New Model** button
451+
2. Go to **Settings****Models** tab
452+
3. You will see a unified model list displaying both public and user-defined models
453+
4. Click **Create New Model** button to add a new model
440454

441-
<!-- TODO: Add screenshot - Model configuration page -->
455+
<!-- TODO: Add screenshot - Model management page -->
442456

443-
#### Step 2: Use Preset Template (Recommended)
457+
#### Step 2: Configure Model Details
444458

445-
Above the JSON configuration input box, you will see a "Quick Configuration" area:
459+
In the model creation/edit dialog, configure the following:
446460

447-
📋 **Use Preset Templates for Quick Configuration**
461+
**Basic Information**:
462+
- **Name**: Give the Model a descriptive name (e.g., `my-claude-sonnet`)
463+
- **Display Name**: Optional human-readable name shown in the UI
448464

449-
- Click **[Claude Sonnet 4 Template]** button (primary recommendation)
450-
- Or click **[OpenAI GPT-4 Template]** button (alternative)
465+
**Provider Configuration**:
466+
- **Provider Type**: Select `OpenAI` or `Anthropic`
467+
- **Model ID**: Choose from preset models or enter a custom model ID
468+
- OpenAI presets: `gpt-4`, `gpt-4-turbo`, `gpt-3.5-turbo`, `gpt-4o`, `gpt-4o-mini`
469+
- Anthropic presets: `claude-sonnet-4-20250514`, `claude-3-7-sonnet-20250219`, `claude-3-5-haiku-20241022`
451470

452-
Clicking will automatically fill the complete JSON configuration into the input box.
471+
**Authentication**:
472+
- **API Key**: Enter your API key from the provider
473+
- Use the visibility toggle (👁️) to show/hide the key
474+
- **Base URL**: Optional custom API endpoint (for proxies or self-hosted services)
453475

454-
#### Step 3: Modify API Key
476+
#### Step 3: Test Connection
455477

456-
⚠️ **Important**: Please replace the API Key in the configuration with your actual key
478+
Before saving, use the **Test Connection** feature to verify your configuration:
457479

458-
The API Key in the template is a placeholder, you need to:
459-
1. Find the `ANTHROPIC_AUTH_TOKEN` or `OPENAI_API_KEY` field in the configuration
460-
2. Replace the value with your real API Key obtained from the official site
461-
3. If it's an Anthropic model, it's recommended to also modify `ANTHROPIC_API_KEY`
480+
1. Click the **Test Connection** button
481+
2. The system will send a minimal test request to verify:
482+
- API Key validity
483+
- Model availability
484+
- Network connectivity
485+
3. Results:
486+
- ✅ "Successfully connected to {model}" - Configuration is valid
487+
- ❌ Error message - Check your API key or network settings
462488

463-
#### Step 4: Fill in Other Fields
489+
#### Step 4: Save Configuration
464490

465-
- **Name**: Give the Model a descriptive name (e.g., `claude-sonnet-4-prod`)
466-
- **Namespace**: Usually use `default`
467-
- **JSON Configuration**: Already filled via template, just need to modify API Key
491+
Click **Save** to create or update the Model.
468492

469-
#### Step 5: Submit Configuration
470-
471-
Click the **Submit** button to create the Model.
472-
473-
The system will validate the configuration format and will prompt if there are errors.
493+
The model will appear in your model list and can be used in Bot configurations.
474494

475495
---
476496

@@ -490,6 +510,32 @@ Import the YAML configuration via the Web interface or API.
490510

491511
---
492512

513+
## 🔄 Model Selection in Tasks
514+
515+
### Per-Task Model Override
516+
517+
When creating or sending a task, you can override the Bot's default model:
518+
519+
1. In the chat interface, look for the **Model Selector** dropdown
520+
2. Select a different model from your available models
521+
3. Optionally enable **Force Override** to ensure this model is used even if the Bot has a configured model
522+
523+
**Use Cases**:
524+
- Testing with different models without modifying Bot configuration
525+
- Using a more powerful model for complex tasks
526+
- Using a faster/cheaper model for simple tasks
527+
528+
### Model Resolution Priority
529+
530+
When a task runs, the model is resolved in this order:
531+
532+
1. **Task-level override** (if force_override_bot_model is true)
533+
2. **Bot's bind_model** (from agent_config)
534+
3. **Bot's modelRef** (legacy)
535+
4. **Default model**
536+
537+
---
538+
493539
## ✅ Configuration Validation
494540

495541
After configuring a Model, **validation is essential** to ensure the configuration is correct and avoid errors during subsequent use.

docs/en/guides/user/creating-bots.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,32 @@ status:
158158
|-------|------|----------|-------------|
159159
| `ghostRef` | object | Yes | Ghost resource reference |
160160
| `shellRef` | object | Yes | Shell resource reference |
161-
| `modelRef` | object | Yes | Model resource reference |
161+
| `modelRef` | object | No | Model resource reference (optional, can use bind_model instead) |
162+
163+
#### Model Binding Methods
164+
165+
There are two ways to bind a model to a Bot:
166+
167+
**Method 1: Using modelRef (Legacy)**
168+
```yaml
169+
spec:
170+
modelRef:
171+
name: <model-name>
172+
namespace: default
173+
```
174+
175+
**Method 2: Using bind_model in agent_config (Recommended)**
176+
```yaml
177+
spec:
178+
agent_config:
179+
bind_model: "my-custom-model"
180+
bind_model_type: "user" # Optional: 'public' or 'user'
181+
```
182+
183+
The `bind_model` approach offers more flexibility:
184+
- Reference models by name without full YAML structure
185+
- Optionally specify model type to avoid naming conflicts
186+
- System auto-detects model type if not specified (user models first, then public)
162187

163188
#### Reference Object Format
164189

docs/en/guides/user/managing-tasks.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,20 @@ status:
187187
| `prompt` | string | Yes | Detailed task description and requirements |
188188
| `teamRef` | object | Yes | Team reference executing the task |
189189
| `workspaceRef` | object | Yes | Workspace reference |
190+
| `model_id` | string | No | Model name to override Bot's default model |
191+
| `force_override_bot_model` | boolean | No | Force use of specified model even if Bot has configured model |
192+
193+
### Per-Task Model Selection
194+
195+
When creating a task through the Web interface, you can select a different model:
196+
197+
1. **Model Selector**: In the chat input area, use the model dropdown to select from available models
198+
2. **Force Override**: Enable this option to ensure your selected model is used regardless of Bot configuration
199+
200+
**Use cases**:
201+
- Test different models without modifying Bot configuration
202+
- Use a more powerful model for complex one-off tasks
203+
- Use a cheaper/faster model for simple queries
190204

191205
#### status Section
192206

docs/zh/guides/user/configuring-models.md

Lines changed: 73 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,21 @@ Model 决定"思考能力有多强"
4545
### 与数据库的关系
4646

4747
Model 资源存储在数据库的以下表中:
48-
- `public_models`: 存储 Model 配置信息
49-
- `kinds`: 定义资源类型为 `Model`
48+
- `public_models`: 存储所有用户共享的公共 Model 配置
49+
- `kinds`: 存储用户自定义的私有 Model 配置 (type='user')
50+
51+
### 模型类型
52+
53+
Wegent 支持两种类型的模型:
54+
55+
| 类型 | 说明 | 存储位置 |
56+
|------|------|----------|
57+
| **公共模型** | 系统提供的所有用户共享的模型 | `public_models`|
58+
| **用户模型** | 用户自定义的私有模型 | `kinds`|
59+
60+
当将模型绑定到 Bot 时,系统按以下顺序解析模型:
61+
1. 用户的私有模型 (type='user')
62+
2. 公共模型 (type='public')
5063

5164
---
5265

@@ -432,45 +445,52 @@ sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
432445

433446
### 方式 1: 通过 Web 界面配置 (推荐新手)
434447

435-
#### 步骤 1: 进入 Model 配置页面
448+
#### 步骤 1: 进入 Model 管理页面
436449

437450
1. 登录 Wegent Web 界面 (http://localhost:3000)
438-
2. 进入 **资源管理****Model 配置**
439-
3. 点击 **创建新 Model** 按钮
451+
2. 进入 **设置****Models** 标签页
452+
3. 您将看到统一的模型列表,显示公共模型和用户自定义模型
453+
4. 点击 **创建新模型** 按钮添加新模型
440454

441-
<!-- TODO: 添加截图 - Model 配置页面 -->
455+
<!-- TODO: 添加截图 - Model 管理页面 -->
442456

443-
#### 步骤 2: 使用预设模板 (推荐)
457+
#### 步骤 2: 配置模型详情
444458

445-
在 JSON 配置输入框上方,您会看到 "快速配置" 区域:
459+
在模型创建/编辑对话框中,配置以下内容:
446460

447-
📋 **使用预设模板快速配置**
461+
**基本信息**:
462+
- **名称**: 给 Model 起一个描述性的名称 (如 `my-claude-sonnet`)
463+
- **显示名称**: 可选的在界面上显示的人类可读名称
448464

449-
- 点击 **[Claude Sonnet 4 模板]** 按钮 (主要推荐)
450-
- 或点击 **[OpenAI GPT-4 模板]** 按钮 (备选)
465+
**提供商配置**:
466+
- **提供商类型**: 选择 `OpenAI``Anthropic`
467+
- **模型 ID**: 从预设模型中选择或输入自定义模型 ID
468+
- OpenAI 预设: `gpt-4`, `gpt-4-turbo`, `gpt-3.5-turbo`, `gpt-4o`, `gpt-4o-mini`
469+
- Anthropic 预设: `claude-sonnet-4-20250514`, `claude-3-7-sonnet-20250219`, `claude-3-5-haiku-20241022`
451470

452-
点击后会自动填充完整的 JSON 配置到输入框。
471+
**认证信息**:
472+
- **API Key**: 输入您从提供商获取的 API 密钥
473+
- 使用可见性切换按钮 (👁️) 显示/隐藏密钥
474+
- **Base URL**: 可选的自定义 API 端点 (用于代理或自托管服务)
453475

454-
#### 步骤 3: 修改 API Key
476+
#### 步骤 3: 测试连接
455477

456-
⚠️ **重要**: 请修改配置中的 API Key 为您的实际密钥
478+
在保存之前,使用 **测试连接** 功能验证您的配置:
457479

458-
模板中的 API Key 是占位符,您需要:
459-
1. 找到配置中的 `ANTHROPIC_AUTH_TOKEN``OPENAI_API_KEY` 字段
460-
2. 将值替换为您从官网获取的真实 API Key
461-
3. 如果是 Anthropic 模型,建议同时修改 `ANTHROPIC_API_KEY`
480+
1. 点击 **测试连接** 按钮
481+
2. 系统会发送一个最小化的测试请求来验证:
482+
- API Key 有效性
483+
- 模型可用性
484+
- 网络连通性
485+
3. 结果:
486+
- ✅ "成功连接到 {模型}" - 配置有效
487+
- ❌ 错误信息 - 检查您的 API 密钥或网络设置
462488

463-
#### 步骤 4: 填写其他字段
489+
#### 步骤 4: 保存配置
464490

465-
- **名称**: 给 Model 起一个描述性的名称 (如 `claude-sonnet-4-prod`)
466-
- **命名空间**: 通常使用 `default`
467-
- **JSON 配置**: 已通过模板填充,只需修改 API Key
491+
点击 **保存** 创建或更新模型。
468492

469-
#### 步骤 5: 提交配置
470-
471-
点击 **提交** 按钮创建 Model。
472-
473-
系统会验证配置格式,如果有错误会提示。
493+
模型将出现在您的模型列表中,可以在 Bot 配置中使用。
474494

475495
---
476496

@@ -490,6 +510,32 @@ sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
490510

491511
---
492512

513+
## 🔄 任务中的模型选择
514+
515+
### 单任务模型覆盖
516+
517+
创建或发送任务时,您可以覆盖 Bot 的默认模型:
518+
519+
1. 在聊天界面中,找到 **模型选择器** 下拉框
520+
2. 从可用模型中选择不同的模型
521+
3. 可选择启用 **强制覆盖** 以确保使用此模型,即使 Bot 已配置了模型
522+
523+
**使用场景**:
524+
- 在不修改 Bot 配置的情况下测试不同模型
525+
- 对复杂任务使用更强大的模型
526+
- 对简单任务使用更快/更便宜的模型
527+
528+
### 模型解析优先级
529+
530+
当任务运行时,模型按以下顺序解析:
531+
532+
1. **任务级覆盖** (如果 force_override_bot_model 为 true)
533+
2. **Bot 的 bind_model** (来自 agent_config)
534+
3. **Bot 的 modelRef** (旧版)
535+
4. **默认模型**
536+
537+
---
538+
493539
## ✅ 配置验证
494540

495541
配置 Model 后,**务必进行验证**以确保配置正确,避免后续使用时出错。

0 commit comments

Comments
 (0)