mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-06 06:52:20 +02:00
narrow DeepSeek Flash tools for forced phases
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -100,12 +100,15 @@ def test_provider_wire_messages_drops_empty_assistant_placeholder():
|
||||
def test_deepseek_flash_keeps_tools_but_drops_unsupported_forced_choice():
|
||||
request = {
|
||||
'model': 'deepseek-flash',
|
||||
'tools': [{'type': 'function', 'function': {'name': 'inspect_media'}}],
|
||||
'tools': [
|
||||
{'type': 'function', 'function': {'name': 'inspect_media'}},
|
||||
{'type': 'function', 'function': {'name': 'python'}},
|
||||
],
|
||||
'tool_choice': {'type': 'function', 'function': {'name': 'inspect_media'}},
|
||||
}
|
||||
|
||||
compatible = provider_compatible_tool_choice_request(request, 'deepseek-flash')
|
||||
assert compatible['tools'] == request['tools']
|
||||
assert [tool['function']['name'] for tool in compatible['tools']] == ['inspect_media']
|
||||
assert 'tool_choice' not in compatible
|
||||
assert request['tool_choice']['function']['name'] == 'inspect_media'
|
||||
assert provider_compatible_tool_choice_request(request, 'qwen3.5-9b') is request
|
||||
|
||||
Reference in New Issue
Block a user