diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatOptions.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatOptions.cs index 52e000c915b..aab2f53a28d 100644 --- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatOptions.cs +++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatOptions.cs @@ -9,6 +9,16 @@ namespace Microsoft.Extensions.AI; /// Represents the options for a chat request. public class ChatOptions { + /// Gets or sets an optional identifier used to associate a request with an existing conversation. + /// This property is obsolete. Use instead. + [System.Obsolete("Use ConversationId instead.")] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public string? ChatThreadId + { + get => ConversationId; + set => ConversationId = value; + } + /// Gets or sets an optional identifier used to associate a request with an existing conversation. public string? ConversationId { get; set; } diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponse.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponse.cs index b1f7f0d0c8a..92be7a5145c 100644 --- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponse.cs +++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponse.cs @@ -63,6 +63,25 @@ public IList Messages /// Gets or sets the ID of the chat response. public string? ResponseId { get; set; } + /// Gets or sets an identifier for the state of the conversation. + /// + /// Some implementations are capable of storing the state for a conversation, such that + /// the input messages supplied to need only be the additional messages beyond + /// what's already stored. If this property is non-, it represents an identifier for that state, + /// and it should be used in a subsequent instead of supplying the same messages + /// (and this 's message) as part of the messages parameter. Note that the value may + /// or may not differ on every response, depending on whether the underlying provider uses a fixed ID for each conversation + /// or updates it for each message. + /// + /// This method is obsolete. Use instead. + [Obsolete("Use ConversationId instead.")] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public string? ChatThreadId + { + get => ConversationId; + set => ConversationId = value; + } + /// Gets or sets an identifier for the state of the conversation. /// /// Some implementations are capable of storing the state for a conversation, such that diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseUpdate.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseUpdate.cs index 63dbfbc0d7d..bdc584596b0 100644 --- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseUpdate.cs +++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseUpdate.cs @@ -116,6 +116,24 @@ public IList Contents /// public string? MessageId { get; set; } + /// Gets or sets an identifier for the state of the conversation of which this update is a part. + /// + /// Some implementations are capable of storing the state for a conversation, such that + /// the input messages supplied to need only be the additional messages beyond + /// what's already stored. If this property is non-, it represents an identifier for that state, + /// and it should be used in a subsequent instead of supplying the same messages + /// (and this streaming message) as part of the messages parameter. Note that the value may or may not differ on every + /// response, depending on whether the underlying provider uses a fixed ID for each conversation or updates it for each message. + /// + /// This method is obsolete. Use instead. + [Obsolete("Use ConversationId instead.")] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public string? ChatThreadId + { + get => ConversationId; + set => ConversationId = value; + } + /// Gets or sets an identifier for the state of the conversation of which this update is a part. /// /// Some implementations are capable of storing the state for a conversation, such that diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Embeddings/EmbeddingGeneratorExtensions.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Embeddings/EmbeddingGeneratorExtensions.cs index 895b7bf7ea7..31f58772abf 100644 --- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Embeddings/EmbeddingGeneratorExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Embeddings/EmbeddingGeneratorExtensions.cs @@ -87,6 +87,35 @@ public static TService GetRequiredService( return service; } + /// Generates an embedding vector from the specified . + /// The type from which embeddings will be generated. + /// The numeric type of the embedding data. + /// The embedding generator. + /// A value from which an embedding will be generated. + /// The embedding generation options to configure the request. + /// The to monitor for cancellation requests. The default is . + /// The generated embedding for the specified . + /// is . + /// is . + /// The generator did not produce exactly one embedding. + /// + /// This operation is equivalent to using and returning the + /// resulting 's property. + /// + /// + /// This method is obsolete. Use instead. + /// + [Obsolete("Use GenerateVectorAsync instead.")] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public static async Task> GenerateEmbeddingVectorAsync( + this IEmbeddingGenerator> generator, + TInput value, + EmbeddingGenerationOptions? options = null, + CancellationToken cancellationToken = default) + { + return await GenerateVectorAsync(generator, value, options, cancellationToken).ConfigureAwait(false); + } + /// Generates an embedding vector from the specified . /// The type from which embeddings will be generated. /// The numeric type of the embedding data. @@ -112,6 +141,39 @@ public static async Task> GenerateVectorAsync< return embedding.Vector; } + /// Generates an embedding from the specified . + /// The type from which embeddings will be generated. + /// The type of embedding to generate. + /// The embedding generator. + /// A value from which an embedding will be generated. + /// The embedding generation options to configure the request. + /// The to monitor for cancellation requests. The default is . + /// + /// The generated embedding for the specified . + /// + /// is . + /// is . + /// The generator did not produce exactly one embedding. + /// + /// This operations is equivalent to using with a + /// collection composed of the single and then returning the first embedding element from the + /// resulting collection. + /// + /// + /// This method is obsolete. Use instead. + /// + [Obsolete("Use GenerateAsync instead.")] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public static async Task GenerateEmbeddingAsync( + this IEmbeddingGenerator generator, + TInput value, + EmbeddingGenerationOptions? options = null, + CancellationToken cancellationToken = default) + where TEmbedding : Embedding + { + return await GenerateAsync(generator, value, options, cancellationToken).ConfigureAwait(false); + } + /// Generates an embedding from the specified . /// The type from which embeddings will be generated. /// The type of embedding to generate.