Skip to content

Added IChatClient implementation for PersistentAgentsClient #50898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@
<PackageReference Update="NUnit" Version="3.13.2" />
</ItemGroup>

<ItemGroup Condition="$(MSBuildProjectName.Contains('Azure.AI.Agents.Persistent'))">
<PackageReference Update="Microsoft.Extensions.AI.Abstractions" Version="9.6.0"/>
</ItemGroup>

<ItemGroup Condition="$(MSBuildProjectName.Contains('Azure.Projects'))">
<PackageReference Update="Azure.Data.AppConfiguration" Version="1.6.0"/>
<PackageReference Update="Azure.Provisioning.Deployment" Version="1.0.0-beta.2"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,10 @@ public PersistentAgentsClient(string endpoint, Azure.Core.TokenCredential creden
public virtual Azure.Response<Azure.AI.Agents.Persistent.ThreadRun> CreateThreadAndRun(string assistantId, Azure.AI.Agents.Persistent.ThreadAndRunOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.Agents.Persistent.ThreadRun>> CreateThreadAndRunAsync(string assistantId, Azure.AI.Agents.Persistent.ThreadAndRunOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
public static partial class PersistentAgentsClientExtensions
{
public static Microsoft.Extensions.AI.IChatClient AsIChatClient(this Azure.AI.Agents.Persistent.PersistentAgentsClient client, string agentId, string? defaultThreadId = null) { throw null; }
}
public static partial class PersistentAgentsExtensions
{
public static Azure.AI.Agents.Persistent.PersistentAgentsClient GetPersistentAgentsClient(this System.ClientModel.Primitives.ClientConnectionProvider provider) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,10 @@ public PersistentAgentsClient(string endpoint, Azure.Core.TokenCredential creden
public virtual Azure.Response<Azure.AI.Agents.Persistent.ThreadRun> CreateThreadAndRun(string assistantId, Azure.AI.Agents.Persistent.ThreadAndRunOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.Agents.Persistent.ThreadRun>> CreateThreadAndRunAsync(string assistantId, Azure.AI.Agents.Persistent.ThreadAndRunOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
public static partial class PersistentAgentsClientExtensions
{
public static Microsoft.Extensions.AI.IChatClient AsIChatClient(this Azure.AI.Agents.Persistent.PersistentAgentsClient client, string agentId, string? defaultThreadId = null) { throw null; }
}
public static partial class PersistentAgentsExtensions
{
public static Azure.AI.Agents.Persistent.PersistentAgentsClient GetPersistentAgentsClient(this System.ClientModel.Primitives.ClientConnectionProvider provider) { throw null; }
Expand Down
2 changes: 1 addition & 1 deletion sdk/ai/Azure.AI.Agents.Persistent/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/ai/Azure.AI.Agents.Persistent",
"Tag": "net/ai/Azure.AI.Agents.Persistent_f7ce2c53dc"
"Tag": "net/ai/Azure.AI.Agents.Persistent_44b68ac951"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

<ItemGroup>
<PackageReference Include="Azure.Core" />
<PackageReference Include="Microsoft.Extensions.AI.Abstractions" />
</ItemGroup>

<!-- Shared source from Azure.Core -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ namespace Azure.AI.Agents.Persistent
public partial class PersistentAgentsAdministrationClient
{
private static readonly bool s_is_test_run = AppContextSwitchHelper.GetConfigValue(
PersistantAgensConstants.UseOldConnectionString,
PersistantAgensConstants.UseOldConnectionStringEnvVar);
PersistentAgentsConstants.UseOldConnectionString,
PersistentAgentsConstants.UseOldConnectionStringEnvVar);
/// <summary> The ClientDiagnostics is used to provide tracing support for the client library. </summary>
internal virtual ClientDiagnostics ClientDiagnostics { get; }
// TODO: Replace project connections string by PROJECT_ENDPOINT when 1DP will be available.
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#nullable enable

using Microsoft.Extensions.AI;

namespace Azure.AI.Agents.Persistent
{
/// <summary>
/// Provides extension methods for <see cref="PersistentAgentsClient"/>.
/// </summary>
public static class PersistentAgentsClientExtensions
{
/// <summary>
/// Creates an <see cref="IChatClient"/> for a <see cref="PersistentAgentsClient"/> client for interacting with a specific agent.
/// </summary>
/// <param name="client">The <see cref="PersistentAgentsClient"/> instance to be accessed as an <see cref="IChatClient"/>.</param>
/// <param name="agentId">The unique identifier of the agent with which to interact.</param>
/// <param name="defaultThreadId">
/// An optional existing thread identifier for the chat session. This serves as a default, and may be overridden per call to
/// <see cref="IChatClient.GetResponseAsync"/> or <see cref="IChatClient.GetStreamingResponseAsync"/> via the <see cref="ChatOptions.ConversationId"/>
/// property. If no thread ID is provided via either mechanism, a new thread will be created for the request.
/// </param>
/// <returns>An <see cref="IChatClient"/> instance configured to interact with the specified agent and thread.</returns>
public static IChatClient AsIChatClient(this PersistentAgentsClient client, string agentId, string? defaultThreadId = null) =>
new PersistentAgentsChatClient(client, agentId, defaultThreadId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Azure.AI.Agents.Persistent
{
internal class PersistantAgensConstants
internal class PersistentAgentsConstants
{
public const string UseOldConnectionString = "Azure.AI.Agents.Persistent.Internal.UseConnectionString";
public const string UseOldConnectionStringEnvVar = "_IS_TEST_RUN";
Expand Down
Loading