refactor: streamline reasoning configuration checks in AIAgent
- Simplified the logic for determining support for reasoning based on the base URL by introducing clearer variable names. - Added product attribution for the Nous Portal to the extra body of requests when applicable, enhancing tagging for better tracking.
This commit is contained in:
parent
55a0178490
commit
e3cb957a10
1 changed files with 13 additions and 10 deletions
23
run_agent.py
23
run_agent.py
|
|
@ -1186,11 +1186,10 @@ class AIAgent:
|
||||||
if provider_preferences:
|
if provider_preferences:
|
||||||
extra_body["provider"] = provider_preferences
|
extra_body["provider"] = provider_preferences
|
||||||
|
|
||||||
_supports_reasoning = (
|
_is_openrouter = "openrouter" in self.base_url.lower()
|
||||||
"openrouter" in self.base_url.lower()
|
_is_nous = "nousresearch" in self.base_url.lower()
|
||||||
or "nousresearch" in self.base_url.lower()
|
|
||||||
)
|
if _is_openrouter or _is_nous:
|
||||||
if _supports_reasoning:
|
|
||||||
if self.reasoning_config is not None:
|
if self.reasoning_config is not None:
|
||||||
extra_body["reasoning"] = self.reasoning_config
|
extra_body["reasoning"] = self.reasoning_config
|
||||||
else:
|
else:
|
||||||
|
|
@ -1199,6 +1198,10 @@ class AIAgent:
|
||||||
"effort": "xhigh"
|
"effort": "xhigh"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Nous Portal product attribution
|
||||||
|
if _is_nous:
|
||||||
|
extra_body["tags"] = ["product=hermes-agent"]
|
||||||
|
|
||||||
if extra_body:
|
if extra_body:
|
||||||
api_kwargs["extra_body"] = extra_body
|
api_kwargs["extra_body"] = extra_body
|
||||||
|
|
||||||
|
|
@ -1612,11 +1615,9 @@ class AIAgent:
|
||||||
api_messages.insert(sys_offset + idx, pfm.copy())
|
api_messages.insert(sys_offset + idx, pfm.copy())
|
||||||
|
|
||||||
summary_extra_body = {}
|
summary_extra_body = {}
|
||||||
_supports_reasoning = (
|
_is_openrouter = "openrouter" in self.base_url.lower()
|
||||||
"openrouter" in self.base_url.lower()
|
_is_nous = "nousresearch" in self.base_url.lower()
|
||||||
or "nousresearch" in self.base_url.lower()
|
if _is_openrouter or _is_nous:
|
||||||
)
|
|
||||||
if _supports_reasoning:
|
|
||||||
if self.reasoning_config is not None:
|
if self.reasoning_config is not None:
|
||||||
summary_extra_body["reasoning"] = self.reasoning_config
|
summary_extra_body["reasoning"] = self.reasoning_config
|
||||||
else:
|
else:
|
||||||
|
|
@ -1624,6 +1625,8 @@ class AIAgent:
|
||||||
"enabled": True,
|
"enabled": True,
|
||||||
"effort": "xhigh"
|
"effort": "xhigh"
|
||||||
}
|
}
|
||||||
|
if _is_nous:
|
||||||
|
summary_extra_body["tags"] = ["product=hermes-agent"]
|
||||||
|
|
||||||
summary_kwargs = {
|
summary_kwargs = {
|
||||||
"model": self.model,
|
"model": self.model,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue