inference: support reasoning effort for openrouter
This commit is contained in:
1 parent
5b75d95a8c
commit
bdd7f89663
2 files changed
+17
-2
No files matched your search
@@ -16,6 +16,10 @@ class ExpertAgent(Agent):
|
|||||||
AgentField('model', 'model_id', default=None),
|
AgentField('model', 'model_id', default=None),
|
||||||
AgentField('temperature', 'number', default=None),
|
AgentField('temperature', 'number', default=None),
|
||||||
AgentField('repetition_penalty', 'number', default=None),
|
AgentField('repetition_penalty', 'number', default=None),
|
||||||
|
AgentField('reasoning_effort', {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["none", "minimal", "low", "medium", "high", "xhigh", "max"]
|
||||||
|
}, default=None),
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
@@ -44,9 +48,12 @@ class ExpertAgent(Agent):
|
|||||||
if tools: run.input['tools'] = tools
|
if tools: run.input['tools'] = tools
|
||||||
|
|
||||||
if self.config.get("temperature") is not None:
|
if self.config.get("temperature") is not None:
|
||||||
opts["temperature"] = self.config["temperature"]
|
run.input["temperature"] = self.config["temperature"]
|
||||||
if self.config.get("repetition_penalty") is not None:
|
if self.config.get("repetition_penalty") is not None:
|
||||||
opts["repetition_penalty"] = self.config["repetition_penalty"]
|
run.input["repetition_penalty"] = self.config["repetition_penalty"]
|
||||||
|
if self.config.get("reasoning_effort") is not None:
|
||||||
|
run.input["reasoning_effort"] = self.config["reasoning_effort"]
|
||||||
|
|
||||||
|
|
||||||
# Build message list based on input
|
# Build message list based on input
|
||||||
messages = inference.build_messages(
|
messages = inference.build_messages(
|
||||||
|
|||||||
@@ -353,6 +353,14 @@ async def openrouter_chat_completion(app, messages, model, tools=[], opts={}, ag
|
|||||||
if formatted_tools:
|
if formatted_tools:
|
||||||
kwargs['tools'] = formatted_tools
|
kwargs['tools'] = formatted_tools
|
||||||
|
|
||||||
|
temp = agent_run.input.get("temperature")
|
||||||
|
if temp is not None:
|
||||||
|
kwargs['temperature'] = temp
|
||||||
|
|
||||||
|
reasoning = agent_run.input.get("reasoning_effort")
|
||||||
|
if reasoning is not None:
|
||||||
|
kwargs['reasoning'] = {"effort": reasoning}
|
||||||
|
|
||||||
stream_response = await app.openrouter_client.chat.send_async(**kwargs)
|
stream_response = await app.openrouter_client.chat.send_async(**kwargs)
|
||||||
|
|
||||||
# OpenAI format streams tool calls in parts
|
# OpenAI format streams tool calls in parts
|
||||||
|
|||||||
Reference in new issue
Block a user