narrow DeepSeek Flash tools for forced phases

This commit is contained in:
pewdiepie-archdaemon
2026-09-17 23:43:06 +00:00
parent d0aee5afc7
commit bd4345a2a6
2 changed files with 17 additions and 2 deletions
+12
View File
@@ -186,6 +186,18 @@ def provider_compatible_tool_choice_request(request, model):
"""Keep tools but avoid forced choice unsupported by thinking providers."""
if canonical(model) == 'deepseek-flash' and 'tool_choice' in request:
compatible = dict(request)
choice = compatible.get('tool_choice')
selected_name = (
(choice.get('function') or {}).get('name')
if isinstance(choice, dict) else None
)
if selected_name:
selected = [
schema for schema in compatible.get('tools') or []
if (schema.get('function') or {}).get('name') == selected_name
]
if selected:
compatible['tools'] = selected
compatible.pop('tool_choice', None)
return compatible
return request