Python: openai updates (#388)

* openai updates

* rebuild of openai structure

* updated responses structure

* renamed sample

* added file id support to code interpreter

* added hosted file ids to code interpretor

* mypy fixes

* removed default az cred from codebase

* updated agent name setup

* added kwargs to entra methods

* and further kwargs

* extra comment

* updated all samples

* readded custom get methods for responses

* updated int tests with ad credential

* missed one
This commit is contained in:
Eduard van Valkenburg
2025-08-12 08:14:22 +02:00
committed by GitHub
Unverified
parent 19676978e9
commit df9d85d1f0
53 changed files with 1668 additions and 1470 deletions
@@ -381,6 +381,8 @@ class ChatClientAgent(AgentBase):
kwargs: any additional keyword arguments.
Unused, can be used by subclasses of this Agent.
"""
kwargs.update(additional_properties or {})
args: dict[str, Any] = {
"chat_client": chat_client,
"chat_options": ChatOptions(
@@ -399,7 +401,7 @@ class ChatClientAgent(AgentBase):
tools=tools, # type: ignore
top_p=top_p,
user=user,
additional_properties=additional_properties or {},
additional_properties=kwargs,
),
}
if instructions is not None:
@@ -412,6 +414,7 @@ class ChatClientAgent(AgentBase):
args["id"] = id
super().__init__(**args)
self._update_agent_name()
async def __aenter__(self) -> "Self":
"""Async context manager entry.
@@ -430,6 +433,16 @@ class ChatClientAgent(AgentBase):
if isinstance(self.chat_client, AbstractAsyncContextManager):
await self.chat_client.__aexit__(exc_type, exc_val, exc_tb) # type: ignore[reportUnknownMemberType]
def _update_agent_name(self) -> None:
"""Update the agent name in a chat client.
Checks if there is a agent name, the implementation
should check if there is already a agent name defined, and if not
set it to this value.
"""
if hasattr(self.chat_client, "_update_agent_name") and callable(self.chat_client._update_agent_name): # type: ignore[reportAttributeAccessIssue]
self.chat_client._update_agent_name(self.name) # type: ignore[reportAttributeAccessIssue]
async def run(
self,
messages: str | ChatMessage | list[str] | list[ChatMessage] | None = None,