Skip to content

Commit d4f6ecd

Browse files
authored
Merge branch 'main' into kelly/keyedCaches
2 parents fe9f5e9 + 7d2ea04 commit d4f6ecd

File tree

73 files changed

+3877
-105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+3877
-105
lines changed

eng/Version.Details.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,17 @@
194194
</Dependency>
195195
</ProductDependencies>
196196
<ToolsetDependencies>
197-
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="9.0.0-beta.25380.1">
197+
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="9.0.0-beta.25407.2">
198198
<Uri>https://github.com/dotnet/arcade</Uri>
199-
<Sha>7e67a7b4b62513a475afe46c4cd74d54b68f65c9</Sha>
199+
<Sha>e29823691315ed6b3acff20d5bdf3b0be7628283</Sha>
200200
</Dependency>
201-
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="9.0.0-beta.25380.1">
201+
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="9.0.0-beta.25407.2">
202202
<Uri>https://github.com/dotnet/arcade</Uri>
203-
<Sha>7e67a7b4b62513a475afe46c4cd74d54b68f65c9</Sha>
203+
<Sha>e29823691315ed6b3acff20d5bdf3b0be7628283</Sha>
204204
</Dependency>
205-
<Dependency Name="Microsoft.DotNet.Build.Tasks.Templating" Version="9.0.0-beta.25380.1">
205+
<Dependency Name="Microsoft.DotNet.Build.Tasks.Templating" Version="9.0.0-beta.25407.2">
206206
<Uri>https://github.com/dotnet/arcade</Uri>
207-
<Sha>7e67a7b4b62513a475afe46c4cd74d54b68f65c9</Sha>
207+
<Sha>e29823691315ed6b3acff20d5bdf3b0be7628283</Sha>
208208
</Dependency>
209209
</ToolsetDependencies>
210210
</Dependencies>

eng/Versions.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup Label="Version settings">
33
<MajorVersion>9</MajorVersion>
4-
<MinorVersion>8</MinorVersion>
4+
<MinorVersion>9</MinorVersion>
55
<PatchVersion>0</PatchVersion>
66
<PreReleaseVersionLabel>preview</PreReleaseVersionLabel>
77
<PreReleaseVersionIteration>1</PreReleaseVersionIteration>
@@ -83,7 +83,7 @@
8383
<!-- Dependencies from https://github.com/dotnet/efcore -->
8484
<MicrosoftEntityFrameworkCoreSqliteVersion>9.0.7</MicrosoftEntityFrameworkCoreSqliteVersion>
8585
<!-- Dependencies from https://github.com/dotnet/arcade -->
86-
<MicrosoftDotNetBuildTasksTemplatingVersion>9.0.0-beta.25380.1</MicrosoftDotNetBuildTasksTemplatingVersion>
86+
<MicrosoftDotNetBuildTasksTemplatingVersion>9.0.0-beta.25407.2</MicrosoftDotNetBuildTasksTemplatingVersion>
8787
</PropertyGroup>
8888
<PropertyGroup Label="No longer automated Maestro dependency updates">
8989
<!-- Packages from dotnet/runtime -->

eng/common/core-templates/job/job.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ parameters:
1919
# publishing defaults
2020
artifacts: ''
2121
enableMicrobuild: false
22+
microbuildUseESRP: true
2223
enablePublishBuildArtifacts: false
2324
enablePublishBuildAssets: false
2425
enablePublishTestResults: false
@@ -134,10 +135,11 @@ jobs:
134135
signType: $(_SignType)
135136
zipSources: false
136137
feedSource: https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json
137-
${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
138-
ConnectedPMEServiceName: 6cc74545-d7b9-4050-9dfa-ebefcc8961ea
139-
${{ else }}:
140-
ConnectedPMEServiceName: 248d384a-b39b-46e3-8ad5-c2c210d5e7ca
138+
${{ if eq(parameters.microbuildUseESRP, true) }}:
139+
${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
140+
ConnectedPMEServiceName: 6cc74545-d7b9-4050-9dfa-ebefcc8961ea
141+
${{ else }}:
142+
ConnectedPMEServiceName: 248d384a-b39b-46e3-8ad5-c2c210d5e7ca
141143
env:
142144
TeamName: $(_TeamName)
143145
MicroBuildOutputFolderOverride: '$(Agent.TempDirectory)'

eng/packages/TestOnly.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ItemGroup>
44
<PackageVersion Include="AutoFixture.AutoMoq" Version="4.17.0" />
5-
<PackageVersion Include="Azure.AI.OpenAI" Version="2.2.0-beta.5" />
5+
<PackageVersion Include="Azure.AI.OpenAI" Version="2.3.0-beta.1" />
66
<PackageVersion Include="autofixture" Version="4.17.0" />
77
<PackageVersion Include="BenchmarkDotNet" Version="0.13.5" />
88
<PackageVersion Include="AwesomeAssertions" Version="8.0.2" />

global.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"sdk": {
3-
"version": "9.0.107"
3+
"version": "9.0.109"
44
},
55
"tools": {
6-
"dotnet": "9.0.107",
6+
"dotnet": "9.0.109",
77
"runtimes": {
88
"dotnet": [
99
"8.0.0",
@@ -18,7 +18,7 @@
1818
"msbuild-sdks": {
1919
"Microsoft.Build.NoTargets": "3.7.0",
2020
"Microsoft.Build.Traversal": "3.2.0",
21-
"Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.25380.1",
22-
"Microsoft.DotNet.Helix.Sdk": "9.0.0-beta.25380.1"
21+
"Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.25407.2",
22+
"Microsoft.DotNet.Helix.Sdk": "9.0.0-beta.25407.2"
2323
}
2424
}
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# Release History
2+
3+
## NOT YET RELEASED
4+
5+
- Added `AIAnnotation` and related types to represent citations and other annotations in chat messages.
6+
- Added `ChatMessage.CreatedAt` so that chat messages can carry their timestamp.
7+
- Added a `[Description(...)]` attribute to `DataContent.Uri` to clarify its purpose when used in schemas.
8+
- Added `DataContent.Name` property to associate a name with the binary data, like a filename.
9+
- Added `HostedFileContent` for representing files hosted by the service.
10+
- Added `HostedVectorStoreContent` for representing vector stores hosted by the service.
11+
- Added `HostedFileSearchTool` to represent server-side file search tools.
12+
- Added `HostedCodeInterpreterTool.Inputs` to supply context about what state is available to the code interpreter tool.
13+
- Improved handling of function parameter data annotation attributes in `AIJsonUtilities.CreateJsonSchema`.
14+
- Fixed schema generation to include an items keyword for arrays of objects in `AIJsonUtilities.CreateJsonSchema`.
15+
16+
## 9.7.1
17+
18+
- Fixed schema generation for nullable function parameters in `AIJsonUtilities.CreateJsonSchema`.
19+
20+
## 9.7.0
21+
22+
- Added `ChatOptions.Instructions` property for configuring system instructions separate from chat messages.
23+
- Added `Usage` property to `SpeechToTextResponse` to provide details about the token usage.
24+
- Augmented `AIJsonUtilities.CreateJsonSchema` with support for data annotations.
25+
26+
## 9.6.0
27+
28+
- Added `AIFunction.ReturnJsonSchema` to represent the JSON schema of the return value of a function.
29+
- Removed title and description keywords from root-level schemas in `AIFunctionFactory`.
30+
31+
## 9.5.0
32+
33+
- Moved `AIFunctionFactory` down from `Microsoft.Extensions.AI` to `Microsoft.Extensions.AI.Abstractions`.
34+
- Added `BinaryEmbedding` type for representing bit embeddings.
35+
- Added `TextReasoningContent` to represent reasoning content in chat messages.
36+
- Added `ChatOptions.AllowMultipleToolCalls` for configuring parallel tool calling.
37+
- Added a public constructor to the base `AIContent`.
38+
- Added a missing `[DebuggerDisplay]` attribute on `AIFunctionArguments`.
39+
- Added `ChatOptions.RawRepresentationFactory` to facilitate passing raw options to the underlying service.
40+
- Added an `AIJsonSchemaTransformOptions` property inside `AIJsonSchemaCreateOptions`.
41+
- Added `DataContent.Base64Data` property for easier and more efficient handling of base64-encoded data.
42+
- Added JSON schema transformation functionality to `AIJsonUtilities`.
43+
- Fixed `AIJsonUtilities.CreateJsonSchema` to handle `JsonSerializerOptions` that do not have a `TypeInfoResolver` configured.
44+
- Fixed `AIFunctionFactory` handling of default struct arguments.
45+
- Fixed schema generation to ensure the type keyword is included when generating schemas for nullable enums.
46+
- Renamed the `GenerateXx` extension methods on `IEmbeddingGenerator<>`.
47+
- Renamed `ChatThreadId` to `ConversationId` across the libraries.
48+
- Replaced `Type targetType` parameter in `AIFunctionFactory.Create` with a delegate.
49+
- Remove `[Obsolete]` members from previews.
50+
51+
## 9.4.4-preview.1.25259.16
52+
53+
- Added `AIJsonUtilities.TransformSchema` and supporting types.
54+
- Added `BinaryEmbedding` for bit embeddings.
55+
- Added `ChatOptions.RawRepresentationFactory` to make it easier to pass options to the underlying service.
56+
- Added `Base64Data` property to `DataContent`.
57+
- Moved `AIFunctionFactory` to `Microsoft.Extensions.AI.Abstractions`.
58+
- Fixed `AIFunctionFactory` handling of default struct arguments.
59+
60+
## 9.4.3-preview.1.25230.7
61+
62+
- Renamed `ChatThreadId` to `ConversationId` on `ChatResponse`, `ChatResponseUpdate`, and `ChatOptions`.
63+
- Renamed `EmbeddingGeneratorExtensions` method `GenerateEmbeddingAsync` to `GenerateAsync` and `GenerateEmbeddingVectorAsync` to `GenerateVectorAsync`.
64+
- Made `AIContent`'s constructor `public` instead of `protected`.
65+
- Fixed `AIJsonUtilities.CreateJsonSchema` to tolerate `JsonSerializerOptions` instances that don't have a `TypeInfoResolver` already configured.
66+
67+
## 9.4.0-preview.1.25207.5
68+
69+
- Added `ErrorContent` and `TextReasoningContent`.
70+
- Added `MessageId` to `ChatMessage` and `ChatResponseUpdate`.
71+
- Added `AIFunctionArguments`, changing `AIFunction.InvokeAsync` to accept one and to return a `ValueTask`.
72+
- Updated `AIJsonUtilities`'s schema generation to not use `default` when `RequireAllProperties` is set to `true`.
73+
- Added `ISpeechToTextClient` and supporting types.
74+
- Fixed several issues related to Native AOT support.
75+
76+
## 9.3.0-preview.1.25161.3
77+
78+
- Changed `IChatClient.GetResponseAsync` and `IChatClient.GetStreamingResponseAsync` to accept an `IEnumerable<ChatMessage>` rather than an `IList<ChatMessage>`. It is no longer mutated by implementations.
79+
- Removed `ChatResponse.Choice` and `ChatResponseUpdate.ChoiceIndex`.
80+
- Replaced `ChatResponse.Message` with `ChatResponse.Messages`. Responses now carry with them all messages generated as part of the operation, rather than all but the last being added to the history and the last returned.
81+
- Added `GetRequiredService` extension method for `IChatClient`/`IEmbeddingGenerator`.
82+
- Added non-generic `IEmbeddingGenerator` interface, which is inherited by `IEmbeddingGenerator<TInput, TEmbedding>`. The `GetService` method moves down to the non-generic interface, and the `GetService`/`GetRequiredService` extension methods are now in terms of the non-generic.
83+
- `AIJsonUtilities.CreateFunctionJsonSchema` now special-cases `CancellationToken` to not include it in the schema.
84+
- Improved the debugger displays for `ChatMessage` and the `AIContent` types.
85+
- Added a static `AIJsonUtilities.HashDataToString` method.
86+
- Split `DataContent`, which handled both in-memory data and URIs to remote data, into `DataContent` (for the former) and `UriContent` (for the latter).
87+
- Renamed `DataContent.MediaTypeStartsWith` to `DataContent.HasTopLevelMediaType`, and changed semantics accordingly.
88+
89+
## 9.3.0-preview.1.25114.11
90+
91+
- Renamed `IChatClient.Complete{Streaming}Async` to `IChatClient.Get{Streaming}ResponseAsync`. This is to avoid confusion with "Complete" being about stopping an operation, as well as to avoid tying the methods to a particular implementation detail of how responses are generated. Along with this, renamed `ChatCompletion` to `ChatResponse`, `StreamingChatCompletionUpdate` to `ChatResponseUpdate`, `CompletionId` to `ResponseId`, `ToStreamingChatCompletionUpdates` to `ToChatResponseUpdates`, and `ToChatCompletion{Async}` to `ToChatResponse{Async}`.
92+
- Removed `IChatClient.Metadata` and `IEmbeddingGenerator.Metadata`. The `GetService` method may be used to retrieve `ChatClientMetadata` and `EmbeddingGeneratorMetadata`, respectively.
93+
- Added overloads of `Get{Streaming}ResponseAsync` that accept a single `ChatMessage` (in addition to the other overloads that accept a `List<ChatMessage>` or a `string`).
94+
- Added `ChatThreadId` properties to `ChatOptions`, `ChatResponse`, and `ChatResponseUpdate`. `IChatClient` can now be used in both stateful and stateless modes of operation, such as with agents that maintain server-side chat history.
95+
- Made `ChatOptions.ToolMode` nullable and added a `None` option.
96+
- Changed `UsageDetails`'s properties from `int?` to `long?`.
97+
- Removed `DataContent.ContainsData`; `DataContent.Data.HasValue` may be used instead.
98+
- Removed `ImageContent` and `AudioContent`; the base `DataContent` should now be used instead, with a new `DataContent.MediaTypeStartsWith` helper for routing based on media type.
99+
- Removed setters on `FunctionCallContent` and `FunctionResultContent` properties where the value is supplied to the constructor.
100+
- Removed `FunctionResultContent.Name`.
101+
- Augmented the base `AITool` with `Name`, `Description`, and `AdditionalProperties` virtual properties.
102+
- Added a `CodeInterpreterTool` for use with services that support server-side code execution.
103+
- Changed `AIFunction`'s schema representation to be for the whole function rather than per parameter, and exposed corresponding methods on `AIJsonUtilities`, e.g. `CreateFunctionJsonSchema`.
104+
- Removed `AIFunctionParameterMetadata` and `AIFunctionReturnParameterMetadata` classes and corresponding properties on `AIFunction` and `AIFunctionFactoryCreateOptions`, replacing them with a `MethodInfo?`. All relevant metadata, such as the JSON schema for the function, are moved to properties directly on `AIFunction`.
105+
- Renamed `AIFunctionFactoryCreateOptions` to `AIFunctionFactoryOptions` and made all its properties nullable.
106+
- Changed `AIJsonUtilities.DefaultOptions` to use relaxed JSON escaping.
107+
- Made `IEmbeddingGenerator<TInput, TEmbedding>` contravariant on `TInput`.
108+
109+
## 9.1.0-preview.1.25064.3
110+
111+
- Added `AdditionalPropertiesDictionary<TValue>` and changed `UsageDetails.AdditionalProperties` to be named `AdditionalCounts` and to be of type `AdditionalPropertiesDictionary<long>`.
112+
- Updated `FunctionCallingChatClient` to sum all `UsageDetails` token counts from all intermediate messages.
113+
- Fixed JSON schema generation for floating-point types.
114+
- Added `AddAIContentType` for enabling custom `AIContent`-derived types to participate in polymorphic serialization.
115+
116+
## 9.0.1-preview.1.24570.5
117+
118+
- Changed `IChatClient`/`IEmbeddingGenerator`.`GetService` to be non-generic.
119+
- Added `ToChatCompletion` / `ToChatCompletionUpdate` extension methods for `IEnumerable<StreamingChatCompletionUpdate>` / `IAsyncEnumerable<StreamingChatCompletionUpdate>`, respectively.
120+
- Added `ToStreamingChatCompletionUpdates` instance method to `ChatCompletion`.
121+
- Added `IncludeTypeInEnumSchemas`, `DisallowAdditionalProperties`, `RequireAllProperties`, and `TransformSchemaNode` options to `AIJsonSchemaCreateOptions`.
122+
- Fixed a Native AOT warning in `AIFunctionFactory.Create`.
123+
- Fixed a bug in `AIJsonUtilities` in the handling of Boolean schemas.
124+
- Improved the `ToString` override of `ChatMessage` and `StreamingChatCompletionUpdate` to include all `TextContent`, and of `ChatCompletion` to include all choices.
125+
- Added `DebuggerDisplay` attributes to `DataContent` and `GeneratedEmbeddings`.
126+
- Improved the documentation.
127+
128+
## 9.0.0-preview.9.24556.5
129+
130+
- Added a strongly-typed `ChatOptions.Seed` property.
131+
- Improved `AdditionalPropertiesDictionary` with a `TryAdd` method, a strongly-typed `Enumerator`, and debugger-related attributes for improved debuggability.
132+
- Fixed `AIJsonUtilities` schema generation for Boolean schemas.
133+
134+
## 9.0.0-preview.9.24525.1
135+
136+
- Lowered the required version of System.Text.Json to 8.0.5 when targeting net8.0 or older.
137+
- Annotated `FunctionCallContent.Exception` and `FunctionResultContent.Exception` as `[JsonIgnore]`, such that they're ignored when serializing instances with `JsonSerializer`. The corresponding constructors accepting an `Exception` were removed.
138+
- Annotated `ChatCompletion.Message` as `[JsonIgnore]`, such that it's ignored when serializing instances with `JsonSerializer`.
139+
- Added the `FunctionCallContent.CreateFromParsedArguments` method.
140+
- Added the `AdditionalPropertiesDictionary.TryGetValue<T>` method.
141+
- Added the `StreamingChatCompletionUpdate.ModelId` property and removed the `AIContent.ModelId` property.
142+
- Renamed the `GenerateAsync` extension method on `IEmbeddingGenerator<,>` to `GenerateEmbeddingsAsync` and updated it to return `Embedding<T>` rather than `GeneratedEmbeddings`.
143+
- Added `GenerateAndZipAsync` and `GenerateEmbeddingVectorAsync` extension methods for `IEmbeddingGenerator<,>`.
144+
- Added the `EmbeddingGeneratorOptions.Dimensions` property.
145+
- Added the `ChatOptions.TopK` property.
146+
- Normalized `null` inputs in `TextContent` to be empty strings.
147+
148+
## 9.0.0-preview.9.24507.7
149+
150+
- Initial Preview

src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatMessage.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using System.Diagnostics.CodeAnalysis;
88
using System.Text.Json.Serialization;
99

10+
#pragma warning disable S3358 // Ternary operators should not be nested
11+
1012
namespace Microsoft.Extensions.AI;
1113

1214
/// <summary>Represents a chat message used by an <see cref="IChatClient" />.</summary>
@@ -107,7 +109,17 @@ public IList<AIContent> Contents
107109

108110
/// <summary>Gets a <see cref="AIContent"/> object to display in the debugger display.</summary>
109111
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
110-
private AIContent? ContentForDebuggerDisplay => _contents is { Count: > 0 } ? _contents[0] : null;
112+
private AIContent? ContentForDebuggerDisplay
113+
{
114+
get
115+
{
116+
string text = Text;
117+
return
118+
!string.IsNullOrWhiteSpace(text) ? new TextContent(text) :
119+
_contents is { Count: > 0 } ? _contents[0] :
120+
null;
121+
}
122+
}
111123

112124
/// <summary>Gets an indication for the debugger display of whether there's more content.</summary>
113125
[DebuggerBrowsable(DebuggerBrowsableState.Never)]

0 commit comments

Comments
 (0)