-
Notifications
You must be signed in to change notification settings - Fork 229
Add VerifySetup Eval Tests and Tool Mocks #13388
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
Draft
JennyPng
wants to merge
14
commits into
Azure:main
Choose a base branch
from
JennyPng:env-setup-eval
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9095907
basic verify setup test
JennyPng a60e411
Merge branch 'main' into env-setup-eval
JennyPng 509ea86
add more test and toolmocks for build and generate
JennyPng efc87ed
just test generate sdk for rest api specs?
JennyPng c770c88
Apply suggestions from code review
JennyPng 9c99251
Merge branch 'main' into env-setup-eval
JennyPng 312ca81
merge fix
JennyPng 436f90e
Merge branch 'env-setup-eval' of https://github.com/JennyPng/azure-sd…
JennyPng 60768e2
minor
JennyPng f24f811
..full workflow?
JennyPng 91b6d2b
more prompt refinement
JennyPng 6b88d14
moore prompt refinement
JennyPng bd42186
fix prompt?
JennyPng 356bb6b
another revision
JennyPng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...k-cli/Azure.Sdk.Tools.Cli.Evaluations/Scenarios/AzureRestApiSpecs/Evaluate_GenerateSdk.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| using Azure.Sdk.Tools.Cli.Evaluations.Evaluators; | ||
| using Azure.Sdk.Tools.Cli.Evaluations.Helpers; | ||
| using Azure.Sdk.Tools.Cli.Evaluations.Models; | ||
| using Microsoft.Extensions.AI.Evaluation; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace Azure.Sdk.Tools.Cli.Evaluations.Scenarios | ||
| { | ||
| public partial class Scenario | ||
| { | ||
| [Test] | ||
| [Category(RepositoryCategories.AzureRestApiSpecs)] | ||
| public async Task Evaluate_GenerateSdk() | ||
| { | ||
| const string prompt = "Do every step necessary to generate my SDK for Dotnet, up until testing. Proceed and don't ask me questions. Stop before running tests on the SDK. I'm in a public repo. My tspconfig is at: \"C:\\azure-rest-api-specs\\specification\\healthdataaiservices\\HealthDataAIServices.DeidServices\\tspconfig.yaml\", and the repo: \"C:\\azure-sdk-for-net\""; | ||
| string[] expectedTools = | ||
| [ | ||
| "azsdk_verify_setup", "azsdk_run_typespec_validation", "azsdk_package_generate_code","azsdk_package_build_code" | ||
| ]; | ||
|
|
||
| // Build scenario data | ||
| var scenarioData = ChatMessageHelper.LoadScenarioFromPrompt(prompt, expectedTools); | ||
|
|
||
| // External construction of evaluation context | ||
| bool checkInputs = false; | ||
|
|
||
| var result = await EvaluationHelper.RunToolInputScenarioAsync( | ||
| scenarioName: this.ScenarioName, | ||
| scenarioData: scenarioData, | ||
| chatCompletion: s_chatCompletion!, | ||
| chatConfig: s_chatConfig!, | ||
| executionName: s_executionName, | ||
| reportingPath: ReportingPath, | ||
| toolNames: s_toolNames!, | ||
| evaluators: [new ExpectedToolInputEvaluator()], | ||
| enableResponseCaching: true, | ||
| additionalContexts: new EvaluationContext[] | ||
| { | ||
| new ExpectedToolInputEvaluatorContext(scenarioData.ExpectedOutcome, s_toolNames!, checkInputs) | ||
| }); | ||
|
|
||
| EvaluationHelper.ValidateToolInputsEvaluator(result); | ||
| } | ||
| } | ||
| } |
44 changes: 44 additions & 0 deletions
44
tools/azsdk-cli/Azure.Sdk.Tools.Cli.Evaluations/Scenarios/General/Evaluate_VerifySetup.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| using Azure.Sdk.Tools.Cli.Evaluations.Evaluators; | ||
| using Azure.Sdk.Tools.Cli.Evaluations.Helpers; | ||
| using Azure.Sdk.Tools.Cli.Evaluations.Models; | ||
| using Microsoft.Extensions.AI.Evaluation; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace Azure.Sdk.Tools.Cli.Evaluations.Scenarios | ||
| { | ||
| public partial class Scenario | ||
| { | ||
| [Test] | ||
| public async Task Evaluate_VerifySetup() | ||
| { | ||
| const string prompt = "Verify my setup for Dotnet."; | ||
| string[] expectedTools = | ||
| [ | ||
| "azsdk_verify_setup" | ||
| ]; | ||
|
|
||
| // Build scenario data | ||
| var scenarioData = ChatMessageHelper.LoadScenarioFromPrompt(prompt, expectedTools); | ||
|
|
||
| // External construction of evaluation context | ||
| bool checkInputs = false; | ||
|
|
||
| var result = await EvaluationHelper.RunToolInputScenarioAsync( | ||
| scenarioName: this.ScenarioName, | ||
| scenarioData: scenarioData, | ||
| chatCompletion: s_chatCompletion!, | ||
| chatConfig: s_chatConfig!, | ||
| executionName: s_executionName, | ||
| reportingPath: ReportingPath, | ||
| toolNames: s_toolNames!, | ||
| evaluators: [new ExpectedToolInputEvaluator()], | ||
| enableResponseCaching: true, | ||
| additionalContexts: new EvaluationContext[] | ||
| { | ||
| new ExpectedToolInputEvaluatorContext(scenarioData.ExpectedOutcome, s_toolNames!, checkInputs) | ||
| }); | ||
|
|
||
| EvaluationHelper.ValidateToolInputsEvaluator(result); | ||
| } | ||
| } | ||
| } |
40 changes: 40 additions & 0 deletions
40
tools/azsdk-cli/Azure.Sdk.Tools.Cli.Evaluations/ToolMocks/PackageBuildCode.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| using Microsoft.Extensions.AI; | ||
|
|
||
| namespace Azure.Sdk.Tools.Cli.Evaluations.ToolMocks | ||
| { | ||
| public class PackageBuildCode : IToolMock | ||
| { | ||
| public string ToolName => "azsdk_package_build_code"; | ||
| public string CallId => "tooluse_l1vP7afmgopmnhjpjp"; | ||
| private string ToolResult => """{"message":"Build completed successfully.","result":"succeeded","language":"DotNet","package_name":"Azure.Health.Deidentification","version":"1.1.0-beta.2","package_type":"Unknown","sdk_repo":"","next_steps":[],"operation_status":"Succeeded"}"""; | ||
| public ChatMessage GetMockResponse(string callid) | ||
| { | ||
| return new ChatMessage( | ||
| ChatRole.Tool, | ||
| [ | ||
| new FunctionResultContent( | ||
| callid, | ||
| ToolResult | ||
| ) | ||
| ] | ||
| ); | ||
| } | ||
|
|
||
| public ChatMessage GetMockCall() | ||
| { | ||
| return new ChatMessage( | ||
| ChatRole.Assistant, | ||
| [ | ||
| new FunctionCallContent( | ||
| CallId, | ||
| ToolName, | ||
| new Dictionary<string, object?> | ||
| { | ||
| { "packagePath", "C:\\azure-sdk-for-net\\sdk\\healthdataaiservices\\Azure.Health.Deidentification" }, | ||
| } | ||
| ) | ||
| ] | ||
| ); | ||
| } | ||
| } | ||
| } | ||
43 changes: 43 additions & 0 deletions
43
tools/azsdk-cli/Azure.Sdk.Tools.Cli.Evaluations/ToolMocks/PackageGenerateCode.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| using Microsoft.Extensions.AI; | ||
|
|
||
| namespace Azure.Sdk.Tools.Cli.Evaluations.ToolMocks | ||
| { | ||
| public class PackageGenerateCode : IToolMock | ||
| { | ||
| public string ToolName => "azsdk_package_generate_code"; | ||
| public string CallId => "tooluse_l1vP7afmgopmnhgmjp"; | ||
JennyPng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private string ToolResult => """{"message":"SDK generation completed successfully using tspconfig.yaml.","result":"succeeded","language":"DotNet","package_name":"","version":"","package_type":"Unknown","sdk_repo":"azure-sdk-for-net","next_steps":["If the SDK is not Python, build the code"],"operation_status":"Succeeded"}"""; | ||
| public ChatMessage GetMockResponse(string callid) | ||
| { | ||
| return new ChatMessage( | ||
| ChatRole.Tool, | ||
| [ | ||
| new FunctionResultContent( | ||
| callid, | ||
| ToolResult | ||
| ) | ||
| ] | ||
| ); | ||
| } | ||
|
|
||
| public ChatMessage GetMockCall() | ||
| { | ||
| return new ChatMessage( | ||
| ChatRole.Assistant, | ||
| [ | ||
| new FunctionCallContent( | ||
| CallId, | ||
| ToolName, | ||
| new Dictionary<string, object?> | ||
| { | ||
| { "tspConfigPath","C:\\azure-rest-api-specs\\specification\\healthdataaiservices\\HealthDataAIServices.DeidServices\\tspconfig.yaml" }, | ||
| { "localSdkRepoPath", "C:\\azure-sdk-for-net" }, | ||
| { "tspLocationPath", "" }, | ||
| { "emitterOptions", "" } | ||
| } | ||
| ) | ||
| ] | ||
| ); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.