pass extrabody for agentloop to ban and allowlist providers on openrouter, control thinking, etc
This commit is contained in:
parent
abe925e212
commit
389ac5e017
1 changed files with 10 additions and 0 deletions
|
|
@ -135,6 +135,7 @@ class HermesAgentLoop:
|
||||||
task_id: Optional[str] = None,
|
task_id: Optional[str] = None,
|
||||||
temperature: float = 1.0,
|
temperature: float = 1.0,
|
||||||
max_tokens: Optional[int] = None,
|
max_tokens: Optional[int] = None,
|
||||||
|
extra_body: Optional[Dict[str, Any]] = None,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Initialize the agent loop.
|
Initialize the agent loop.
|
||||||
|
|
@ -148,6 +149,9 @@ class HermesAgentLoop:
|
||||||
task_id: Unique ID for terminal/browser session isolation
|
task_id: Unique ID for terminal/browser session isolation
|
||||||
temperature: Sampling temperature for generation
|
temperature: Sampling temperature for generation
|
||||||
max_tokens: Max tokens per generation (None for server default)
|
max_tokens: Max tokens per generation (None for server default)
|
||||||
|
extra_body: Extra parameters passed to the OpenAI client's create() call.
|
||||||
|
Used for OpenRouter provider preferences, transforms, etc.
|
||||||
|
e.g. {"provider": {"ignore": ["DeepInfra"]}}
|
||||||
"""
|
"""
|
||||||
self.server = server
|
self.server = server
|
||||||
self.tool_schemas = tool_schemas
|
self.tool_schemas = tool_schemas
|
||||||
|
|
@ -156,6 +160,7 @@ class HermesAgentLoop:
|
||||||
self.task_id = task_id or str(uuid.uuid4())
|
self.task_id = task_id or str(uuid.uuid4())
|
||||||
self.temperature = temperature
|
self.temperature = temperature
|
||||||
self.max_tokens = max_tokens
|
self.max_tokens = max_tokens
|
||||||
|
self.extra_body = extra_body
|
||||||
|
|
||||||
async def run(self, messages: List[Dict[str, Any]]) -> AgentResult:
|
async def run(self, messages: List[Dict[str, Any]]) -> AgentResult:
|
||||||
"""
|
"""
|
||||||
|
|
@ -191,6 +196,11 @@ class HermesAgentLoop:
|
||||||
if self.max_tokens is not None:
|
if self.max_tokens is not None:
|
||||||
chat_kwargs["max_tokens"] = self.max_tokens
|
chat_kwargs["max_tokens"] = self.max_tokens
|
||||||
|
|
||||||
|
# Inject extra_body for provider-specific params (e.g., OpenRouter
|
||||||
|
# provider preferences like banned/preferred providers, transforms)
|
||||||
|
if self.extra_body:
|
||||||
|
chat_kwargs["extra_body"] = self.extra_body
|
||||||
|
|
||||||
# Make the API call -- standard OpenAI spec
|
# Make the API call -- standard OpenAI spec
|
||||||
api_start = _time.monotonic()
|
api_start = _time.monotonic()
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue