Rename AI Agent packages to use Microsoft.Agents.AI (#913)

* Rename AI Agent packages to use Microsoft.Agents.AI

* Fix for build

* Fix formatting

* Fix formatting

* Ignore in VSTHRD200 in migration samples

* Ignore in VSTHRD200 in migration samples

* Add some missing projects and run format

* Fix build errors

* Address code review feedback

* Fix merge issues

---------

Co-authored-by: Mark Wallace <markwallace@microsoft.com>
This commit is contained in:
Mark Wallace
2025-09-25 20:31:25 +01:00
committed by GitHub
Unverified
parent a480ccfd16
commit 32e054f1fe
332 changed files with 520 additions and 432 deletions
@@ -0,0 +1,31 @@
// Copyright (c) Microsoft. All rights reserved.
using System.ClientModel;
using OpenAI.Chat;
namespace Microsoft.Agents.AI.OpenAI.ChatClient;
internal sealed class AsyncStreamingUpdateCollectionResult : AsyncCollectionResult<StreamingChatCompletionUpdate>
{
private readonly IAsyncEnumerable<AgentRunResponseUpdate> _updates;
internal AsyncStreamingUpdateCollectionResult(IAsyncEnumerable<AgentRunResponseUpdate> updates)
{
this._updates = updates;
}
public override ContinuationToken? GetContinuationToken(ClientResult page) => null;
public override IAsyncEnumerable<ClientResult> GetRawPagesAsync() =>
AsyncEnumerable.Repeat(ClientResult.FromValue(this._updates, new StreamingUpdatePipelineResponse(this._updates)), 1);
protected override async IAsyncEnumerable<StreamingChatCompletionUpdate> GetValuesFromPageAsync(ClientResult page)
{
var updates = ((ClientResult<IAsyncEnumerable<AgentRunResponseUpdate>>)page).Value;
await foreach (var update in updates.ConfigureAwait(false))
{
yield return update.AsStreamingChatCompletionUpdate();
}
}
}
@@ -0,0 +1,79 @@
// Copyright (c) Microsoft. All rights reserved.
using System.ClientModel.Primitives;
namespace Microsoft.Agents.AI.OpenAI.ChatClient;
internal sealed class StreamingUpdatePipelineResponse : PipelineResponse
{
/// <summary>
/// Gets the HTTP status code. For streaming responses, this is typically 200.
/// </summary>
public override int Status => 200;
/// <summary>
/// Gets the reason phrase. For streaming responses, this is typically "OK".
/// </summary>
public override string ReasonPhrase => "OK";
/// <summary>
/// Streaming responses do not support direct content stream access.
/// </summary>
public override Stream? ContentStream
{
get => null;
set { /* no-op */ }
}
/// <summary>
/// Streaming responses do not support direct content access.
/// </summary>
public override BinaryData Content => BinaryData.FromString(string.Empty);
/// <summary>
/// Streaming responses do not have headers.
/// </summary>
protected override PipelineResponseHeaders HeadersCore => new EmptyPipelineResponseHeaders();
/// <summary>
/// Buffering content is not supported for streaming responses.
/// </summary>
public override BinaryData BufferContent(CancellationToken cancellationToken = default) =>
throw new NotSupportedException("Buffering content is not supported for streaming responses.");
/// <summary>
/// Buffering content asynchronously is not supported for streaming responses.
/// </summary>
public override ValueTask<BinaryData> BufferContentAsync(CancellationToken cancellationToken = default) =>
throw new NotSupportedException("Buffering content asynchronously is not supported for streaming responses.");
/// <summary>
/// Disposes resources. No resources to dispose for streaming response.
/// </summary>
public override void Dispose()
{
// No resources to dispose.
}
internal StreamingUpdatePipelineResponse(IAsyncEnumerable<AgentRunResponseUpdate> updates)
{
}
private sealed class EmptyPipelineResponseHeaders : PipelineResponseHeaders
{
public override bool TryGetValue(string name, out string? value)
{
value = null;
return false;
}
public override bool TryGetValues(string name, out IEnumerable<string>? values)
{
values = null;
return false;
}
public override IEnumerator<KeyValuePair<string, string>> GetEnumerator()
{
yield break;
}
}
}