GPTRouter 1.0.6__tar.gz → 1.0.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gptrouter-1.0.6 → gptrouter-1.0.7}/GPTRouter.egg-info/PKG-INFO +1 -1
- {gptrouter-1.0.6 → gptrouter-1.0.7}/PKG-INFO +1 -1
- {gptrouter-1.0.6 → gptrouter-1.0.7}/gpt_router/models.py +13 -1
- {gptrouter-1.0.6 → gptrouter-1.0.7}/setup.py +1 -1
- {gptrouter-1.0.6 → gptrouter-1.0.7}/GPTRouter.egg-info/SOURCES.txt +0 -0
- {gptrouter-1.0.6 → gptrouter-1.0.7}/GPTRouter.egg-info/dependency_links.txt +0 -0
- {gptrouter-1.0.6 → gptrouter-1.0.7}/GPTRouter.egg-info/requires.txt +0 -0
- {gptrouter-1.0.6 → gptrouter-1.0.7}/GPTRouter.egg-info/top_level.txt +0 -0
- {gptrouter-1.0.6 → gptrouter-1.0.7}/LICENSE +0 -0
- {gptrouter-1.0.6 → gptrouter-1.0.7}/README.md +0 -0
- {gptrouter-1.0.6 → gptrouter-1.0.7}/gpt_router/__init__.py +0 -0
- {gptrouter-1.0.6 → gptrouter-1.0.7}/gpt_router/client.py +0 -0
- {gptrouter-1.0.6 → gptrouter-1.0.7}/gpt_router/constants.py +0 -0
- {gptrouter-1.0.6 → gptrouter-1.0.7}/gpt_router/enums.py +0 -0
- {gptrouter-1.0.6 → gptrouter-1.0.7}/gpt_router/exceptions.py +0 -0
- {gptrouter-1.0.6 → gptrouter-1.0.7}/pyproject.toml +0 -0
- {gptrouter-1.0.6 → gptrouter-1.0.7}/setup.cfg +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from pydantic import ConfigDict, BaseModel, Field
|
|
1
|
+
from pydantic import ConfigDict, BaseModel, Field, model_validator
|
|
2
2
|
from enum import Enum
|
|
3
3
|
from typing import Dict, List, Literal, Optional, Any, Union
|
|
4
4
|
from humps import camelize
|
|
@@ -90,6 +90,18 @@ class Usage(BaseModel):
|
|
|
90
90
|
prompt_tokens: Optional[int] = None
|
|
91
91
|
total_tokens: Optional[int] = None
|
|
92
92
|
|
|
93
|
+
@model_validator(mode="before")
|
|
94
|
+
@classmethod
|
|
95
|
+
def unwrap_nested_usage(cls, data):
|
|
96
|
+
"""Handle API response where token counts are nested under a 'usage' key.
|
|
97
|
+
|
|
98
|
+
The API returns: {"meta": {"usage": {"prompt_tokens": N, ...}}}
|
|
99
|
+
but this model expects flat fields: {"prompt_tokens": N, ...}
|
|
100
|
+
"""
|
|
101
|
+
if isinstance(data, dict) and "usage" in data and isinstance(data["usage"], dict):
|
|
102
|
+
return data["usage"]
|
|
103
|
+
return data
|
|
104
|
+
|
|
93
105
|
|
|
94
106
|
class Choice(BaseModel):
|
|
95
107
|
index: int
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|