Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3d61789

Browse files
authored
Add AsChatClient for OpenAIResponseClient (#6103)
* Add AsChatClient for OpenAIResponseClient* Address feedback
1 parenta2aa47e commit3d61789

File tree

15 files changed

+1031
-40
lines changed

15 files changed

+1031
-40
lines changed

‎eng/packages/General.props‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<PackageVersionInclude="Microsoft.IO.RecyclableMemoryStream"Version="3.0.0" />
1414
<PackageVersionInclude="Microsoft.ML.Tokenizers"Version="$(MicrosoftMLTokenizersVersion)" />
1515
<PackageVersionInclude="Newtonsoft.Json"Version="13.0.3" />
16-
<PackageVersionInclude="OpenAI"Version="2.2.0-beta.1" />
16+
<PackageVersionInclude="OpenAI"Version="2.2.0-beta.3" />
1717
<PackageVersionInclude="Polly"Version="8.4.2" />
1818
<PackageVersionInclude="Polly.Core"Version="8.4.2" />
1919
<PackageVersionInclude="Polly.Extensions"Version="8.4.2" />

‎eng/packages/TestOnly.props‎

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

‎src/Libraries/Microsoft.Extensions.AI.Abstractions/CodeInterpreterTool.cs‎

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespaceMicrosoft.Extensions.AI;
5+
6+
/// <summary>Represents a hosted tool that can be specified to an AI service to enable it to execute code it generates.</summary>
7+
/// <remarks>
8+
/// This tool does not itself implement code interpretation. It is a marker that can be used to inform a service
9+
/// that the service is allowed to execute its generated code if the service is capable of doing so.
10+
/// </remarks>
11+
publicclassHostedCodeInterpreterTool:AITool
12+
{
13+
/// <summary>Initializes a new instance of the <see cref="HostedCodeInterpreterTool"/> class.</summary>
14+
publicHostedCodeInterpreterTool()
15+
{
16+
}
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespaceMicrosoft.Extensions.AI;
5+
6+
/// <summary>Represents a hosted tool that can be specified to an AI service to enable it to perform web searches.</summary>
7+
/// <remarks>
8+
/// This tool does not itself implement web searches. It is a marker that can be used to inform a service
9+
/// that the service is allowed to perform web searches if the service is capable of doing so.
10+
/// </remarks>
11+
publicclassHostedWebSearchTool:AITool
12+
{
13+
/// <summary>Initializes a new instance of the <see cref="HostedWebSearchTool"/> class.</summary>
14+
publicHostedWebSearchTool()
15+
{
16+
}
17+
}

‎src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIAssistantClient.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ strictObj is bool strictValue ?
230230
runOptions.ToolsOverride.Add(ToolDefinition.CreateFunction(aiFunction.Name,aiFunction.Description,functionParameters,strict));
231231
break;
232232

233-
caseCodeInterpreterTool:
233+
caseHostedCodeInterpreterTool:
234234
runOptions.ToolsOverride.Add(ToolDefinition.CreateCodeInterpreter());
235235
break;
236236
}

‎src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIClientExtensions.cs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
usingOpenAI.Assistants;
66
usingOpenAI.Chat;
77
usingOpenAI.Embeddings;
8+
usingOpenAI.Responses;
89

910
namespaceMicrosoft.Extensions.AI;
1011

@@ -24,6 +25,12 @@ public static IChatClient AsChatClient(this OpenAIClient openAIClient, string mo
2425
publicstaticIChatClientAsChatClient(thisChatClientchatClient)=>
2526
newOpenAIChatClient(chatClient);
2627

28+
/// <summary>Gets an <see cref="IChatClient"/> for use with this <see cref="OpenAIResponseClient"/>.</summary>
29+
/// <param name="responseClient">The client.</param>
30+
/// <returns>An <see cref="IChatClient"/> that can be used to converse via the <see cref="OpenAIResponseClient"/>.</returns>
31+
publicstaticIChatClientAsChatClient(thisOpenAIResponseClientresponseClient)=>
32+
newOpenAIResponseChatClient(responseClient);
33+
2734
#pragma warning disableOPENAI001// Type is for evaluation purposes only
2835
/// <summary>Gets an <see cref="IChatClient"/> for use with this <see cref="AssistantClient"/>.</summary>
2936
/// <param name="assistantClient">The client.</param>

‎src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIModelMapper.ChatCompletion.cs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
usingSystem;
55
usingSystem.Collections.Generic;
66
usingSystem.Diagnostics.CodeAnalysis;
7-
usingSystem.Globalization;
87
usingSystem.Text;
98
usingSystem.Text.Json;
109
usingSystem.Text.Json.Serialization;
@@ -620,7 +619,7 @@ private static FunctionCallContent ParseCallContentFromBinaryData(BinaryData ut8
620619
privatestaticT?GetValueOrDefault<T>(thisAdditionalPropertiesDictionary?dict,stringkey)=>
621620
dict?.TryGetValue(key,outT?value)istrue?value:default;
622621

623-
privatestaticstringCreateCompletionId()=>$"chatcmpl-{Guid.NewGuid().ToString("N",CultureInfo.InvariantCulture)}";
622+
privatestaticstringCreateCompletionId()=>$"chatcmpl-{Guid.NewGuid():N}";
624623

625624
/// <summary>Used to create the JSON payload for an OpenAI chat tool description.</summary>
626625
publicsealedclassOpenAIChatToolJson
@@ -633,6 +632,9 @@ public sealed class OpenAIChatToolJson
633632

634633
[JsonPropertyName("properties")]
635634
publicDictionary<string,JsonElement>Properties{get;set;}=[];
635+
636+
[JsonPropertyName("additionalProperties")]
637+
publicboolAdditionalProperties{get;set;}
636638
}
637639

638640
/// <summary>POCO representing function calling info. Used to concatenation information for a single function call from across multiple streaming updates.</summary>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp