diff --git a/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.netstandard2.0.cs b/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.netstandard2.0.cs index 733b707ca1d3..98d2d5022316 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.netstandard2.0.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.netstandard2.0.cs @@ -77,6 +77,7 @@ namespace Azure.CloudMachine.OpenAI { public static partial class AzureOpenAIExtensions { + public static void Add(this System.Collections.Generic.List messages, OpenAI.Chat.ChatCompletion completion) { } public static void Add(this System.Collections.Generic.List messages, System.Collections.Generic.IEnumerable entries) { } 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; } @@ -96,6 +97,7 @@ public void Add(System.Type functions) { } protected virtual string GetMethodInfoToDescription(System.Reflection.MethodInfo function) { throw null; } protected virtual string GetMethodInfoToName(System.Reflection.MethodInfo function) { throw null; } protected virtual string GetParameterInfoToDescription(System.Reflection.ParameterInfo parameter) { throw null; } + public static implicit operator OpenAI.Chat.ChatCompletionOptions (Azure.CloudMachine.OpenAI.ChatTools tools) { throw null; } } public partial class EmbeddingsVectorbase { diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/extensions/AzureOpenAIExtensions.cs b/sdk/cloudmachine/Azure.CloudMachine/src/extensions/AzureOpenAIExtensions.cs index a764cbc41ac4..4284adc13300 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/src/extensions/AzureOpenAIExtensions.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/extensions/AzureOpenAIExtensions.cs @@ -95,4 +95,12 @@ public static void Add(this List messages, IEnumerable + /// Adds a chat completion as an AssistantChatMessage to the list of chat messages. + /// + /// + /// + public static void Add(this List messages, ChatCompletion completion) + => messages.Add(ChatMessage.CreateAssistantMessage(completion)); } diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/extensions/ChatTools.cs b/sdk/cloudmachine/Azure.CloudMachine/src/extensions/ChatTools.cs index a5cd50372c31..4835ad826524 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/src/extensions/ChatTools.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/extensions/ChatTools.cs @@ -8,6 +8,7 @@ using System.Reflection; using System.Text; using System.Text.Json; +using Azure.Messaging.EventGrid.SystemEvents; using OpenAI.Chat; namespace Azure.CloudMachine.OpenAI; @@ -35,6 +36,20 @@ public ChatTools(params Type[] tools) /// public IList Definitions => _definitions; + /// + /// Implicitly converts a to . + /// + /// + public static implicit operator ChatCompletionOptions(ChatTools tools) + { + ChatCompletionOptions options = new(); + foreach (var tool in tools.Definitions) + { + options.Tools.Add(tool); + } + return options; + } + /// /// Adds a set of functions to the chat functions. ///