Audio
GetAudioTranscription()
now supports word-level timestamp granularities viaAudioTranscriptionOptions
:- The
Verbose
option forResponseFormat
must be used for any timing information to be populated TimestampGranularityFlags
accepts a combination of the.Word
and.Segment
granularity values inAudioTimestampGranularity
, joined when needed via the single-pipe|
operator- For example,
TimestampGranularityFlags = AudioTimestampGranularity.Word | AudioTimestampGranularity.Segment
will request that both word-level and segment-level timestamps are provided on the transcription result
- For example,
- If not otherwise specified,
Verbose
format will default to using segment-level timestamp information - Corresponding word-level information is found on the
.Words
collection ofAudioTranscription
, peer to the existing.Segments
collection - Note that word-level timing information incurs a small amount of additional processingly latency; segment-level timestamps do not encounter this behavior
- The
GenerateSpeechFromText()
can now useWav
andPcm
values fromSpeechGenerationResponseFormat
, these new options providing alternative uncompressed formats toFlac
Chat
ChatCompletions
andStreamingChatCompletionsUpdate
now include the reportedModel
value from the response- Log probability information is now included in
StreamingChatCompletionsUpdate
whenlogprobs
are requested onGetChatCompletionsStreaming()
- [AOAI] Custom Blocklist information in content filter results is now represented in a more structured
ContentFilterDetailedResults
type - [AOAI] A new
IndirectAttack
content filter entry is now present on content filter results for prompts
- [AOAI]
AzureChatExtensionMessageContext
'sRequestContentFilterResults
now uses the newContentFilterDetailedResults
type, changed from the previousIReadOnlyList<ContentFilterBlockListIdResult>
. The previous list is now present onCustomBlockLists.Details
, supplemented with a newCustomBlockLists.Filtered
property.
- [AOAI] An issue that sometimes caused
StreamingChatCompletionUpdates
from Azure OpenAI to inappropriately exclude top-level information likeId
andCreatedAt
has been addressed
This release targets the latest 2024-03-01-preview
service API label and brings support for the Dimensions
property when using new embedding models.
EmbeddingsOptions
now includes theDimensions
property, new to Azure OpenAI's2024-03-01-preview
service API.
- Several issues with the
ImageGenerations
response object being treated as writeable are fixed:ImageGenerations
no longer has an erroneous public constructorImageGenerations.Created
no longer has a public setterImageGenerations.Data
is now anIReadOnlyList
instead of anIList
- A corresponding replacement factory method for mocks is added to
AzureOpenAIModelFactory
- Text-to-speech using OpenAI TTS models is now supported. See OpenAI's API reference or the Azure OpenAI quickstart for detailed overview and background information.
- The new method
GenerateSpeechFromText
exposes this capability onOpenAIClient
. - Text-to-speech converts text into lifelike spoken audio in a chosen voice, together with other optional configurations.
- This method works for both Azure OpenAI and non-Azure
api.openai.com
client configurations
- The new method
"On Your Data" changes:
- Introduced a new type
AzureChatExtensionDataSourceResponseCitation
for a more structured representation of citation data. - Correspondingly, updated
AzureChatExtensionsMessageContext
:- Replaced
Messages
withCitations
of typeAzureChatExtensionDataSourceResponseCitation
. - Added
Intent
as a string type.
- Replaced
- Renamed "AzureCognitiveSearch" to "AzureSearch":
AzureCognitiveSearchChatExtensionConfiguration
is nowAzureSearchChatExtensionConfiguration
.AzureCognitiveSearchIndexFieldMappingOptions
is nowAzureSearchIndexFieldMappingOptions
.
- Check the project README for updated code snippets.
- New properties in
ChatCompletionsOptions
:EnableLogProbabilities
: Allows retrieval of log probabilities (REST:logprobs
)LogProbabilitiesPerToken
: The number of most likely tokens to return per token (REST:top_logprobs
)
- Introduced a new property in
CompletionsOptions
:Suffix
: Defines the suffix that follows the completion of inserted text (REST:suffix
)
- Image generation response now includes content filtering details (specific to Azure OpenAI endpoint):
ImageGenerationData.ContentFilterResults
: Information about the content filtering results. (REST:content_filter_results
)ImageGenerationData.PromptFilterResults
: Information about the content filtering category (REST:prompt_filter_results
)
- Removed the setter of the
Functions
property of theChatCompletionsOptions
class as per the guidelines for collection properties.
- Addressed an issue with the public constructor for
ChatCompletionsFunctionToolCall
that failed to set the tool call type in the corresponding request.
Like beta.11, beta.12 is another release that brings further refinements and fixes. It remains based on the 2023-12-01-preview
service API version for Azure OpenAI and does not add any new service capabilities.
Updates for using streaming tool calls:
- A new .NET-specific
StreamingToolCallUpdate
type has been added to better represent streaming tool call updates when using chat tools.- This new type includes an explicit
ToolCallIndex
property, reflectingindex
in the REST schema, to allow resilient deserialization of parallel function tool calling.
- This new type includes an explicit
- A convenience constructor has been added for
ChatRequestAssistantMessage
that can automatically populate from a priorChatResponseMessage
when using non-streaming chat completions. - A public constructor has been added for
ChatCompletionsFunctionToolCall
to allow more intuitive reconstruction ofChatCompletionsToolCall
instances for use inChatRequestAssistantMessage
instances made from streaming responses.
Other additions:
- To facilitate reuse of user message contents,
ChatRequestUserMessage
now provides a publicContent
property (string
) as well as a publicMultimodalContentItems
property (IList<ChatMessageContentItem
).Content
is the conventional plain-text content and will be populated as non-null when the aChatRequestUserMessage()
constructor accepting a string is used to instantiate the message.MultimodalContentItems
is the new compound content type, currently only usable withgpt-4-vision-preview
, that allows hybrid use of text and image references. It will be populated when an appropriateChatRequestUserMessage()
constructor accepting a collection ofChatMessageContentItem
instances is used.Role
is also restored to common visibility toChatRequestUserMessage
.
- The type of
ToolCallUpdate
onStreamingChatCompletionsUpdate
has been changed from the non-streamingChatCompletionsToolCall
to the newStreamingToolCallUpdate
type. The conversion is straightforward:ToolCallUpdate.Id
remains unchanged.- Instead of casting
ToolCallUpdate
toChatCompletionsFunctionToolCall
, cast it toStreamingToolCallUpdate
. - Update cast instance use of
functionToolCallUpdate.Arguments
to accumulatefunctionToolCallUpdate.ArgumentsUpdate
.
- Removed the parameterized constructor of the
ChatCompletionsOptions
class that only received the messages as a parameter in favor of the parameterized constructor that receives the deployment name as well. This makes it consistent with the implementation of other Options classes. - Removed the setter of the
Input
property of theEmbeddingsOptions
class as per the guidelines for collection properties.
- [QUERY] Azure.AI.OpenAI_1.0.0-beta.10 no longer exposes message content on base ChatRequestMessage
- [BUG] Null Reference Exception in OpenAIClient.GetChatCompletionsAsync
This is a fast-following bug fix update to address some of the biggest issues reported by the community. Thank you sharing your experiences!
- The type of
ChatCompletionsOptions.ToolChoice
has been updated fromBinaryData
to a newChatCompletionsToolChoice
type. Please useChatCompletionsToolChoice.None
,ChatCompletionsToolChoice.Auto
, or provide a reference to a function or function tool definition to migrate.
ChatCompletionsOptions.ResponseFormat
now serializes correctly and will not result in "not of type 'object" errorsChatCompletionsOptions.FunctionCall
is fixed to again work withFunctionDefinition.None
andFunctionDefinition.Auto
instead of resulting in not finding a named "none" or "auto" functionChatCompletionsOptions.ToolChoice
previously defaulted to aBinaryData
type and has now been corrected to use a customChatCompletionsToolChoice
type that parallelsFunctionDefinition
for older function calling.
Following OpenAI's November Dev Day and Microsoft's 2023 Ignite conference, this update brings a slew of new features and changes to the SDK.
-1106
model feature support forgpt-35-turbo
andgpt-4-turbo
, including use ofseed
,system_fingerprint
, parallel function calling via tools, "JSON mode" for guaranteed function outputs, and moredall-e-3
image generation capabilities viaGetImageGenerations
, featuring higher model quality, automatic prompt revisions bygpt-4
, and customizable quality/style settings- Greatly expanded "On Your Data" capabilities in Azure OpenAI, including many new data source options and authentication mechanisms
- Early support for
gpt-4-vision-preview
, which allows the hybrid use of text and images as input to enable scenarios like "describe this image for me" - Support for Azure enhancements to
gpt-4-vision-preview
results that include grounding and OCR features
ChatMessage
changes:
- The singular
ChatMessage
type has been replaced byChatRequestMessage
andChatResponseMessage
, the former of which is an abstract, polymorphic type with concrete derivations likeChatRequestSystemMessage
andChatRequestUserMessage
. This requires conversion from oldChatMessages
into the new types. While this is usually a straightforward string replacement, converting a response message into a request message (e.g. when propagating an assistant response to continue the conversation) will require creating a new instance of the appropriate request message with the response message's data. See the examples for details.
Dall-e-3:
- Azure OpenAI now uses
dall-e-3
model deployments for its image generation API and such a valid deployment must be provided into the options for theGetImageGenerations
method to receive results.
- Audio transcription and translation (via
GetAudioTranscription()
andGetAudioTranslation()
now allow specification of an optionalFilename
in addition to the binary audio data. This is used purely as an identifier and does not functionally alter the transcription/translation behavior in any way.
This update includes a number of version-to-version breaking changes to the API.
Streaming Completions and Streaming Chat Completions have been significantly updated to use simpler, shallower usage patterns and data representations. The goal of these changes is to make streaming much easier to consume in common cases while still retaining full functionality in more complex ones (e.g. with multiple choices requested).
- A new
StreamingResponse<T>
type is introduced that implicitly exposes anIAsyncEnumerable<T>
derived from the underlying response. OpenAI.GetCompletionsStreaming()
now returns aStreamingResponse<Completions>
that may be directly enumerated over.StreamingCompletions
,StreamingChoice
, and the corresponding methods are removed.- Because Chat Completions use a distinct structure for their streaming response messages, a new
StreamingChatCompletionsUpdate
type is introduced that encapsulates this update data. - Correspondingly,
OpenAI.GetChatCompletionsStreaming()
now returns aStreamingResponse<StreamingChatCompletionsUpdate>
that may be enumerated over directly.StreamingChatCompletions
,StreamingChatChoice
, and related methods are removed. - For more information, please see the related pull request description as well as the updated snippets in the project README.
deploymentOrModelName
and related method parameters on OpenAIClient
have been moved to DeploymentName
properties in the corresponding method options. This is intended to promote consistency across scenario,
language, and Azure/non-Azure OpenAI use.
As an example, the following:
ChatCompletionsOptions chatCompletionsOptions = new()
{
Messages = { new(ChatRole.User, "Hello, assistant!") },
};
Response<ChatCompletions> response = client.GetChatCompletions("gpt-4", chatCompletionsOptions);
...is now re-written as:
ChatCompletionsOptions chatCompletionsOptions = new()
{
DeploymentName = "gpt-4",
Messages = { new(ChatRole.User, "Hello, assistant!") },
};
Response<ChatCompletions> response = client.GetChatCompletions(chatCompletionsOptions);
With the migration of DeploymentName
into method complex options types, these options types have now been snapped to
follow a common pattern: each complex options type will feature a default constructor that allows init
-style setting
of properties as well as a single additional constructor that accepts all required parameters for the corresponding
method. Existing constructors that no longer meet that "all" requirement, including those impacted by the addition of
DeploymentName
, have been removed. The "convenience" constructors that represented required parameter data
differently -- for example, EmbeddingsOptions(string)
, have also been removed in favor of the consistent "set of
directly provide" choice.
More exhaustively, removed are:
AudioTranscriptionOptions(BinaryData)
AudioTranslationOptions(BinaryData)
ChatCompletionsOptions(IEnumerable<ChatMessage>)
CompletionsOptions(IEnumerable<string>)
EmbeddingsOptions(string)
EmbeddingsOptions(IEnumerable<string>)
And added as replacements are:
AudioTranscriptionOptions(string, BinaryData)
AudioTranslationOptions(string, BinaryData)
ChatCompletionsOptions(string, IEnumerable<ChatMessage>)
CompletionsOptions(string, IEnumerable<string>)
EmbeddingsOptions(string, IEnumerable<string>)
Changed the representation of embeddings (specifically, the type of the Embedding
property of the EmbeddingItem
class)
from IReadOnlyList<float>
to ReadOnlyMemory<float>
as part of a broader effort to establish consistency across the
.NET ecosystem.
Replaced the SearchKey
and EmbeddingKey
properties of the AzureCognitiveSearchChatExtensionConfiguration
class with
new SetSearchKey
and SetEmbeddingKey
methods respectively. These methods simplify the configuration of the Azure Cognitive
Search chat extension by receiving a plain string instead of an AzureKeyCredential
, promote more sensible key and secret
management, and align with the Azure SDK guidelines.
- Audio Transcription and Audio Translation using OpenAI Whisper models is now supported. See OpenAI's API
reference or the Azure OpenAI
quickstart for detailed overview and
background information.
- The new methods
GetAudioTranscription
andGetAudioTranscription
expose these capabilities onOpenAIClient
- Transcription produces text in the primary, supported, spoken input language of the audio data provided, together with any optional associated metadata
- Translation produces text, translated to English and reflective of the audio data provided, together with any optional associated metadata
- These methods work for both Azure OpenAI and non-Azure
api.openai.com
client configurations
- The new methods
- The underlying representation of
PromptFilterResults
(forCompletions
andChatCompletions
) has had its response body key changed fromprompt_annotations
toprompt_filter_results
- Prior versions of the
Azure.AI.OpenAI
library may no longer populatePromptFilterResults
as expected and it's highly recommended to upgrade to this version if the use of Azure OpenAI content moderation annotations for input data is desired - If a library version upgrade is not immediately possible, it's advised to use
Response<T>.GetRawResponse()
and manually extract theprompt_filter_results
object from the top level of theCompletions
orChatCompletions
responseContent
payload
- Support for the described breaking change for
PromptFilterResults
was added and this library version will now again deserializePromptFilterResults
appropriately PromptFilterResults
andContentFilterResults
are now exposed on the result classes for streaming Completions and Chat Completions.Streaming(Chat)Completions.PromptFilterResults
will report an index-sorted list of all prompt annotations received so far whileStreaming(Chat)Choice.ContentFilterResults
will reflect the latest-received content annotations that were populated and received while streaming
- The Azure OpenAI "using your own data" feature is now supported. See the Azure OpenAI using your own data quickstart for conceptual background and detailed setup instructions.
- Azure OpenAI chat extensions are configured via a new
AzureChatExtensionsOptions
property onChatCompletionsOptions
. When anAzureChatExtensionsOptions
is provided, configured requests will only work with clients configured to use the Azure OpenAI service, as the capabilities are unique to that service target. AzureChatExtensionsOptions
then hasAzureChatExtensionConfiguration
instances added to itsExtensions
property, with these instances representing the supplementary information needed for Azure OpenAI to use desired data sources to supplement chat completions behavior.ChatChoice
instances on aChatCompletions
response value that used chat extensions will then also have theirMessage
property supplemented by anAzureChatExtensionMessageContext
instance. This context contains a collection of supplementaryMessages
that describe the behavior of extensions that were used and supplementary response data, such as citations, provided along with the response.- See the README sample snippet for a simplified example of request/response use with "using your own data"
- Azure OpenAI chat extensions are configured via a new
- DALL-E image generation is now supported. See the Azure OpenAI quickstart for conceptual background and detailed setup instructions.
OpenAIClient
gains a newGetImageGenerations
method that accepts anImageGenerationOptions
and produces anImageGenerations
via its response. This response object encapsulates the temporary storage location of generated images for future retrieval.- In contrast to other capabilities, DALL-E image generation does not require explicit creation or specification of a deployment or model. Its surface as such does not include this concept.
- Functions for chat completions are now supported: see OpenAI's blog post on the topic for much more detail.
- A list of
FunctionDefinition
objects may be populated onChatCompletionsOptions
via itsFunctions
property. These definitions include a name and description together with a serialized JSON Schema representation of its parameters; these parameters can be generated easily viaBinaryData.FromObjectAsJson
with dynamic objects -- see the README for example usage. - NOTE: Chat Functions requires a minimum of the
-0613
model versions forgpt-4
andgpt-3.5-turbo
/gpt-35-turbo
. Please ensure you're using these later model versions, as Functions are not supported with older model revisions. For Azure OpenAI, you can update a deployment's model version or create a new model deployment with an updated version via the Azure AI Studio interface, also accessible through Azure Portal.
- A list of
- (Azure OpenAI specific) Completions and Chat Completions responses now include embedded content filter annotations for prompts and responses
- A new
Azure.AI.OpenAI.AzureOpenAIModelFactory
is now present for mocking.
ChatMessage
's one-parameter constructor has been replaced with a no-parameter constructor. Please replace any hybrid construction with one of these two options that either completely rely on property setting or completely rely on constructor parameters.
This is a significant release that brings GPT-4 model support (chat) and the ability to use non-Azure OpenAI (not just Azure OpenAI resources) to the .NET library. It also makes a number of clarifying adjustments to request properties for completions.
- GPT-4 models are now supported via new
GetChatCompletions
andGetChatCompletionsStreaming
methods onOpenAIClient
. These use the/chat/completions
REST endpoint and represent the OpenAI Chat messages format.- The
gpt-3.5-model
can also be used with Chat completions; prior models like text-davinci-003 cannot be used with Chat completions and should still use theGetCompletions
methods.
- The
- Support for using OpenAI's endpoint via valid API keys obtained from https://platform.openai.com has been added.
OpenAIClient
has new constructors that accept an OpenAI API key instead of an Azure endpoint URI and credential; once configured, Completions, Chat Completions, and Embeddings can be used with identical calling patterns.
A number of Completions request properties have been renamed and further documented for clarity.
CompletionsOptions
(REST request payload):CacheLevel
andCompletionConfig
are removed.LogitBias
(REST:logit_bias
), previously a<string, int>
Dictionary, is now an<int, int>
Dictionary namedTokenSelectionBiases
.LogProbability
(REST:logprobs
) is renamed toLogProbabilityCount
.Model
is removed (in favor of the method-level parameter for deployment or model name)Prompt
is renamed toPrompts
SnippetCount
(REST:n
) is renamed toChoicesPerPrompt
.Stop
is renamed toStopSequences
.
- Method and property documentation are broadly updated, with renames from REST schema (like
n
becomingChoicesPerPrompt
) specifically noted in<remarks>
.
- Addressed issues that sometimes caused
beta.3
's newGetStreamingCompletions
method to execute indefinitely
- Support for streaming Completions responses, a capability that parallels setting
stream=true
in the REST API, is now available. A newGetStreamingCompletions
method onOpenAIClient
provides a response valueStreamingCompletions
type. This, in turn, exposes a collection ofStreamingChoice
objects as anIAsyncEnumerable
that will update as a streamed response progresses.StreamingChoice
further exposes anIAsyncEnumerable
of streaming text elements via aGetTextStreaming
method. Used together, this facilitates providing faster, live-updating responses for Completions via the convenientawait foreach
pattern. - ASP.NET integration via
Microsoft.Extensions.Azure
'sIAzureClientBuilder
interfaces is available.OpenAIClient
is now a supported client type for these extension methods.
CompletionsLogProbability.TokenLogProbability
, available onChoice
elements of aCompletions
response value's.Choices
collection when a non-zeroLogProbability
value is provided viaCompletionsOptions
, is now anIReadOnlyList<float?>
vs. its previous type ofIReadOnlyList<float>
. This nullability addition accomodates circumstances where some tokens produce expected null values in log probability arrays.
- Setting
CompletionsOptions.Echo
to true while also setting a non-zeroCompletionsOptions.LogProbability
no longer results in a deserialization error during response processing.
- Adjusted bad name
finishReason
tofinish_reason
in deserializer class
- This is the initial preview release for Azure OpenAI inference capabilities, including completions and embeddings.