Skip to content

Commit d8a74d8

Browse files
committed
Merge remote-tracking branch 'upstream/main' into conversationid
2 parents f8ce0a6 + c095888 commit d8a74d8

File tree

25 files changed

+309
-64
lines changed

25 files changed

+309
-64
lines changed

src/Libraries/Microsoft.Extensions.AI.Abstractions/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22

33
## NOT YET RELEASED
44

5+
- Updated `AIFunctionFactory` to respect `[DisplayName(...)]` on functions as a way to override the function name.
6+
- Updated `AIFunctionFactory` to respect `[DefaultValue(...)]` on function parameters as a way to specify default values.
7+
8+
## 9.10.1
9+
510
- Updated `HostedMcpServerTool` to allow for non-`Uri` server addresses, in order to enable built-in names.
611
- Updated `HostedMcpServerTool` to replace the header collection with an `AuthorizationToken` property.
12+
- Fixed `ToChatResponse{Async}` to not discard `TextReasoningContent.ProtectedData` when coalescing messages.
13+
- Fixed `AIFunctionFactory.Create` to special-case return types of `AIContent` and `IEnumerable<AIContent>` to not automatically JSON serialize them.
714

815
## 9.10.0
916

src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/UserInputRequestContent.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.Diagnostics.CodeAnalysis;
6+
using System.Text.Json.Serialization;
67
using Microsoft.Shared.Diagnostics;
78

