Skip to content
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

Cloud Machine and Azure AI Project integration #47933

Merged
merged 10 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from 9 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
8 changes: 5 additions & 3 deletions eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@
<PackageReference Update="Microsoft.CSharp" Version="4.7.0" />

<!-- Azure SDK packages -->
<PackageReference Update="Azure.AI.Inference" Version="1.0.0-beta.2" />
<PackageReference Update="Azure.AI.OpenAI" Version="2.0.0" />
<PackageReference Update="Azure.AI.Projects" Version="1.0.0-beta.2" />
<PackageReference Update="Azure.Communication.Identity" Version="1.3.1" />
<PackageReference Update="Azure.Communication.Common" Version="1.3.0" />
<PackageReference Update="Azure.Core" Version="1.44.1" />
Expand All @@ -128,8 +131,7 @@
<PackageReference Update="Azure.Storage.Blobs" Version="12.21.1" />
<PackageReference Update="Azure.Storage.Queues" Version="12.19.1" />
<PackageReference Update="Azure.Storage.Files.Shares" Version="12.19.1" />
<PackageReference Update="Azure.AI.Inference" Version="1.0.0-beta.2" />
<PackageReference Update="Azure.AI.OpenAI" Version="2.0.0" />
<PackageReference Update="Azure.Search.Documents" Version="11.6.0" />
<PackageReference Update="Azure.ResourceManager" Version="1.13.0" />
<PackageReference Update="Azure.ResourceManager.AppConfiguration" Version="1.3.2" />
<PackageReference Update="Azure.ResourceManager.ApplicationInsights" Version="1.0.0" />
Expand Down Expand Up @@ -286,7 +288,7 @@
<PackageReference Update="Azure.ResourceManager.ExtendedLocations" Version="1.1.0-beta.1" />
<PackageReference Update="Azure.ResourceManager.EventHubs" Version="1.2.0-beta.1" />
<PackageReference Update="Azure.ResourceManager.ContainerRegistry" Version="1.3.0-beta.1" />
<PackageReference Update="Azure.Search.Documents" Version="11.2.0" />
<PackageReference Update="Azure.Search.Documents" Version="11.6.0" />
<PackageReference Update="Azure.Security.KeyVault.Keys" Version="4.6.0" />
<PackageReference Update="Azure.Security.KeyVault.Secrets" Version="4.6.0" />
<PackageReference Update="Azure.Storage.Blobs" Version="12.20.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public static void Add(this System.Collections.Generic.List<OpenAI.Chat.ChatMess
public static string AsText(this OpenAI.Chat.ChatCompletion completion) { throw null; }
public static string AsText(this OpenAI.Chat.ChatMessageContent content) { throw null; }
public static string AsText(this System.ClientModel.ClientResult<OpenAI.Chat.ChatCompletion> completionResult) { throw null; }
public static OpenAI.Chat.ChatClient GetOpenAIChatClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
public static OpenAI.Embeddings.EmbeddingClient GetOpenAIEmbeddingsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
public static OpenAI.Chat.ChatClient GetOpenAIChatClient(this Azure.Core.ClientWorkspace workspace, string? deploymentName = null) { throw null; }
public static OpenAI.Embeddings.EmbeddingClient GetOpenAIEmbeddingsClient(this Azure.Core.ClientWorkspace workspace, string? deploymentName = null) { throw null; }
public static void Trim(this System.Collections.Generic.List<OpenAI.Chat.ChatMessage> messages) { }
}
public partial class ChatTools
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public static void Add(this System.Collections.Generic.List<OpenAI.Chat.ChatMess
public static string AsText(this OpenAI.Chat.ChatCompletion completion) { throw null; }
public static string AsText(this OpenAI.Chat.ChatMessageContent content) { throw null; }
public static string AsText(this System.ClientModel.ClientResult<OpenAI.Chat.ChatCompletion> completionResult) { throw null; }
public static OpenAI.Chat.ChatClient GetOpenAIChatClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
public static OpenAI.Embeddings.EmbeddingClient GetOpenAIEmbeddingsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
public static OpenAI.Chat.ChatClient GetOpenAIChatClient(this Azure.Core.ClientWorkspace workspace, string? deploymentName = null) { throw null; }
public static OpenAI.Embeddings.EmbeddingClient GetOpenAIEmbeddingsClient(this Azure.Core.ClientWorkspace workspace, string? deploymentName = null) { throw null; }
public static void Trim(this System.Collections.Generic.List<OpenAI.Chat.ChatMessage> messages) { }
}
public partial class ChatTools
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ public static class AzureOpenAIExtensions
/// Gets the OpenAI chat client.
/// </summary>
/// <param name="workspace"></param>
/// <param name="deploymentName"></param>
/// <returns></returns>
public static ChatClient GetOpenAIChatClient(this ClientWorkspace workspace)
public static ChatClient GetOpenAIChatClient(this ClientWorkspace workspace, string? deploymentName = null)
{
string name = deploymentName ?? "default";

ChatClient chatClient = workspace.Subclients.Get(() =>
{
AzureOpenAIClient aoiaClient = workspace.Subclients.Get(() => CreateAzureOpenAIClient(workspace));
return workspace.CreateChatClient(aoiaClient);
});
return workspace.CreateChatClient(aoiaClient, deploymentName);
}, name);

return chatClient;
}
Expand All @@ -36,14 +39,17 @@ public static ChatClient GetOpenAIChatClient(this ClientWorkspace workspace)
/// Gets the OpenAI embeddings client.
/// </summary>
/// <param name="workspace"></param>
/// <param name="deploymentName"></param>
/// <returns></returns>
public static EmbeddingClient GetOpenAIEmbeddingsClient(this ClientWorkspace workspace)
public static EmbeddingClient GetOpenAIEmbeddingsClient(this ClientWorkspace workspace, string? deploymentName = null)
{
string name = deploymentName ?? "default";

EmbeddingClient embeddingsClient = workspace.Subclients.Get(() =>
{
AzureOpenAIClient aoiaClient = workspace.Subclients.Get(() => CreateAzureOpenAIClient(workspace));
return workspace.CreateEmbeddingsClient(aoiaClient);
});
return workspace.CreateEmbeddingsClient(aoiaClient, deploymentName);
}, name);

return embeddingsClient;
}
Expand Down Expand Up @@ -99,17 +105,17 @@ private static AzureOpenAIClient CreateAzureOpenAIClient(this ClientWorkspace wo
}
}

private static ChatClient CreateChatClient(this ClientWorkspace workspace, AzureOpenAIClient client)
private static ChatClient CreateChatClient(this ClientWorkspace workspace, AzureOpenAIClient client, string? deploymentName = null)
{
ClientConnection connection = workspace.GetConnectionOptions(typeof(ChatClient).FullName);
ChatClient chat = client.GetChatClient(connection.Locator);
ChatClient chat = client.GetChatClient(deploymentName ?? connection.Locator);
return chat;
}

private static EmbeddingClient CreateEmbeddingsClient(this ClientWorkspace workspace, AzureOpenAIClient client)
private static EmbeddingClient CreateEmbeddingsClient(this ClientWorkspace workspace, AzureOpenAIClient client, string? deploymentName = null)
{
ClientConnection connection = workspace.GetConnectionOptions(typeof(EmbeddingClient).FullName);
EmbeddingClient embeddings = client.GetEmbeddingClient(connection.Locator);
EmbeddingClient embeddings = client.GetEmbeddingClient(deploymentName ?? connection.Locator);
return embeddings;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
namespace Azure.CloudMachine
{
public partial class AIFoundryClient : Azure.Core.ClientWorkspace
{
protected AIFoundryClient() : base (default(Azure.Core.TokenCredential)) { }
public AIFoundryClient(string connectionString, Azure.Core.TokenCredential credential = null) : base (default(Azure.Core.TokenCredential)) { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public Azure.Core.ConnectionCollection Connections { get { throw null; } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object obj) { throw null; }
public override System.Collections.Generic.IEnumerable<Azure.Core.ClientConnection> GetAllConnectionOptions() { throw null; }
public override Azure.Core.ClientConnection GetConnectionOptions(string connectionId) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override int GetHashCode() { throw null; }
}
public static partial class AzureAIProjectsExensions
{
public static Azure.AI.Projects.AgentsClient GetAgentsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
public static Azure.AI.Inference.ChatCompletionsClient GetChatCompletionsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
public static Azure.AI.Inference.EmbeddingsClient GetEmbeddingsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
public static Azure.AI.Projects.EvaluationsClient GetEvaluationsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
public static Azure.Search.Documents.SearchClient GetSearchClient(this Azure.Core.ClientWorkspace workspace, string indexName) { throw null; }
public static Azure.Search.Documents.Indexes.SearchIndexClient GetSearchIndexClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
public static Azure.Search.Documents.Indexes.SearchIndexerClient GetSearchIndexerClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
}
public partial class CloudMachineClient : Azure.Core.ClientWorkspace
{
protected CloudMachineClient() : base (default(Azure.Core.TokenCredential)) { }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
namespace Azure.CloudMachine
{
public partial class AIFoundryClient : Azure.Core.ClientWorkspace
{
protected AIFoundryClient() : base (default(Azure.Core.TokenCredential)) { }
public AIFoundryClient(string connectionString, Azure.Core.TokenCredential credential = null) : base (default(Azure.Core.TokenCredential)) { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public Azure.Core.ConnectionCollection Connections { get { throw null; } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object obj) { throw null; }
public override System.Collections.Generic.IEnumerable<Azure.Core.ClientConnection> GetAllConnectionOptions() { throw null; }
public override Azure.Core.ClientConnection GetConnectionOptions(string connectionId) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override int GetHashCode() { throw null; }
}
public static partial class AzureAIProjectsExensions
{
public static Azure.AI.Projects.AgentsClient GetAgentsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
public static Azure.AI.Inference.ChatCompletionsClient GetChatCompletionsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
public static Azure.AI.Inference.EmbeddingsClient GetEmbeddingsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
public static Azure.AI.Projects.EvaluationsClient GetEvaluationsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
public static Azure.Search.Documents.SearchClient GetSearchClient(this Azure.Core.ClientWorkspace workspace, string indexName) { throw null; }
public static Azure.Search.Documents.Indexes.SearchIndexClient GetSearchIndexClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
public static Azure.Search.Documents.Indexes.SearchIndexerClient GetSearchIndexerClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
}
public partial class CloudMachineClient : Azure.Core.ClientWorkspace
{
protected CloudMachineClient() : base (default(Azure.Core.TokenCredential)) { }
Expand Down
Loading