-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Sync eng/common directory with azure-sdk-tools for PR 13218 #44381
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| <# | ||
| .SYNOPSIS | ||
| Evaluates tool and prompt descriptions and produces a Markdown results report using Tool Description Evaluator from Mcp repo. | ||
|
|
||
| .DESCRIPTION | ||
| This script builds and runs the ToolDescriptionEvaluator (.NET) against a set of tool and prompt definitions. | ||
| It restores and compiles the evaluator, executes it with the provided JSON inputs, and emits a `results.md` | ||
| report. The script supports configuration via parameters and environment variables for the embedding model | ||
| service used during evaluation. | ||
|
|
||
| .LINK | ||
| https://github.com/microsoft/mcp/tree/main/eng/tools/ToolDescriptionEvaluator | ||
|
|
||
| .PARAMETER EvaluatorPath | ||
| The path to the evaluator project root (or its `src` directory) that will be restored, built, and executed. | ||
|
|
||
| .PARAMETER ToolsFilePath | ||
| The path to the JSON file containing tool definitions to be evaluated. | ||
|
|
||
| .PARAMETER PromptsFilePath | ||
| The path to the JSON file containing prompt definitions to be evaluated. | ||
|
|
||
| .PARAMETER OutputFilePath | ||
| The target file path where the generated `results.md` will be moved after the evaluator runs. | ||
|
|
||
| .PARAMETER AoaiEndpoint | ||
| The full endpoint URL for the embedding model (e.g., Azure OpenAI embeddings) used by the evaluator. | ||
|
|
||
| .PARAMETER TextEmbeddingApiKey | ||
| The API key used to authenticate with the embedding endpoint. Prefer providing this via a secure | ||
| secret store or environment variable rather than hard-coding. | ||
|
|
||
| .NOTES | ||
| - The evaluator emits `results.md` in the evaluator folder; this script moves it to `OutputFilePath`. | ||
| - Requires .NET SDK available on PATH. | ||
| - Set-StrictMode is enabled. | ||
|
|
||
| .EXAMPLE | ||
| .\Invoke-ToolDescriptionEvaluator.ps1 ` | ||
| -EvaluatorPath "C:\work\mcp\eng\tools\ToolDescriptionEvaluator\src" ` | ||
| -ToolsFilePath "C:\work\azure-sdk-tools\tools\azsdk-cli\azure-sdk-tools.json" ` | ||
| -PromptsFilePath "C:\work\azure-sdk-tools\tools\azsdk-cli\azure-sdk-prompts.json" ` | ||
| -OutputFilePath "C:\work\azure-sdk-tools\tools\azsdk-cli" ` | ||
| -AoaiEndpoint "https://<your-endpoint>/openai/deployments/text-embedding-3-large/embeddings?api-version=2023-05-15" ` | ||
| -TextEmbeddingApiKey (Get-Secret -Name 'TextEmbeddingApiKey') | ||
|
|
||
| Runs the evaluator with the specified tools and prompts files, then moves the generated results to the output path. | ||
| #> | ||
| param ( | ||
| [Parameter(Mandatory = $true)] | ||
| [string] $EvaluatorPath, | ||
|
|
||
| [Parameter(Mandatory = $true)] | ||
| [string] $ToolsFilePath, | ||
|
|
||
| [Parameter(Mandatory = $true)] | ||
| [string] $PromptsFilePath, | ||
|
|
||
| [Parameter(Mandatory = $true)] | ||
| [string] $OutputFilePath, | ||
|
|
||
| # Environment Variables | ||
| [Parameter(Mandatory = $true)] | ||
| [string] $AoaiEndpoint, | ||
|
|
||
| [Parameter(Mandatory = $true)] | ||
| [string] $TextEmbeddingApiKey | ||
| ) | ||
|
|
||
| Set-StrictMode -Version 3 | ||
|
|
||
| # Validate input paths | ||
| $pathsToCheck = @{ | ||
| "EvaluatorPath" = $EvaluatorPath | ||
| "ToolsFilePath" = $ToolsFilePath | ||
| "PromptsFilePath" = $PromptsFilePath | ||
| "OutputFilePath" = $OutputFilePath | ||
| } | ||
|
|
||
| foreach ($p in $pathsToCheck.GetEnumerator()) { | ||
| if (-not (Test-Path -Path $p.Value)) { | ||
| throw "Path does not exist for parameter '$($p.Key)': $($p.Value)" | ||
| } | ||
| } | ||
|
|
||
| # Build & run the evaluator | ||
| Write-Host "Changing directory to evaluator: $EvaluatorPath" | ||
| Push-Location $EvaluatorPath | ||
| try { | ||
| $env:AOAI_ENDPOINT = $AoaiEndpoint | ||
| $env:TEXT_EMBEDDING_API_KEY = $TextEmbeddingApiKey | ||
|
|
||
| Write-Host "Running Tool..." | ||
| dotnet run --configuration Release -- --tools-file "$ToolsFilePath" --prompts-file "$PromptsFilePath" | ||
| } | ||
| finally { | ||
| Pop-Location | ||
| Remove-Item Env:\AOAI_ENDPOINT -ErrorAction SilentlyContinue | ||
| Remove-Item Env:\TEXT_EMBEDDING_API_KEY -ErrorAction SilentlyContinue | ||
| } | ||
|
|
||
| # The tool emits results.md in the evaluator folder | ||
| $generatedName = 'results.md' | ||
| $EvaluatorRoot = Split-Path $EvaluatorPath -Parent | ||
| $generatedPath = Join-Path -Path $EvaluatorRoot -ChildPath $generatedName | ||
| if (-not (Test-Path -Path $generatedPath -PathType Leaf)) { | ||
| throw "Expected output file not found: $generatedPath" | ||
smw-ms marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| Write-Host "Moving Results File: $generatedPath -> $OutputFilePath" | ||
| Move-Item -Path $generatedPath -Destination $OutputFilePath -Force | ||
| Write-Host "Successfully moved results file to $OutputFilePath" | ||
smw-ms marked this conversation as resolved.
Show resolved
Hide resolved
smw-ms marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.