89
namespace Microsoft.Extensions.AI;
@@ -11,6 +12,9 @@ namespace Microsoft.Extensions.AI;
1112
/// Represents a request for user input.
1213
/// </summary>
1314
[Experimental("MEAI001")]
15+
[JsonPolymorphic(TypeDiscriminatorPropertyName = "$type")]
16+
[JsonDerivedType(typeof(FunctionApprovalRequestContent), "functionApprovalRequest")]
17+
[JsonDerivedType(typeof(McpServerToolApprovalRequestContent), "mcpServerToolApprovalRequest")]
1418
public class UserInputRequestContent : AIContent
1519
{
1620
/// <summary>

src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/UserInputResponseContent.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.Diagnostics.CodeAnalysis;
6+
using System.Text.Json.Serialization;
67
using Microsoft.Shared.Diagnostics;
78

89
namespace Microsoft.Extensions.AI;
@@ -11,6 +12,9 @@ namespace Microsoft.Extensions.AI;
1112
/// Represents the response to a request for user input.
1213
/// </summary>
1314
[Experimental("MEAI001")]
15+
[JsonPolymorphic(TypeDiscriminatorPropertyName = "$type")]
16+
[JsonDerivedType(typeof(FunctionApprovalResponseContent), "functionApprovalResponse")]
17+
[JsonDerivedType(typeof(McpServerToolApprovalResponseContent), "mcpServerToolApprovalResponse")]
1418
public class UserInputResponseContent : AIContent
1519
{
1620
/// <summary>

src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.Defaults.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ private static JsonSerializerOptions CreateDefaultOptions()
121121

122122
// Temporary workaround: These should be implicitly added in once they're no longer [Experimental]
123123
// and are included via [JsonDerivedType] on AIContent.
124+
[JsonSerializable(typeof(UserInputRequestContent))]
125+
[JsonSerializable(typeof(UserInputResponseContent))]
124126
[JsonSerializable(typeof(FunctionApprovalRequestContent))]
125127
[JsonSerializable(typeof(FunctionApprovalResponseContent))]
126128
[JsonSerializable(typeof(McpServerToolCallContent))]

src/Libraries/Microsoft.Extensions.AI.AzureAIInference/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release History
22

3+
## 9.10.1-preview.1.25521.4
4+
5+
- No changes.
6+
37
## 9.10.0-preview.1.25513.3
48

59
- Updated to accommodate the additions in `Microsoft.Extensions.AI.Abstractions`.

src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/package-lock.json

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Libraries/Microsoft.Extensions.AI.OpenAI/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Release History
22

3-
## NOT YET RELEASED
3+
## 9.10.1-preview.1.25521.4
44

5-
- Updated `IChatClient` for Responses API to support connectors with `HostedMcpServerTool`.
5+
- Updated the `IChatClient` for the OpenAI Responses API to support connectors with `HostedMcpServerTool`.
6+
- Fixed the `IChatClient` for the OpenAI Responses API to roundtrip a `ResponseItem` stored in an `AIContent` in a `ChatRole.User` message.
67
- Updated to accommodate the additions in `Microsoft.Extensions.AI.Abstractions`.
78

89
## 9.10.0-preview.1.25513.3

src/Libraries/Microsoft.Extensions.AI/CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Release History
22

3-
## NOT YET RELEASED
3+
## 9.10.1
4+
5+
- Added an `[Experimental]` implementation of tool reduction component for constraining the set of tools exposed.
6+
- Fixed `SummarizingChatReducer` to preserve function calling content in the chat history.
47

58
## 9.10.0
69

src/Libraries/Microsoft.Extensions.AI/ChatCompletion/OpenTelemetryChatClient.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ internal static string SerializeChatMessages(
239239
message.Role == ChatRole.Tool ? "tool" :
240240
message.Role == ChatRole.System || message.Role == new ChatRole("developer") ? "system" :
241241
"user",
242+
Name = message.AuthorName,
242243
};
243244

244245
foreach (AIContent content in message.Contents)
@@ -595,6 +596,7 @@ private void AddOutputMessagesTags(ChatResponse response, Activity? activity)
595596
private sealed class OtelMessage
596597
{
597598
public string? Role { get; set; }
599+
public string? Name { get; set; }
598600
public List<object> Parts { get; set; } = [];
599601
public string? FinishReason { get; set; }
600602
}

src/Libraries/Microsoft.Extensions.ServiceDiscovery.Abstractions/ServiceEndpoint.cs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
45
using System.Net;
56
using Microsoft.AspNetCore.Http.Features;
67
using Microsoft.Extensions.ServiceDiscovery.Internal;
@@ -34,4 +35,52 @@ public static ServiceEndpoint Create(EndPoint endPoint, IFeatureCollection? feat
3435

3536
return new ServiceEndpointImpl(endPoint, features);
3637
}
38+
39+
/// <summary>
40+
/// Tries to convert a specified string representation to its <see cref="ServiceEndpoint"/> equivalent,
41+
/// and returns a value that indicates whether the conversion succeeded.
42+
/// </summary>
43+
/// <param name="value">A string that consists of an IP address or hostname, optionally followed by a colon and port number, or a URI.</param>
44+
/// <param name="serviceEndpoint">When this method returns, contains the equivalent <see cref="ServiceEndpoint"/> if the conversion succeeded; otherwise,
45+
/// <see langword="null"/>. This parameter is passed uninitialized; any value originally supplied will be overwritten.</param>
46+
/// <returns><see langword="true"/> if the string was successfully parsed into a <see cref="ServiceEndpoint"/>; otherwise, <see langword="false"/>.</returns>
47+
public static bool TryParse([NotNullWhen(true)] string? value,
48+
[NotNullWhen(true)] out ServiceEndpoint? serviceEndpoint)
49+
{
50+
EndPoint? endPoint = TryParseEndPoint(value);
51+
52+
if (endPoint != null)
53+
{
54+
serviceEndpoint = Create(endPoint);
55+
return true;
56+
}
57+
else
58+
{
59+
serviceEndpoint = null;
60+
return false;
61+
}
62+
}
63+
64+
private static EndPoint? TryParseEndPoint(string? value)
65+
{
66+
if (!string.IsNullOrWhiteSpace(value))
67+
{
68+
#pragma warning disable CS8602
69+
if (value.IndexOf("://", StringComparison.Ordinal) < 0 && Uri.TryCreate($"fakescheme://{value}", default, out var uri))
70+
#pragma warning restore CS8602
71+
{
72+
var port = uri.Port > 0 ? uri.Port : 0;
73+
return IPAddress.TryParse(uri.Host, out var ip)
74+
? new IPEndPoint(ip, port)
75+
: new DnsEndPoint(uri.Host, port);
76+
}
77+
78+
if (Uri.TryCreate(value, default, out uri))
79+
{
80+
return new UriEndPoint(uri);
81+
}
82+
}
83+
84+
return null;
85+
}
3786
}

0 commit comments

Comments
 (0)