mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
.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:
committed by
GitHub
Unverified
parent
8dad045c9d
commit
2d20e644df
+3
-6
@@ -3,7 +3,7 @@
|
||||
using System.ClientModel;
|
||||
using OpenAI.Chat;
|
||||
|
||||
namespace Microsoft.Agents.AI.OpenAI.ChatClient;
|
||||
namespace Microsoft.Agents.AI.OpenAI;
|
||||
|
||||
internal sealed class AsyncStreamingUpdateCollectionResult : AsyncCollectionResult<StreamingChatCompletionUpdate>
|
||||
{
|
||||
@@ -19,13 +19,10 @@ internal sealed class AsyncStreamingUpdateCollectionResult : AsyncCollectionResu
|
||||
public override IAsyncEnumerable<ClientResult> GetRawPagesAsync() =>
|
||||
AsyncEnumerable.Repeat(ClientResult.FromValue(this._updates, new StreamingUpdatePipelineResponse(this._updates)), 1);
|
||||
|
||||
protected override async IAsyncEnumerable<StreamingChatCompletionUpdate> GetValuesFromPageAsync(ClientResult page)
|
||||
protected override IAsyncEnumerable<StreamingChatCompletionUpdate> GetValuesFromPageAsync(ClientResult page)
|
||||
{
|
||||
var updates = ((ClientResult<IAsyncEnumerable<AgentRunResponseUpdate>>)page).Value;
|
||||
|
||||
await foreach (var update in updates.ConfigureAwait(false))
|
||||
{
|
||||
yield return update.AsStreamingChatCompletionUpdate();
|
||||
}
|
||||
return updates.AsChatResponseUpdatesAsync().AsOpenAIStreamingChatCompletionUpdatesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
using System.ClientModel.Primitives;
|
||||
|
||||
namespace Microsoft.Agents.AI.OpenAI.ChatClient;
|
||||
namespace Microsoft.Agents.AI.OpenAI;
|
||||
|
||||
internal sealed class StreamingUpdatePipelineResponse : PipelineResponse
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user