Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Python: Support OpenAI message "name" field #2951

Description

@gdhuang

Background
The Python SDK does not currently map the ChatMessage.author_name field to OpenAI's optional "name" field when sending messages to the OpenAI completion API.
This field is useful for identifying different participants in conversations.

Current Behavior
In the Python implementation, the ChatMessage class has an author_name attribute.
However, when converting messages to OpenAI format in _openai_chat_message_parser(), the author_name is not included:
File: python/packages/core/agent_framework/openai/_chat_client.py:364-393

Expected Behavior

The author_name should be mapped to OpenAI's "name" field when present, similar to how the .NET implementation handles it.

string? name = SanitizeAuthorName(input.AuthorName);

File: https://github.com/dotnet/extensions/blob/main/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIChatClient.cs:158

Metadata

Metadata

Labels

pythonUsage: [Issues, PRs], Target: Python

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions