Skip to content

Python: Not all OpenAI-like endpoints accept system messages with content of a list #1407

Description

@pamelafox

I am trying to use agent-framework with a NIM model (from NVIDIA - following this tutorial: https://learn.microsoft.com/en-us/azure/container-apps/serverless-gpu-nim?tabs=bash)

Unfortunately, I get an immediate error:

agent_framework.exceptions.ServiceResponseException: <class 'agent_framework.openai._chat_client.OpenAIChatClient'> service failed to complete the prompt: Error code: 400 - {'error': {'message': '[{'type': 'value_error', 'loc': ('body', 'messages', 0), 'msg': 'Value error, Message content as a list is only supported for user messages.', 'input': {'role': 'system', 'content': [{'type': 'text', 'text': "You're an informational agent. Answer questions cheerfully.\n"}]}, 'ctx': {'error': ValueError('Message content as a list is only supported for user messages.')}}, {'type': 'value_error', 'loc': ('body', 'messages', 1), 'msg': 'Value error, Message content as a list is only supported for user messages.', 'input': {'role': 'system', 'content': [{'type': 'text', 'text': "You're an informational agent. Answer questions cheerfully.\n"}]}, 'ctx': {'error': ValueError('Message content as a list is only supported for user messages.')}}]', 'type': 'BadRequestError', 'param': None, 'code': 400}}

It appears that agent-framework sends the system message using a list of contents, and this OpenAI-like chat completions server doesn't support it.
Is there some possibility to avoid that? I would love to use agent-framework with NIM. Thanks!

Metadata

Metadata

Labels

agentsUsage: [Issues, PRs], Target: Single agentpythonUsage: [Issues, PRs], Target: Python

Type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions