.NET: Update M.A.AI.OpenAI implementations (#1018)

* Update M.A.AI.OpenAI implementations

- There was only a ChatClient-based agent. Add a Responses one, too.
- Fix the public extension methods to create OpenAI types even when not backed by the right OpenAI client.
- Add reusable AgentRunResponse{Update} to ChatResponse{Update} conversion routines that are then used by the OpenAI agents and elsewhere

* Address feedback
This commit is contained in:
Stephen Toub
2025-09-30 15:06:10 -04:00
committed by GitHub
Unverified
parent 8dad045c9d
commit 2d20e644df
11 changed files with 275 additions and 184 deletions
@@ -72,19 +72,7 @@ internal sealed class MessageMerger
throw new InvalidOperationException($"No updates found for message ID '{messageId}' in response '{this.ResponseId}'.");
}
return updates.Select(oldUpdate =>
oldUpdate.RawRepresentation as ChatResponseUpdate ??
new()
{
AdditionalProperties = oldUpdate.AdditionalProperties,
AuthorName = oldUpdate.AuthorName,
Contents = oldUpdate.Contents,
CreatedAt = oldUpdate.CreatedAt,
MessageId = oldUpdate.MessageId,
RawRepresentation = oldUpdate.RawRepresentation,
Role = oldUpdate.Role,
ResponseId = oldUpdate.ResponseId,
}).ToChatResponse().Messages;
return updates.Select(oldUpdate => oldUpdate.AsChatResponseUpdate()).ToChatResponse().Messages;
}
}
}