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
As it stands, using the OpenAI library with OpenAI-like endpoints will trigger an error related to the unsupported "developer" role. Since most models use "system" for roles, we should allow custom role mappings to avoid such errors.
Steps to Reproduce
Configure 03_agent_with_knowledge.py to use a different base url and model.
Execute:
(agno) (agno-env) alberto@barrahome:~/Projects/agno$ python cookbook/getting_started/03_agent_with_knowledge.py
INFO Loading knowledge base
INFO Reading: .............
INFO Skipped 2 existing/duplicate documents.
INFO Added 0 documents to knowledge base
ERROR API status error from OpenAI API: Error code: 400 - {'object': 'error', 'message': '1 validation error for ChatCompletionRequest\nmessages.0\n Input tag \'developer\'
found using \'role\' does not match any of the expected tags: <Roles.system: \'system\'>, <Roles.user: \'user\'>, <Roles.assistant: \'assistant\'>, <Roles.tool: \'tool\'>
[type=union_tag_invalid, input_value={\'content\': "<instruction...>", \'role\': \'developer\'}, input_type=dict]\n For further information visit
https://errors.pydantic.dev/2.10/v/union_tag_invalid', 'type': 'BadRequestError', 'param': None, 'code': 400}
▰▰▱▱▱▱▱ Thinking...
agent=Agent(
model=OpenAIChat(
id="mistralai/Mistral-Small-24B-Instruct-2501",
base_url="https://...../v1",
api_key="......",
role_map={
"system": "system", # Maps internal "system" role to API's "system" role"user": "user", # Maps internal "user" role to API's "user" role"assistant": "assistant", # Maps internal "assistant" role to API's "assistant" role"tool": "tool", # Maps internal "tool" role to API's "tool" role"model": "assistant", # Maps internal "model" role to API's "assistant" role"developer": "system", # Maps "developer" role to "system" role in the API"expert": "assistant"# Maps "expert" role to "assistant" role in the API
}
),
Additional Context
No response
The text was updated successfully, but these errors were encountered:
Description
As it stands, using the OpenAI library with OpenAI-like endpoints will trigger an error related to the unsupported "developer" role. Since most models use "system" for roles, we should allow custom role mappings to avoid such errors.
Steps to Reproduce
Agent Configuration (if applicable)
Possible Solutions (optional)
Implement a custom role if not present then fallback to default, IE:
libs/agno/agno/models/openai/chat.py
Replace role_map with something like:
Then on the
_format_message
we implement the following:Then when we do the call:
Additional Context
No response
The text was updated successfully, but these errors were encountered: