mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 03:30:48 +08:00
chore(llm): drop AIA_DEEPSEEK_STRICT_TOOL_MODE legacy knob
Only AIA_TOOL_FUNCTION_STRICT=0 disables function.strict injection. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
81163371bd
commit
1d7282a0a2
2 changed files with 6 additions and 46 deletions
|
|
@ -115,17 +115,11 @@ def _openai_tool_function_strict_enabled() -> bool:
|
||||||
Default **on** for every provider/model: many gateways ignore unknown ``function`` keys; some
|
Default **on** for every provider/model: many gateways ignore unknown ``function`` keys; some
|
||||||
reject them—use ``AIA_TOOL_FUNCTION_STRICT=0`` to disable.
|
reject them—use ``AIA_TOOL_FUNCTION_STRICT=0`` to disable.
|
||||||
|
|
||||||
``AIA_DEEPSEEK_STRICT_TOOL_MODE=0`` is still honored as a legacy global opt-out when
|
DeepSeek documents ``function.strict`` in strict (Beta) tool mode:
|
||||||
``AIA_TOOL_FUNCTION_STRICT`` is unset. DeepSeek strict mode details:
|
|
||||||
https://api-docs.deepseek.com/zh-cn/guides/tool_calls
|
https://api-docs.deepseek.com/zh-cn/guides/tool_calls
|
||||||
"""
|
"""
|
||||||
primary = str(os.getenv("AIA_TOOL_FUNCTION_STRICT") or "").strip().lower()
|
raw = str(os.getenv("AIA_TOOL_FUNCTION_STRICT") or "").strip().lower()
|
||||||
if primary in ("0", "false", "no", "off"):
|
if raw in ("0", "false", "no", "off"):
|
||||||
return False
|
|
||||||
if primary in ("1", "true", "yes", "on"):
|
|
||||||
return True
|
|
||||||
legacy = str(os.getenv("AIA_DEEPSEEK_STRICT_TOOL_MODE") or "").strip().lower()
|
|
||||||
if legacy in ("0", "false", "no", "off"):
|
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,15 +13,12 @@ from svc.llm.transports.openai_chat_completions import (
|
||||||
|
|
||||||
class OpenAIToolFunctionStrictTests(unittest.TestCase):
|
class OpenAIToolFunctionStrictTests(unittest.TestCase):
|
||||||
def test_enabled_by_default(self) -> None:
|
def test_enabled_by_default(self) -> None:
|
||||||
prev_t = os.environ.pop("AIA_TOOL_FUNCTION_STRICT", None)
|
prev = os.environ.pop("AIA_TOOL_FUNCTION_STRICT", None)
|
||||||
prev_d = os.environ.pop("AIA_DEEPSEEK_STRICT_TOOL_MODE", None)
|
|
||||||
try:
|
try:
|
||||||
self.assertTrue(_openai_tool_function_strict_enabled())
|
self.assertTrue(_openai_tool_function_strict_enabled())
|
||||||
finally:
|
finally:
|
||||||
if prev_t is not None:
|
if prev is not None:
|
||||||
os.environ["AIA_TOOL_FUNCTION_STRICT"] = prev_t
|
os.environ["AIA_TOOL_FUNCTION_STRICT"] = prev
|
||||||
if prev_d is not None:
|
|
||||||
os.environ["AIA_DEEPSEEK_STRICT_TOOL_MODE"] = prev_d
|
|
||||||
|
|
||||||
def test_disabled_when_tool_function_strict_off(self) -> None:
|
def test_disabled_when_tool_function_strict_off(self) -> None:
|
||||||
prev = os.environ.get("AIA_TOOL_FUNCTION_STRICT")
|
prev = os.environ.get("AIA_TOOL_FUNCTION_STRICT")
|
||||||
|
|
@ -34,37 +31,6 @@ class OpenAIToolFunctionStrictTests(unittest.TestCase):
|
||||||
else:
|
else:
|
||||||
os.environ["AIA_TOOL_FUNCTION_STRICT"] = prev
|
os.environ["AIA_TOOL_FUNCTION_STRICT"] = prev
|
||||||
|
|
||||||
def test_disabled_legacy_deepseek_env_when_primary_unset(self) -> None:
|
|
||||||
prev_t = os.environ.pop("AIA_TOOL_FUNCTION_STRICT", None)
|
|
||||||
prev_d = os.environ.get("AIA_DEEPSEEK_STRICT_TOOL_MODE")
|
|
||||||
try:
|
|
||||||
os.environ["AIA_DEEPSEEK_STRICT_TOOL_MODE"] = "0"
|
|
||||||
self.assertFalse(_openai_tool_function_strict_enabled())
|
|
||||||
finally:
|
|
||||||
if prev_t is not None:
|
|
||||||
os.environ["AIA_TOOL_FUNCTION_STRICT"] = prev_t
|
|
||||||
if prev_d is None:
|
|
||||||
os.environ.pop("AIA_DEEPSEEK_STRICT_TOOL_MODE", None)
|
|
||||||
else:
|
|
||||||
os.environ["AIA_DEEPSEEK_STRICT_TOOL_MODE"] = prev_d
|
|
||||||
|
|
||||||
def test_primary_env_overrides_legacy_off(self) -> None:
|
|
||||||
prev_t = os.environ.get("AIA_TOOL_FUNCTION_STRICT")
|
|
||||||
prev_d = os.environ.get("AIA_DEEPSEEK_STRICT_TOOL_MODE")
|
|
||||||
try:
|
|
||||||
os.environ["AIA_DEEPSEEK_STRICT_TOOL_MODE"] = "0"
|
|
||||||
os.environ["AIA_TOOL_FUNCTION_STRICT"] = "1"
|
|
||||||
self.assertTrue(_openai_tool_function_strict_enabled())
|
|
||||||
finally:
|
|
||||||
if prev_t is None:
|
|
||||||
os.environ.pop("AIA_TOOL_FUNCTION_STRICT", None)
|
|
||||||
else:
|
|
||||||
os.environ["AIA_TOOL_FUNCTION_STRICT"] = prev_t
|
|
||||||
if prev_d is None:
|
|
||||||
os.environ.pop("AIA_DEEPSEEK_STRICT_TOOL_MODE", None)
|
|
||||||
else:
|
|
||||||
os.environ["AIA_DEEPSEEK_STRICT_TOOL_MODE"] = prev_d
|
|
||||||
|
|
||||||
def test_apply_sets_strict_on_function_tools(self) -> None:
|
def test_apply_sets_strict_on_function_tools(self) -> None:
|
||||||
tools = [
|
tools = [
|
||||||
{"type": "function", "function": {"name": "get_weather", "parameters": {"type": "object", "properties": {}}}},
|
{"type": "function", "function": {"name": "get_weather", "parameters": {"type": "object", "properties": {}}}},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue