-
Notifications
You must be signed in to change notification settings - Fork 1.3k
.NET: Fix anthropic integration tests and skip reason #4211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,13 @@ | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| using System; | ||
| using System.Threading.Tasks; | ||
| using AgentConformance.IntegrationTests; | ||
|
|
||
| namespace AnthropicChatCompletion.IntegrationTests; | ||
|
|
||
| public abstract class SkipAllChatClientRunStreaming(Func<AnthropicChatCompletionFixture> func) : ChatClientAgentRunStreamingTests<AnthropicChatCompletionFixture>(func) | ||
| { | ||
| public override Task RunWithFunctionsInvokesFunctionsAndReturnsExpectedResultsAsync() | ||
| { | ||
| Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); | ||
| return base.RunWithFunctionsInvokesFunctionsAndReturnsExpectedResultsAsync(); | ||
| } | ||
| public class AnthropicBetaChatCompletionChatClientAgentReasoningRunStreamingTests() : ChatClientAgentRunStreamingTests<AnthropicChatCompletionFixture>(() => new(useReasoningChatModel: true, useBeta: true)); | ||
|
|
||
| public override Task RunWithInstructionsAndNoMessageReturnsExpectedResultAsync() | ||
| { | ||
| Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); | ||
| return base.RunWithInstructionsAndNoMessageReturnsExpectedResultAsync(); | ||
| } | ||
| } | ||
| public class AnthropicBetaChatCompletionChatClientAgentRunStreamingTests() : ChatClientAgentRunStreamingTests<AnthropicChatCompletionFixture>(() => new(useReasoningChatModel: false, useBeta: true)); | ||
|
|
||
| public class AnthropicBetaChatCompletionChatClientAgentReasoningRunStreamingTests() : SkipAllChatClientRunStreaming(() => new(useReasoningChatModel: true, useBeta: true)); | ||
| public class AnthropicChatCompletionChatClientAgentRunStreamingTests() : ChatClientAgentRunStreamingTests<AnthropicChatCompletionFixture>(() => new(useReasoningChatModel: false, useBeta: false)); | ||
|
|
||
| public class AnthropicBetaChatCompletionChatClientAgentRunStreamingTests() : SkipAllChatClientRunStreaming(() => new(useReasoningChatModel: false, useBeta: true)); | ||
|
|
||
| public class AnthropicChatCompletionChatClientAgentRunStreamingTests() : SkipAllChatClientRunStreaming(() => new(useReasoningChatModel: false, useBeta: false)); | ||
|
|
||
| public class AnthropicChatCompletionChatClientAgentReasoningRunStreamingTests() : SkipAllChatClientRunStreaming(() => new(useReasoningChatModel: true, useBeta: false)); | ||
| public class AnthropicChatCompletionChatClientAgentReasoningRunStreamingTests() : ChatClientAgentRunStreamingTests<AnthropicChatCompletionFixture>(() => new(useReasoningChatModel: true, useBeta: false)); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,17 @@ | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| using System; | ||
| using System.Threading.Tasks; | ||
| using AgentConformance.IntegrationTests; | ||
|
|
||
| namespace AnthropicChatCompletion.IntegrationTests; | ||
|
|
||
| public abstract class SkipAllChatClientAgentRun(Func<AnthropicChatCompletionFixture> func) : ChatClientAgentRunTests<AnthropicChatCompletionFixture>(func) | ||
| { | ||
| public override Task RunWithFunctionsInvokesFunctionsAndReturnsExpectedResultsAsync() | ||
| { | ||
| Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); | ||
| return base.RunWithFunctionsInvokesFunctionsAndReturnsExpectedResultsAsync(); | ||
| } | ||
|
|
||
| public override Task RunWithInstructionsAndNoMessageReturnsExpectedResultAsync() | ||
| { | ||
| Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); | ||
| return base.RunWithInstructionsAndNoMessageReturnsExpectedResultAsync(); | ||
| } | ||
| } | ||
|
|
||
| public class AnthropicBetaChatCompletionChatClientAgentRunTests() | ||
| : SkipAllChatClientAgentRun(() => new(useReasoningChatModel: false, useBeta: true)); | ||
| : ChatClientAgentRunTests<AnthropicChatCompletionFixture>(() => new(useReasoningChatModel: false, useBeta: true)); | ||
|
|
||
| public class AnthropicBetaChatCompletionChatClientAgentReasoningRunTests() | ||
| : SkipAllChatClientAgentRun(() => new(useReasoningChatModel: true, useBeta: true)); | ||
| : ChatClientAgentRunTests<AnthropicChatCompletionFixture>(() => new(useReasoningChatModel: true, useBeta: true)); | ||
|
|
||
| public class AnthropicChatCompletionChatClientAgentRunTests() | ||
| : SkipAllChatClientAgentRun(() => new(useReasoningChatModel: false, useBeta: false)); | ||
| : ChatClientAgentRunTests<AnthropicChatCompletionFixture>(() => new(useReasoningChatModel: false, useBeta: false)); | ||
|
|
||
| public class AnthropicChatCompletionChatClientAgentReasoningRunTests() | ||
| : SkipAllChatClientAgentRun(() => new(useReasoningChatModel: true, useBeta: false)); | ||
| : ChatClientAgentRunTests<AnthropicChatCompletionFixture>(() => new(useReasoningChatModel: true, useBeta: false)); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,7 +20,6 @@ public class AnthropicChatCompletionFixture : IChatClientAgentFixture | |||||
| // All tests for Anthropic are intended to be ran locally as the CI pipeline for Anthropic is not setup. | ||||||
| internal const string SkipReason = "Integrations tests for local execution only"; | ||||||
|
|
||||||
| private static readonly AnthropicConfiguration s_config = TestConfiguration.LoadSection<AnthropicConfiguration>(); | ||||||
| private readonly bool _useReasoningModel; | ||||||
| private readonly bool _useBeta; | ||||||
|
|
||||||
|
|
@@ -53,7 +52,8 @@ public Task<ChatClientAgent> CreateChatClientAgentAsync( | |||||
| string instructions = "You are a helpful assistant.", | ||||||
| IList<AITool>? aiTools = null) | ||||||
| { | ||||||
| var anthropicClient = new AnthropicClient() { ApiKey = s_config.ApiKey }; | ||||||
| AnthropicConfiguration config = TestConfiguration.LoadSection<AnthropicConfiguration>(); | ||||||
| var anthropicClient = new AnthropicClient() { ApiKey = config.ApiKey }; | ||||||
|
|
||||||
| IChatClient? chatClient = this._useBeta | ||||||
| ? anthropicClient | ||||||
|
|
@@ -64,7 +64,7 @@ public Task<ChatClientAgent> CreateChatClientAgentAsync( | |||||
| => options.RawRepresentationFactory = _ | ||||||
| => new Anthropic.Models.Beta.Messages.MessageCreateParams() | ||||||
| { | ||||||
| Model = options.ModelId ?? (this._useReasoningModel ? s_config.ChatReasoningModelId : s_config.ChatModelId), | ||||||
| Model = options.ModelId ?? (this._useReasoningModel ? config.ChatReasoningModelId : config.ChatModelId), | ||||||
| MaxTokens = options.MaxOutputTokens ?? 4096, | ||||||
| Messages = [], | ||||||
| Thinking = this._useReasoningModel | ||||||
|
|
@@ -79,7 +79,7 @@ public Task<ChatClientAgent> CreateChatClientAgentAsync( | |||||
| => options.RawRepresentationFactory = _ | ||||||
| => new Anthropic.Models.Messages.MessageCreateParams() | ||||||
| { | ||||||
| Model = options.ModelId ?? (this._useReasoningModel ? s_config.ChatReasoningModelId : s_config.ChatModelId), | ||||||
| Model = options.ModelId ?? (this._useReasoningModel ? config.ChatReasoningModelId : config.ChatModelId), | ||||||
| MaxTokens = options.MaxOutputTokens ?? 4096, | ||||||
| Messages = [], | ||||||
| Thinking = this._useReasoningModel | ||||||
|
|
@@ -102,8 +102,11 @@ public Task DeleteSessionAsync(AgentSession session) => | |||||
| // Chat Completion does not require/support deleting sessions, so this is a no-op. | ||||||
| Task.CompletedTask; | ||||||
|
|
||||||
| public async ValueTask InitializeAsync() => | ||||||
| public async ValueTask InitializeAsync() | ||||||
| { | ||||||
| Assert.SkipWhen(SkipReason is not null, SkipReason ?? string.Empty); | ||||||
|
||||||
| Assert.SkipWhen(SkipReason is not null, SkipReason ?? string.Empty); | |
| Assert.Skip(SkipReason); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,52 +1,17 @@ | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| using System; | ||
| using System.Threading.Tasks; | ||
| using AgentConformance.IntegrationTests; | ||
|
|
||
| namespace AnthropicChatCompletion.IntegrationTests; | ||
|
|
||
| public abstract class SkipAllRunStreaming(Func<AnthropicChatCompletionFixture> func) : RunStreamingTests<AnthropicChatCompletionFixture>(func) | ||
| { | ||
| public override Task RunWithChatMessageReturnsExpectedResultAsync() | ||
| { | ||
| Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); | ||
| return base.RunWithChatMessageReturnsExpectedResultAsync(); | ||
| } | ||
|
|
||
| public override Task RunWithNoMessageDoesNotFailAsync() | ||
| { | ||
| Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); | ||
| return base.RunWithNoMessageDoesNotFailAsync(); | ||
| } | ||
|
|
||
| public override Task RunWithChatMessagesReturnsExpectedResultAsync() | ||
| { | ||
| Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); | ||
| return base.RunWithChatMessagesReturnsExpectedResultAsync(); | ||
| } | ||
|
|
||
| public override Task RunWithStringReturnsExpectedResultAsync() | ||
| { | ||
| Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); | ||
| return base.RunWithStringReturnsExpectedResultAsync(); | ||
| } | ||
|
|
||
| public override Task SessionMaintainsHistoryAsync() | ||
| { | ||
| Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); | ||
| return base.SessionMaintainsHistoryAsync(); | ||
| } | ||
| } | ||
|
|
||
| public class AnthropicBetaChatCompletionRunStreamingTests() | ||
| : SkipAllRunStreaming(() => new(useReasoningChatModel: false, useBeta: true)); | ||
| : RunStreamingTests<AnthropicChatCompletionFixture>(() => new(useReasoningChatModel: false, useBeta: true)); | ||
|
|
||
| public class AnthropicBetaChatCompletionReasoningRunStreamingTests() | ||
| : SkipAllRunStreaming(() => new(useReasoningChatModel: true, useBeta: true)); | ||
| : RunStreamingTests<AnthropicChatCompletionFixture>(() => new(useReasoningChatModel: true, useBeta: true)); | ||
|
|
||
| public class AnthropicChatCompletionRunStreamingTests() | ||
| : SkipAllRunStreaming(() => new(useReasoningChatModel: false, useBeta: false)); | ||
| : RunStreamingTests<AnthropicChatCompletionFixture>(() => new(useReasoningChatModel: false, useBeta: false)); | ||
|
|
||
| public class AnthropicChatCompletionReasoningRunStreamingTests() | ||
| : SkipAllRunStreaming(() => new(useReasoningChatModel: true, useBeta: false)); | ||
| : RunStreamingTests<AnthropicChatCompletionFixture>(() => new(useReasoningChatModel: true, useBeta: false)); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,52 +1,17 @@ | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| using System; | ||
| using System.Threading.Tasks; | ||
| using AgentConformance.IntegrationTests; | ||
|
|
||
| namespace AnthropicChatCompletion.IntegrationTests; | ||
|
|
||
| public abstract class SkipAllRun(Func<AnthropicChatCompletionFixture> func) : RunTests<AnthropicChatCompletionFixture>(func) | ||
| { | ||
| public override Task RunWithChatMessageReturnsExpectedResultAsync() | ||
| { | ||
| Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); | ||
| return base.RunWithChatMessageReturnsExpectedResultAsync(); | ||
| } | ||
|
|
||
| public override Task RunWithNoMessageDoesNotFailAsync() | ||
| { | ||
| Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); | ||
| return base.RunWithNoMessageDoesNotFailAsync(); | ||
| } | ||
|
|
||
| public override Task RunWithChatMessagesReturnsExpectedResultAsync() | ||
| { | ||
| Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); | ||
| return base.RunWithChatMessagesReturnsExpectedResultAsync(); | ||
| } | ||
|
|
||
| public override Task RunWithStringReturnsExpectedResultAsync() | ||
| { | ||
| Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); | ||
| return base.RunWithStringReturnsExpectedResultAsync(); | ||
| } | ||
|
|
||
| public override Task SessionMaintainsHistoryAsync() | ||
| { | ||
| Assert.SkipWhen(AnthropicChatCompletionFixture.SkipReason is not null, AnthropicChatCompletionFixture.SkipReason!); | ||
| return base.SessionMaintainsHistoryAsync(); | ||
| } | ||
| } | ||
|
|
||
| public class AnthropicBetaChatCompletionRunTests() | ||
| : SkipAllRun(() => new(useReasoningChatModel: false, useBeta: true)); | ||
| : RunTests<AnthropicChatCompletionFixture>(() => new(useReasoningChatModel: false, useBeta: true)); | ||
|
|
||
| public class AnthropicBetaChatCompletionReasoningRunTests() | ||
| : SkipAllRun(() => new(useReasoningChatModel: true, useBeta: true)); | ||
| : RunTests<AnthropicChatCompletionFixture>(() => new(useReasoningChatModel: true, useBeta: true)); | ||
|
|
||
| public class AnthropicChatCompletionRunTests() | ||
| : SkipAllRun(() => new(useReasoningChatModel: false, useBeta: false)); | ||
| : RunTests<AnthropicChatCompletionFixture>(() => new(useReasoningChatModel: false, useBeta: false)); | ||
|
|
||
| public class AnthropicChatCompletionReasoningRunTests() | ||
| : SkipAllRun(() => new(useReasoningChatModel: true, useBeta: false)); | ||
| : RunTests<AnthropicChatCompletionFixture>(() => new(useReasoningChatModel: true, useBeta: false)); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -22,14 +22,15 @@ public sealed class AnthropicSkillsIntegrationTests | |||||
| // All tests for Anthropic are intended to be ran locally as the CI pipeline for Anthropic is not setup. | ||||||
| private const string SkipReason = "Integrations tests for local execution only"; | ||||||
|
||||||
| private const string SkipReason = "Integrations tests for local execution only"; | |
| private const string SkipReason = "Integration tests for local execution only"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,25 +18,25 @@ public override Task SessionMaintainsHistoryAsync() | |
|
|
||
| public override Task RunWithChatMessageReturnsExpectedResultAsync() | ||
| { | ||
| Assert.SkipWhen(ManualVerification is not null, ManualVerification!); | ||
| Assert.SkipWhen(ManualVerification is not null, ManualVerification ?? string.Empty); | ||
| return base.RunWithChatMessageReturnsExpectedResultAsync(); | ||
|
Comment on lines
+21
to
22
|
||
| } | ||
|
|
||
| public override Task RunWithChatMessagesReturnsExpectedResultAsync() | ||
| { | ||
| Assert.SkipWhen(ManualVerification is not null, ManualVerification!); | ||
| Assert.SkipWhen(ManualVerification is not null, ManualVerification ?? string.Empty); | ||
| return base.RunWithChatMessagesReturnsExpectedResultAsync(); | ||
| } | ||
|
|
||
| public override Task RunWithNoMessageDoesNotFailAsync() | ||
| { | ||
| Assert.SkipWhen(ManualVerification is not null, ManualVerification!); | ||
| Assert.SkipWhen(ManualVerification is not null, ManualVerification ?? string.Empty); | ||
| return base.RunWithNoMessageDoesNotFailAsync(); | ||
| } | ||
|
|
||
| public override Task RunWithStringReturnsExpectedResultAsync() | ||
| { | ||
| Assert.SkipWhen(ManualVerification is not null, ManualVerification!); | ||
| Assert.SkipWhen(ManualVerification is not null, ManualVerification ?? string.Empty); | ||
| return base.RunWithStringReturnsExpectedResultAsync(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,25 +18,25 @@ public override Task SessionMaintainsHistoryAsync() | |
|
|
||
| public override Task RunWithChatMessageReturnsExpectedResultAsync() | ||
| { | ||
| Assert.SkipWhen(ManualVerification is not null, ManualVerification!); | ||
| Assert.SkipWhen(ManualVerification is not null, ManualVerification ?? string.Empty); | ||
| return base.RunWithChatMessageReturnsExpectedResultAsync(); | ||
|
Comment on lines
+21
to
22
|
||
| } | ||
|
|
||
| public override Task RunWithChatMessagesReturnsExpectedResultAsync() | ||
| { | ||
| Assert.SkipWhen(ManualVerification is not null, ManualVerification!); | ||
| Assert.SkipWhen(ManualVerification is not null, ManualVerification ?? string.Empty); | ||
| return base.RunWithChatMessagesReturnsExpectedResultAsync(); | ||
| } | ||
|
|
||
| public override Task RunWithNoMessageDoesNotFailAsync() | ||
| { | ||
| Assert.SkipWhen(ManualVerification is not null, ManualVerification!); | ||
| Assert.SkipWhen(ManualVerification is not null, ManualVerification ?? string.Empty); | ||
| return base.RunWithNoMessageDoesNotFailAsync(); | ||
| } | ||
|
|
||
| public override Task RunWithStringReturnsExpectedResultAsync() | ||
| { | ||
| Assert.SkipWhen(ManualVerification is not null, ManualVerification!); | ||
| Assert.SkipWhen(ManualVerification is not null, ManualVerification ?? string.Empty); | ||
| return base.RunWithStringReturnsExpectedResultAsync(); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in the skip reason string: "Integrations tests" should be "Integration tests".