mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
feat(api): enhance max_tokens field with robust null handling
- Update LLMModelConfigUpdate schema to accept Union[int, str] for max_tokens - Add field validator to gracefully handle various null representations: - Convert string "null" to null - Convert empty strings to null - Convert numeric strings to integers - Accept proper JSON null values - Update documentation to reflect new behavior and explain robust null handling - Prevents validation errors from incorrect null serialization by clients
This commit is contained in:
1 parent
e452f75ac3
commit
10a827f0c5
2 files changed
+25
-4
No files matched your search
@@ -148,7 +148,7 @@ The `model_type` field accepts the following values:
|
||||
| `model` | string (optional) | Model name |
|
||||
| `temperature` | float (optional) | Temperature |
|
||||
| `api_key` | string (optional) | API key |
|
||||
| `max_tokens` | integer (optional) | Max tokens |
|
||||
| `max_tokens` | integer or string (optional) | Max tokens for generation. Accepts integers, null, or the string "null" (which will be converted to null) |
|
||||
| `context_limit` | integer (optional) | Model context window limit in K tokens |
|
||||
| `context_strategy` | string (optional) | Context trimming strategy |
|
||||
| `is_default` | boolean (optional) | Default flag |
|
||||
@@ -156,6 +156,14 @@ The `model_type` field accepts the following values:
|
||||
|
||||
**Note:** When using `expected_version`, the API will verify the version hasn't changed since you read the data. If it has, you'll receive a 409 Conflict error.
|
||||
|
||||
**Robust Null Handling:** The `max_tokens` field includes a validator that gracefully handles various null representations:
|
||||
- Accepts proper JSON `null` values
|
||||
- Accepts the string `"null"` (common serialization issue) and converts it to `null`
|
||||
- Accepts empty strings `""` and converts them to `null`
|
||||
- Accepts numeric strings (e.g., `"4096"`) and converts them to integers
|
||||
|
||||
This prevents validation errors when clients incorrectly serialize `null` as the string `"null"`.
|
||||
|
||||
### LLMModelConfigResponse
|
||||
|
||||
| Field | Type | Description |
|
||||
|
||||
Reference in new issue
Block a user