Spaces:
Paused
Paused
Mirrowel
commited on
Commit
·
868b7c9
1
Parent(s):
3298177
refactor(logging): 🔨 adjust logging levels and improve schema cleaning for Antigravity
Browse files- Change reasoning parameters log from info to debug level in main.py
- Move reasoning parameters logging outside logger conditional block for consistent monitoring
- Enhance _clean_claude_schema documentation to clarify it's for Antigravity/Google's Proto-based API
- Add support for converting 'const' to 'enum' with single value in schema cleaning
- Improve code organization with better comments explaining unsupported fields
These changes improve logging granularity and enhance JSON Schema compatibility with Antigravity's Proto-based API requirements.
src/proxy_app/main.py
CHANGED
|
@@ -672,15 +672,15 @@ async def chat_completions(
|
|
| 672 |
if logger:
|
| 673 |
logger.log_request(headers=request.headers, body=request_data)
|
| 674 |
|
| 675 |
-
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
|
| 681 |
-
|
| 682 |
-
|
| 683 |
-
|
| 684 |
|
| 685 |
# Log basic request info to console (this is a separate, simpler logger).
|
| 686 |
log_request_to_console(
|
|
|
|
| 672 |
if logger:
|
| 673 |
logger.log_request(headers=request.headers, body=request_data)
|
| 674 |
|
| 675 |
+
# Extract and log specific reasoning parameters for monitoring.
|
| 676 |
+
model = request_data.get("model")
|
| 677 |
+
generation_cfg = request_data.get("generationConfig", {}) or request_data.get("generation_config", {}) or {}
|
| 678 |
+
reasoning_effort = request_data.get("reasoning_effort") or generation_cfg.get("reasoning_effort")
|
| 679 |
+
custom_reasoning_budget = request_data.get("custom_reasoning_budget") or generation_cfg.get("custom_reasoning_budget", False)
|
| 680 |
+
|
| 681 |
+
logging.getLogger("rotator_library").debug(
|
| 682 |
+
f"Handling reasoning parameters: model={model}, reasoning_effort={reasoning_effort}, custom_reasoning_budget={custom_reasoning_budget}"
|
| 683 |
+
)
|
| 684 |
|
| 685 |
# Log basic request info to console (this is a separate, simpler logger).
|
| 686 |
log_request_to_console(
|
src/rotator_library/providers/antigravity_provider.py
CHANGED
|
@@ -186,15 +186,27 @@ def _recursively_parse_json_strings(obj: Any) -> Any:
|
|
| 186 |
|
| 187 |
|
| 188 |
def _clean_claude_schema(schema: Any) -> Any:
|
| 189 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
if not isinstance(schema, dict):
|
| 191 |
return schema
|
| 192 |
|
| 193 |
-
|
|
|
|
|
|
|
|
|
|
| 194 |
cleaned = {}
|
| 195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
for key, value in schema.items():
|
| 197 |
-
if key in incompatible:
|
| 198 |
continue
|
| 199 |
if isinstance(value, dict):
|
| 200 |
cleaned[key] = _clean_claude_schema(value)
|
|
|
|
| 186 |
|
| 187 |
|
| 188 |
def _clean_claude_schema(schema: Any) -> Any:
|
| 189 |
+
"""
|
| 190 |
+
Recursively clean JSON Schema for Antigravity/Google's Proto-based API.
|
| 191 |
+
- Removes unsupported fields ($schema, additionalProperties, etc.)
|
| 192 |
+
- Converts 'const' to 'enum' with single value (supported equivalent)
|
| 193 |
+
"""
|
| 194 |
if not isinstance(schema, dict):
|
| 195 |
return schema
|
| 196 |
|
| 197 |
+
# Fields not supported by Antigravity/Google's Proto-based API
|
| 198 |
+
incompatible = {
|
| 199 |
+
'$schema', 'additionalProperties', 'minItems', 'maxItems', 'pattern',
|
| 200 |
+
}
|
| 201 |
cleaned = {}
|
| 202 |
|
| 203 |
+
# Handle 'const' by converting to 'enum' with single value
|
| 204 |
+
if 'const' in schema:
|
| 205 |
+
const_value = schema['const']
|
| 206 |
+
cleaned['enum'] = [const_value]
|
| 207 |
+
|
| 208 |
for key, value in schema.items():
|
| 209 |
+
if key in incompatible or key == 'const':
|
| 210 |
continue
|
| 211 |
if isinstance(value, dict):
|
| 212 |
cleaned[key] = _clean_claude_schema(value)
|