mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-09-19 11:15:24 +03:00
fix(llm): apply DeepSeek capabilities to OpenRouter-namespaced models
- OpenRouter exposes DeepSeek as deepseek/<id>, which matched neither the exact IDs nor the patterns, so a thinking model like deepseek/deepseek-v4-flash fell through to _DEFAULT and had object-form tool_choice forced on it - strip the official deepseek/ namespace before lookup so it reuses the native quirks; deepseek/deepseek-chat still keeps tool_choice, and third-party finetunes on other publishers stay on _DEFAULT #1199
This commit is contained in:
@@ -116,6 +116,37 @@ class TestDefault:
|
||||
assert caps.supports_tool_choice is True
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
class TestOpenRouterDeepSeekNamespace:
|
||||
"""OpenRouter namespaces DeepSeek as ``deepseek/<id>``; strip it so the
|
||||
same quirks apply as the native provider (#1199)."""
|
||||
|
||||
def test_prefixed_v4_flash_suppresses_tool_choice(self):
|
||||
# Was falling through to _DEFAULT (tool_choice on) -> slow object-form call.
|
||||
assert get_capabilities("deepseek/deepseek-v4-flash").supports_tool_choice is False
|
||||
|
||||
def test_prefixed_reasoner_suppresses_tool_choice(self):
|
||||
assert get_capabilities("deepseek/deepseek-reasoner").supports_tool_choice is False
|
||||
|
||||
def test_prefixed_chat_selects_deepseek_chat_not_default(self):
|
||||
# Must resolve to _DEEPSEEK_CHAT, not _DEFAULT: supports_json_schema=False
|
||||
# is what distinguishes them (both keep tool_choice).
|
||||
caps = get_capabilities("deepseek/deepseek-chat")
|
||||
assert caps.supports_tool_choice is True
|
||||
assert caps.supports_json_schema is False # _DEEPSEEK_CHAT, not _DEFAULT
|
||||
|
||||
def test_only_official_namespace_is_stripped(self):
|
||||
# A third-party publisher whose model name WOULD match a deepseek pattern
|
||||
# must stay _DEFAULT: proves we strip only "deepseek/", not any "*/".
|
||||
caps = get_capabilities("tngtech/deepseek-v4-flash")
|
||||
assert caps.supports_tool_choice is True # not thinking
|
||||
assert caps.supports_json_schema is True # _DEFAULT
|
||||
|
||||
def test_native_ids_unchanged(self):
|
||||
assert get_capabilities("deepseek-v4-flash").supports_tool_choice is False
|
||||
assert get_capabilities("deepseek-chat").supports_tool_choice is True
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_capabilities_dataclass_is_frozen():
|
||||
"""Capability rows are immutable so they can be safely shared."""
|
||||
|
||||
Reference in New Issue
Block a user