Add GitHubModelName enum for polyglot export support#14923
Add GitHubModelName enum for polyglot export support#14923davidfowl merged 2 commits intorelease/13.2from
Conversation
- Generate internal GitHubModelName enum and GetModelId conversion method in tools/GenModel.cs and GitHubModel.Generated.cs - Add internal AddGitHubModel(GitHubModelName) overload exported as addGitHubModel for polyglot app hosts - Mark string and GitHubModel overloads as AspireExportIgnore - Rename WithHealthCheck export to enableHealthCheck to avoid collision with core withHealthCheck(key) - Update ValidationAppHost/apphost.ts to exercise all exported methods - Fix tsconfig.json to include .d.ts files per convention Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14923Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14923" |
There was a problem hiding this comment.
Pull request overview
Adds a polyglot-friendly way to reference GitHub Models by generating a stable GitHubModelName enum and routing the exported polyglot addGitHubModel API through that enum-to-model-id mapping. This also resolves a polyglot method-name collision around withHealthCheck by renaming the GitHub Models export to enableHealthCheck, and updates the TypeScript validation app host to exercise the updated exported surface.
Changes:
- Generate an internal
GitHubModelNameenum plusGitHubModel.GetModelId(GitHubModelName)mapping in the GitHub Models codegen output. - Switch the exported polyglot
addGitHubModeloverload to useGitHubModelName, and ignore the string andGitHubModeloverloads for ATS export. - Update TypeScript polyglot validation host + codegen outputs (including DTO writeback behavior and tsconfig include rules).
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Aspire.Hosting.GitHub.Models/tools/GenModel.cs | Updates generator to produce GitHubModelName + GetModelId and stabilizes ordering. |
| src/Aspire.Hosting.GitHub.Models/GitHubModelsExtensions.cs | Adds exported enum-based overload, ignores non-ATS-friendly overloads, renames exported health check method to enableHealthCheck. |
| src/Aspire.Hosting.GitHub.Models/GitHubModel.Generated.cs | Generated enum + mapping method output for runtime conversion from enum to model id. |
| playground/polyglot/TypeScript/Aspire.Hosting.GitHub.Models/ValidationAppHost/tsconfig.json | Includes .modules/**/*.d.ts per polyglot convention. |
| playground/polyglot/TypeScript/Aspire.Hosting.GitHub.Models/ValidationAppHost/apphost.ts | Exercises all exported GitHub Models APIs using the new enum-based surface. |
| playground/polyglot/TypeScript/Aspire.Hosting.GitHub.Models/ValidationAppHost/.modules/transport.ts | Returns original args object for void callbacks to enable DTO writeback on the .NET side. |
| playground/polyglot/TypeScript/Aspire.Hosting.GitHub.Models/ValidationAppHost/.modules/aspire.ts | Regenerates TS bindings: adds GitHubModelName, updates addGitHubModel signature, adds enableHealthCheck, and adds core withHealthCheck(key) overloads. |
| playground/polyglot/TypeScript/Aspire.Hosting.GitHub.Models/ValidationAppHost/.modules/.codegen-hash | Updates codegen hash for regenerated modules. |
| playground/polyglot/TypeScript/Aspire.Hosting.GitHub.Models/ValidationAppHost/.aspire/settings.json | Formatting-only newline/whitespace adjustment. |
| /// <param name="organization">The organization login associated with the organization to which the request is to be attributed.</param> | ||
| /// <returns>A reference to the <see cref="IResourceBuilder{T}"/>.</returns> | ||
| /// <remarks> | ||
| /// <para>This overload is not available in polyglot app hosts. Use the string-based overload instead.</para> |
There was a problem hiding this comment.
The remarks for the GitHubModel-based overload say polyglot app hosts should use the string-based overload, but that string overload is also marked AspireExportIgnore and therefore isn’t available to polyglot app hosts. Update this remark to point polyglot users to the GitHubModelName-based overload (addGitHubModel), or remove the polyglot guidance here to avoid contradicting the export surface.
| /// <para>This overload is not available in polyglot app hosts. Use the string-based overload instead.</para> | |
| /// <para> | |
| /// This overload is not available in polyglot app hosts. Use the <see cref="GitHubModelName"/>-based overload instead. | |
| /// </para> |
| GitHubModelName.OpenAITextEmbedding3Small => "openai/text-embedding-3-small", | ||
| GitHubModelName.Grok3 => "xai/grok-3", | ||
| GitHubModelName.Grok3Mini => "xai/grok-3-mini", | ||
| _ => throw new System.ArgumentOutOfRangeException(nameof(name), name, "Unknown GitHub model name.") |
There was a problem hiding this comment.
Is there an overload that takes a string model name as well?
There was a problem hiding this comment.
Done, addGitHubModelById(name, id)
Exports an internal addGitHubModelById method so TypeScript users can pass model identifier strings (e.g. 'custom-vendor/custom-model') for models not yet in the GitHubModelName enum. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🎬 CLI E2E Test RecordingsThe following terminal recordings are available for commit
📹 Recordings uploaded automatically from CI run #22651388952 |
* Add GitHubModelName enum for polyglot export support - Generate internal GitHubModelName enum and GetModelId conversion method in tools/GenModel.cs and GitHubModel.Generated.cs - Add internal AddGitHubModel(GitHubModelName) overload exported as addGitHubModel for polyglot app hosts - Mark string and GitHubModel overloads as AspireExportIgnore - Rename WithHealthCheck export to enableHealthCheck to avoid collision with core withHealthCheck(key) - Update ValidationAppHost/apphost.ts to exercise all exported methods - Fix tsconfig.json to include .d.ts files per convention Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add addGitHubModelById for arbitrary model ID strings Exports an internal addGitHubModelById method so TypeScript users can pass model identifier strings (e.g. 'custom-vendor/custom-model') for models not yet in the GitHubModelName enum. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.