Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Anthropic.SDK.Tests/Anthropic.SDK.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
<ItemGroup>
<PackageReference Include="Google.Cloud.AIPlatform.V1" Version="3.24.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.AI" Version="9.3.0-preview.1.25161.3" />
<PackageReference Include="Microsoft.Extensions.AI" Version="9.4.0-preview.1.25207.5" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="Microsoft.SemanticKernel" Version="1.42.0" />
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" Version="1.42.0" />
<PackageReference Include="Microsoft.SemanticKernel" Version="1.47.0" />
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" Version="1.47.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.8.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.8.2" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
Expand Down
2 changes: 1 addition & 1 deletion Anthropic.SDK.Tests/Messages.ChatClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public async Task TestThinkingStreamingConversation()

messages.AddMessages(updates);

Assert.IsTrue(messages.Last().Contents.OfType<Extensions.MEAI.ThinkingContent>().Any());
Assert.IsTrue(messages.Last().Contents.OfType<Microsoft.Extensions.AI.TextReasoningContent>().Any());

messages.Add(new ChatMessage(ChatRole.User, "and how many letters total?"));

Expand Down
2 changes: 1 addition & 1 deletion Anthropic.SDK.Tests/VertexAI.ChatClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public async Task TestThinkingStreamingConversation()

messages.AddMessages(updates);

Assert.IsTrue(messages.Last().Contents.OfType<Extensions.MEAI.ThinkingContent>().Any());
Assert.IsTrue(messages.Last().Contents.OfType<Microsoft.Extensions.AI.TextReasoningContent>().Any());

messages.Add(new ChatMessage(ChatRole.User, "and how many letters total?"));

Expand Down
2 changes: 1 addition & 1 deletion Anthropic.SDK/Anthropic.SDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.AI.Abstractions" Version="9.3.0-preview.1.25161.3" />
<PackageReference Include="Microsoft.Extensions.AI.Abstractions" Version="9.4.0-preview.1.25207.5" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
</ItemGroup>

Expand Down
13 changes: 0 additions & 13 deletions Anthropic.SDK/Extensions/MEAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,6 @@

namespace Anthropic.SDK.Extensions.MEAI
{
public sealed class ThinkingContent : Microsoft.Extensions.AI.AIContent
{
public ThinkingContent(string thinking, string signature)
{
Thinking = thinking;
Signature = signature;
}
public string Thinking { get; set; }

public string Signature { get; set; }
public override string ToString() => Thinking;
}

public sealed class RedactedThinkingContent : Microsoft.Extensions.AI.AIContent
{
public RedactedThinkingContent(string data)
Expand Down
16 changes: 13 additions & 3 deletions Anthropic.SDK/Messaging/ChatClientHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,12 @@ public static MessageParameters CreateMessageParameters(IEnumerable<ChatMessage>
{
switch (content)
{
case Anthropic.SDK.Extensions.MEAI.ThinkingContent thinkingContent:
m.Content.Add(new Messaging.ThinkingContent() { Thinking = thinkingContent.Thinking, Signature = thinkingContent.Signature });
case Microsoft.Extensions.AI.TextReasoningContent textReasoningContent:
m.Content.Add(new Messaging.ThinkingContent()
{
Thinking = textReasoningContent.Text,
Signature = textReasoningContent.AdditionalProperties[nameof(ThinkingContent.Signature)]?.ToString()
});
break;

case Anthropic.SDK.Extensions.MEAI.RedactedThinkingContent redactedThinkingContent:
Expand Down Expand Up @@ -182,7 +186,13 @@ public static List<AIContent> ProcessResponseContent(MessageResponse response)
switch (content)
{
case Messaging.ThinkingContent thinkingContent:
contents.Add(new Anthropic.SDK.Extensions.MEAI.ThinkingContent(thinkingContent.Thinking, thinkingContent.Signature));
contents.Add(new Microsoft.Extensions.AI.TextReasoningContent(thinkingContent.Thinking)
{
AdditionalProperties = new AdditionalPropertiesDictionary
{
[nameof(ThinkingContent.Signature)] = thinkingContent.Signature
}
});
break;

case Messaging.RedactedThinkingContent redactedThinkingContent:
Expand Down
8 changes: 7 additions & 1 deletion Anthropic.SDK/Messaging/MessagesEndpoint.ChatClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,13 @@ async IAsyncEnumerable<ChatResponseUpdate> IChatClient.GetStreamingResponseAsync

if (!string.IsNullOrEmpty(response.Delta.Signature))
{
update.Contents.Add(new Anthropic.SDK.Extensions.MEAI.ThinkingContent(thinking, response.Delta.Signature));
update.Contents.Add(new TextReasoningContent(thinking)
{
AdditionalProperties = new AdditionalPropertiesDictionary
{
[nameof(ThinkingContent.Signature)] = response.Delta.Signature
}
});
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@ async IAsyncEnumerable<ChatResponseUpdate> IChatClient.GetStreamingResponseAsync

if (!string.IsNullOrEmpty(response.Delta.Signature))
{
update.Contents.Add(new Anthropic.SDK.Extensions.MEAI.ThinkingContent(thinking, response.Delta.Signature));
update.Contents.Add(new Microsoft.Extensions.AI.TextReasoningContent(thinking)
{
AdditionalProperties = new AdditionalPropertiesDictionary
{
[nameof(ThinkingContent.Signature)] = response.Delta.Signature
}
});
}


Expand Down
Loading