Skip to content

Commit 0d9775f

Browse files
authored
Cloud Machine and Azure AI Project integration (Azure#47933)
Cloud Machine and Azure AI Project integration
1 parent 0eb66bb commit 0d9775f

12 files changed

+628
-17
lines changed

eng/Packages.Data.props

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@
106106
<PackageReference Update="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0"/>
107107

108108
<!-- Azure SDK packages -->
109+
<PackageReference Update="Azure.AI.Inference" Version="1.0.0-beta.2" />
110+
<PackageReference Update="Azure.AI.OpenAI" Version="2.0.0" />
111+
<PackageReference Update="Azure.AI.Projects" Version="1.0.0-beta.2" />
109112
<PackageReference Update="Azure.Communication.Identity" Version="1.3.1" />
110113
<PackageReference Update="Azure.Communication.Common" Version="1.3.0" />
111114
<PackageReference Update="Azure.Core" Version="1.44.1" />
@@ -122,15 +125,14 @@
122125
<PackageReference Update="Azure.Monitor.OpenTelemetry.Exporter" Version="1.4.0-beta.2" />
123126
<PackageReference Update="Azure.Monitor.Query" Version="1.1.0" />
124127
<PackageReference Update="Azure.Identity" Version="1.13.1" />
128+
<PackageReference Update="Azure.Search.Documents" Version="11.6.0" />
125129
<PackageReference Update="Azure.Security.KeyVault.Secrets" Version="4.6.0" />
126130
<PackageReference Update="Azure.Security.KeyVault.Keys" Version="4.6.0" />
127131
<PackageReference Update="Azure.Security.KeyVault.Certificates" Version="4.6.0" />
128132
<PackageReference Update="Azure.Storage.Common" Version="12.22.0" />
129133
<PackageReference Update="Azure.Storage.Blobs" Version="12.23.0" />
130134
<PackageReference Update="Azure.Storage.Queues" Version="12.21.0" />
131135
<PackageReference Update="Azure.Storage.Files.Shares" Version="12.21.0" />
132-
<PackageReference Update="Azure.AI.Inference" Version="1.0.0-beta.2" />
133-
<PackageReference Update="Azure.AI.OpenAI" Version="2.0.0" />
134136
<PackageReference Update="Azure.ResourceManager" Version="1.13.0" />
135137
<PackageReference Update="Azure.ResourceManager.AppConfiguration" Version="1.3.2" />
136138
<PackageReference Update="Azure.ResourceManager.ApplicationInsights" Version="1.0.0" />
@@ -288,7 +290,7 @@
288290
<PackageReference Update="Azure.ResourceManager.ExtendedLocations" Version="1.1.0-beta.1" />
289291
<PackageReference Update="Azure.ResourceManager.EventHubs" Version="1.2.0-beta.1" />
290292
<PackageReference Update="Azure.ResourceManager.ContainerRegistry" Version="1.3.0-beta.1" />
291-
<PackageReference Update="Azure.Search.Documents" Version="11.2.0" />
293+
<PackageReference Update="Azure.Search.Documents" Version="11.6.0" />
292294
<PackageReference Update="Azure.Security.KeyVault.Keys" Version="4.6.0" />
293295
<PackageReference Update="Azure.Security.KeyVault.Secrets" Version="4.6.0" />
294296
<PackageReference Update="Azure.Storage.Blobs" Version="12.23.0" />

sdk/cloudmachine/Azure.CloudMachine.OpenAI/api/Azure.CloudMachine.OpenAI.net8.0.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public static void Add(this System.Collections.Generic.List<OpenAI.Chat.ChatMess
1313
public static string AsText(this OpenAI.Chat.ChatCompletion completion) { throw null; }
1414
public static string AsText(this OpenAI.Chat.ChatMessageContent content) { throw null; }
1515
public static string AsText(this System.ClientModel.ClientResult<OpenAI.Chat.ChatCompletion> completionResult) { throw null; }
16-
public static OpenAI.Chat.ChatClient GetOpenAIChatClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
17-
public static OpenAI.Embeddings.EmbeddingClient GetOpenAIEmbeddingsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
16+
public static OpenAI.Chat.ChatClient GetOpenAIChatClient(this Azure.Core.ClientWorkspace workspace, string? deploymentName = null) { throw null; }
17+
public static OpenAI.Embeddings.EmbeddingClient GetOpenAIEmbeddingsClient(this Azure.Core.ClientWorkspace workspace, string? deploymentName = null) { throw null; }
1818
public static void Trim(this System.Collections.Generic.List<OpenAI.Chat.ChatMessage> messages) { }
1919
}
2020
public partial class ChatTools

sdk/cloudmachine/Azure.CloudMachine.OpenAI/api/Azure.CloudMachine.OpenAI.netstandard2.0.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public static void Add(this System.Collections.Generic.List<OpenAI.Chat.ChatMess
1313
public static string AsText(this OpenAI.Chat.ChatCompletion completion) { throw null; }
1414
public static string AsText(this OpenAI.Chat.ChatMessageContent content) { throw null; }
1515
public static string AsText(this System.ClientModel.ClientResult<OpenAI.Chat.ChatCompletion> completionResult) { throw null; }
16-
public static OpenAI.Chat.ChatClient GetOpenAIChatClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
17-
public static OpenAI.Embeddings.EmbeddingClient GetOpenAIEmbeddingsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
16+
public static OpenAI.Chat.ChatClient GetOpenAIChatClient(this Azure.Core.ClientWorkspace workspace, string? deploymentName = null) { throw null; }
17+
public static OpenAI.Embeddings.EmbeddingClient GetOpenAIEmbeddingsClient(this Azure.Core.ClientWorkspace workspace, string? deploymentName = null) { throw null; }
1818
public static void Trim(this System.Collections.Generic.List<OpenAI.Chat.ChatMessage> messages) { }
1919
}
2020
public partial class ChatTools

sdk/cloudmachine/Azure.CloudMachine.OpenAI/src/AzureOpenAIExtensions.cs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ public static class AzureOpenAIExtensions
2020
/// Gets the OpenAI chat client.
2121
/// </summary>
2222
/// <param name="workspace"></param>
23+
/// <param name="deploymentName"></param>
2324
/// <returns></returns>
24-
public static ChatClient GetOpenAIChatClient(this ClientWorkspace workspace)
25+
public static ChatClient GetOpenAIChatClient(this ClientWorkspace workspace, string? deploymentName = null)
2526
{
27+
string name = deploymentName ?? "default";
28+
2629
ChatClient chatClient = workspace.Subclients.Get(() =>
2730
{
2831
AzureOpenAIClient aoiaClient = workspace.Subclients.Get(() => CreateAzureOpenAIClient(workspace));
29-
return workspace.CreateChatClient(aoiaClient);
30-
});
32+
return workspace.CreateChatClient(aoiaClient, deploymentName);
33+
}, name);
3134

3235
return chatClient;
3336
}
@@ -36,14 +39,17 @@ public static ChatClient GetOpenAIChatClient(this ClientWorkspace workspace)
3639
/// Gets the OpenAI embeddings client.
3740
/// </summary>
3841
/// <param name="workspace"></param>
42+
/// <param name="deploymentName"></param>
3943
/// <returns></returns>
40-
public static EmbeddingClient GetOpenAIEmbeddingsClient(this ClientWorkspace workspace)
44+
public static EmbeddingClient GetOpenAIEmbeddingsClient(this ClientWorkspace workspace, string? deploymentName = null)
4145
{
46+
string name = deploymentName ?? "default";
47+
4248
EmbeddingClient embeddingsClient = workspace.Subclients.Get(() =>
4349
{
4450
AzureOpenAIClient aoiaClient = workspace.Subclients.Get(() => CreateAzureOpenAIClient(workspace));
45-
return workspace.CreateEmbeddingsClient(aoiaClient);
46-
});
51+
return workspace.CreateEmbeddingsClient(aoiaClient, deploymentName);
52+
}, name);
4753

4854
return embeddingsClient;
4955
}
@@ -99,17 +105,17 @@ private static AzureOpenAIClient CreateAzureOpenAIClient(this ClientWorkspace wo
99105
}
100106
}
101107

102-
private static ChatClient CreateChatClient(this ClientWorkspace workspace, AzureOpenAIClient client)
108+
private static ChatClient CreateChatClient(this ClientWorkspace workspace, AzureOpenAIClient client, string? deploymentName = null)
103109
{
104110
ClientConnection connection = workspace.GetConnectionOptions(typeof(ChatClient).FullName);
105-
ChatClient chat = client.GetChatClient(connection.Locator);
111+
ChatClient chat = client.GetChatClient(deploymentName ?? connection.Locator);
106112
return chat;
107113
}
108114

