You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I plan to use openrouter with autogen given it provides openai api compatible models. I am able to run openai using openrouter. however, if i try to run claude or gemini, i run into this:
ValidationError: 1 validation error for CreateResult
finish_reason
Input should be 'stop', 'length', 'function_calls' or 'content_filter' [type=literal_error, input_value='end_turn', input_type=str]
For further information visit https://errors.pydantic.dev/2.10/v/literal_error
What did you expect to happen?
I expect a way to easily specify stop reasons and map them to openai standard ones so that we can use any model whose request schema is compatible to openai but response schema may not be.
How can we reproduce it (as minimally and precisely as possible)?
Result:
ValidationError: 1 validation error for CreateResult
finish_reason
Input should be 'stop', 'length', 'function_calls' or 'content_filter' [type=literal_error, input_value='end_turn', input_type=str]
For further information visit https://errors.pydantic.dev/2.10/v/literal_error
Works well when i change "config = config_list[1]" to "config = config_list[0]" ie. use openai
AutoGen version
0.4
Which package was this bug in
AgentChat
Model used
claude
Python version
3.12
Operating system
No response
Any additional info you think would be helpful for fixing this bug
I believe there should be a way to map response keys from non-openai models in "CreateResult" so that they can be used
The text was updated successfully, but these errors were encountered:
@ravishqureshi thanks for the Issue. I believe the stop_reason should allow arbitrary text rather than a Literal for non-OpenAI clients. It's not really meaningful to keep the stop reason a fixed set.
What happened?
I plan to use openrouter with autogen given it provides openai api compatible models. I am able to run openai using openrouter. however, if i try to run claude or gemini, i run into this:
ValidationError: 1 validation error for CreateResult
finish_reason
Input should be 'stop', 'length', 'function_calls' or 'content_filter' [type=literal_error, input_value='end_turn', input_type=str]
For further information visit https://errors.pydantic.dev/2.10/v/literal_error
What did you expect to happen?
I expect a way to easily specify stop reasons and map them to openai standard ones so that we can use any model whose request schema is compatible to openai but response schema may not be.
How can we reproduce it (as minimally and precisely as possible)?
config_list=[
{
"model": "openai/gpt-4o",
"base_url": "https://openrouter.ai/api/v1",
"api_key": openrouter_key,
"api_type": "openai",
"model_info": {
"vision": True,
"function_calling": True,
"json_output": False
}
},
{
"model": "anthropic/claude-3.5-sonnet",
"base_url": "https://openrouter.ai/api/v1",
"api_key": openrouter_key,
"api_type": "anthropic",
"model_info": {
"vision": True,
"function_calling": True,
"json_output": False
}
}
]
config = config_list[1] # Use the openai model config
Extract relevant parameters
model = config["model"]
api_key = config["api_key"]
base_url = config["base_url"]
model_info=config.get("model_info", {})
api_type = config["api_type"]
Initialize the OpenRouterClient
model_client = OpenAIChatCompletionClient(
model=model,
api_key=api_key,
base_url=base_url,
model_info=model_info,
api_type=api_type
)
from autogen_agentchat.agents import AssistantAgent
Initialize the AssistantAgent
agent = AssistantAgent(
name="assistant",
model_client=model_client,
system_message="You are a helpful assistant skilled in multimodal tasks."
)
from autogen_core.models import UserMessage
Run the task with the pre-constructed messages
response = await run_task(agent, agentchat_messages)
print(response)
Result:
ValidationError: 1 validation error for CreateResult
finish_reason
Input should be 'stop', 'length', 'function_calls' or 'content_filter' [type=literal_error, input_value='end_turn', input_type=str]
For further information visit https://errors.pydantic.dev/2.10/v/literal_error
Works well when i change "config = config_list[1]" to "config = config_list[0]" ie. use openai
AutoGen version
0.4
Which package was this bug in
AgentChat
Model used
claude
Python version
3.12
Operating system
No response
Any additional info you think would be helpful for fixing this bug
I believe there should be a way to map response keys from non-openai models in "CreateResult" so that they can be used
The text was updated successfully, but these errors were encountered: