mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-10-27 02:32:23 +02: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 |
|
| Field | Type | Description |
|
||||||
|-------|------|-------------|
|
|-------|------|-------------|
|
||||||
| `configs` | list[LLMModelConfigWithSource] | Effective configurations |
|
| `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 |
|
| `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
|
### LLMModelConfigWithSource
|
||||||
|
|
||||||
| Field | Type | Description |
|
| 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>"
|
-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:**
|
**Response:**
|
||||||
```json
|
```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.
|
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
|
### 8. Delete a configuration
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@ -496,6 +496,10 @@ class LLMModelConfigsRepository(BaseRepository):
|
|||||||
if config.is_default and default_config is None:
|
if config.is_default and default_config is None:
|
||||||
default_config = configs_with_source[-1]
|
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 {
|
return {
|
||||||
"configs": configs_with_source,
|
"configs": configs_with_source,
|
||||||
"default_config": default_config
|
"default_config": default_config
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user