109-
private static EmbeddingClient CreateEmbeddingsClient(this ClientWorkspace workspace, AzureOpenAIClient client)
115+
private static EmbeddingClient CreateEmbeddingsClient(this ClientWorkspace workspace, AzureOpenAIClient client, string? deploymentName = null)
110116
{
111117
ClientConnection connection = workspace.GetConnectionOptions(typeof(EmbeddingClient).FullName);
112-
EmbeddingClient embeddings = client.GetEmbeddingClient(connection.Locator);
118+
EmbeddingClient embeddings = client.GetEmbeddingClient(deploymentName ?? connection.Locator);
113119
return embeddings;
114120
}
115121

sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.net8.0.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
namespace Azure.CloudMachine
22
{
3+
public partial class AIFoundryClient : Azure.Core.ClientWorkspace
4+
{
5+
protected AIFoundryClient() : base (default(Azure.Core.TokenCredential)) { }
6+
public AIFoundryClient(string connectionString, Azure.Core.TokenCredential credential = null) : base (default(Azure.Core.TokenCredential)) { }
7+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
8+
public Azure.Core.ConnectionCollection Connections { get { throw null; } }
9+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
10+
public override bool Equals(object obj) { throw null; }
11+
public override System.Collections.Generic.IEnumerable<Azure.Core.ClientConnection> GetAllConnectionOptions() { throw null; }
12+
public override Azure.Core.ClientConnection GetConnectionOptions(string connectionId) { throw null; }
13+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
14+
public override int GetHashCode() { throw null; }
15+
}
16+
public static partial class AzureAIProjectsExensions
17+
{
18+
public static Azure.AI.Projects.AgentsClient GetAgentsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
19+
public static Azure.AI.Inference.ChatCompletionsClient GetChatCompletionsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
20+
public static Azure.AI.Inference.EmbeddingsClient GetEmbeddingsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
21+
public static Azure.AI.Projects.EvaluationsClient GetEvaluationsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
22+
public static Azure.Search.Documents.SearchClient GetSearchClient(this Azure.Core.ClientWorkspace workspace, string indexName) { throw null; }
23+
public static Azure.Search.Documents.Indexes.SearchIndexClient GetSearchIndexClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
24+
public static Azure.Search.Documents.Indexes.SearchIndexerClient GetSearchIndexerClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
25+
}
326
public partial class CloudMachineClient : Azure.Core.ClientWorkspace
427
{
528
protected CloudMachineClient() : base (default(Azure.Core.TokenCredential)) { }

sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.netstandard2.0.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
namespace Azure.CloudMachine
22
{
3+
public partial class AIFoundryClient : Azure.Core.ClientWorkspace
4+
{
5+
protected AIFoundryClient() : base (default(Azure.Core.TokenCredential)) { }
6+
public AIFoundryClient(string connectionString, Azure.Core.TokenCredential credential = null) : base (default(Azure.Core.TokenCredential)) { }
7+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
8+
public Azure.Core.ConnectionCollection Connections { get { throw null; } }
9+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
10+
public override bool Equals(object obj) { throw null; }
11+
public override System.Collections.Generic.IEnumerable<Azure.Core.ClientConnection> GetAllConnectionOptions() { throw null; }
12+
public override Azure.Core.ClientConnection GetConnectionOptions(string connectionId) { throw null; }
13+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
14+
public override int GetHashCode() { throw null; }
15+
}
16+
public static partial class AzureAIProjectsExensions
17+
{
18+
public static Azure.AI.Projects.AgentsClient GetAgentsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
19+
public static Azure.AI.Inference.ChatCompletionsClient GetChatCompletionsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
20+
public static Azure.AI.Inference.EmbeddingsClient GetEmbeddingsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
21+
public static Azure.AI.Projects.EvaluationsClient GetEvaluationsClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
22+
public static Azure.Search.Documents.SearchClient GetSearchClient(this Azure.Core.ClientWorkspace workspace, string indexName) { throw null; }
23+
public static Azure.Search.Documents.Indexes.SearchIndexClient GetSearchIndexClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
24+
public static Azure.Search.Documents.Indexes.SearchIndexerClient GetSearchIndexerClient(this Azure.Core.ClientWorkspace workspace) { throw null; }
25+
}
326
public partial class CloudMachineClient : Azure.Core.ClientWorkspace
427
{
528
protected CloudMachineClient() : base (default(Azure.Core.TokenCredential)) { }

0 commit comments

Comments
 (0)