mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-08-27 12:30:13 +03:00
feat(api): clarify default LLM model config selection logic
- Update API documentation to explicitly describe default configuration selection logic - Add fallback behavior in repository to use first config when no default is marked - Clarify difference between `/default` endpoint and `default_config` field - Document that `default_config` is never null when configs list is not empty
This commit is contained in:
parent
b06593cf2a
commit
2e4c42fadc
@ -161,9 +161,14 @@ The `model_type` field accepts the following values:
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `configs` | list[LLMModelConfigWithSource] | Effective configurations |
|
||||
| `default_config` | LLMModelConfigWithSource (nullable) | Default configuration |
|
||||
| `default_config` | LLMModelConfigWithSource (nullable) | Default configuration (never null if configs list is not empty) |
|
||||
| `total` | integer | Total count |
|
||||
|
||||
**Default Configuration Selection Logic:**
|
||||
1. User's config marked with `is_default: true`
|
||||
2. Group's config marked with `is_default: true` (if user has no default)
|
||||
3. First config in the list (fallback if no default is marked)
|
||||
|
||||
### LLMModelConfigWithSource
|
||||
|
||||
| Field | Type | Description |
|
||||
@ -368,6 +373,8 @@ curl -X GET http://localhost:3080/v3/access/users/{user_id}/llm-model-configs/de
|
||||
-H "Authorization: Bearer <token>"
|
||||
```
|
||||
|
||||
**Note:** This endpoint only returns configurations explicitly marked with `is_default: true`. If no configuration is marked as default, it returns 404.
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
@ -408,6 +415,12 @@ curl -X GET http://localhost:3080/v3/access/groups/{group_id}/llm-model-configs/
|
||||
|
||||
The response format is the same as for users.
|
||||
|
||||
---
|
||||
|
||||
**Important Note:** This dedicated `/default` endpoint is different from the `default_config` field in the list response:
|
||||
- `/default` endpoint: Requires explicit `is_default: true` flag, returns 404 if not found
|
||||
- `default_config` field in list: Falls back to first config if no explicit default is marked
|
||||
|
||||
### 8. Delete a configuration
|
||||
|
||||
```bash
|
||||
|
||||
@ -496,6 +496,10 @@ class LLMModelConfigsRepository(BaseRepository):
|
||||
if config.is_default and default_config is None:
|
||||
default_config = configs_with_source[-1]
|
||||
|
||||
# Fallback: if no config is marked as default, use the first one
|
||||
if default_config is None and configs_with_source:
|
||||
default_config = configs_with_source[0]
|
||||
|
||||
return {
|
||||
"configs": configs_with_source,
|
||||
"default_config": default_config
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user