mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-11-06 13:12:27 +01:00
normalize named tool choice for Kimi thinking mode
This commit is contained in:
@@ -185,7 +185,7 @@ def search_tool_choice_request(request):
|
|||||||
def provider_compatible_tool_choice_request(request, model):
|
def provider_compatible_tool_choice_request(request, model):
|
||||||
"""Keep tools but avoid forced choice unsupported by thinking providers."""
|
"""Keep tools but avoid forced choice unsupported by thinking providers."""
|
||||||
model_name = canonical(str(model or '')).casefold()
|
model_name = canonical(str(model or '')).casefold()
|
||||||
if model_name.startswith('deepseek') and 'tool_choice' in request:
|
if model_name.startswith(('deepseek', 'kimi')) and 'tool_choice' in request:
|
||||||
compatible = dict(request)
|
compatible = dict(request)
|
||||||
choice = compatible.get('tool_choice')
|
choice = compatible.get('tool_choice')
|
||||||
selected_name = (
|
selected_name = (
|
||||||
|
|||||||
@@ -124,6 +124,23 @@ def test_deepseek_v4_flash_drops_named_choice_for_thinking_mode():
|
|||||||
assert 'tool_choice' not in compatible
|
assert 'tool_choice' not in compatible
|
||||||
|
|
||||||
|
|
||||||
|
def test_kimi_k3_drops_named_choice_incompatible_with_thinking_mode():
|
||||||
|
request = {
|
||||||
|
'tools': [
|
||||||
|
{'type': 'function', 'function': {'name': 'inspect_media'}},
|
||||||
|
{'type': 'function', 'function': {'name': 'write_file'}},
|
||||||
|
],
|
||||||
|
'tool_choice': {'type': 'function', 'function': {'name': 'inspect_media'}},
|
||||||
|
}
|
||||||
|
|
||||||
|
compatible = provider_compatible_tool_choice_request(request, 'kimi-k3')
|
||||||
|
|
||||||
|
assert [tool['function']['name'] for tool in compatible['tools']] == [
|
||||||
|
'inspect_media'
|
||||||
|
]
|
||||||
|
assert 'tool_choice' not in compatible
|
||||||
|
|
||||||
|
|
||||||
def test_qwen_capture_converts_single_required_tool_to_named_constraint():
|
def test_qwen_capture_converts_single_required_tool_to_named_constraint():
|
||||||
request = {
|
request = {
|
||||||
'tools': [{'type': 'function', 'function': {'name': 'web_search'}}],
|
'tools': [{'type': 'function', 'function': {'name': 'web_search'}}],
|
||||||
|
|||||||
Reference in New Issue
Block a user