Skip to content

Add GitHubModelName enum for polyglot export support#14923

Merged
davidfowl merged 2 commits intorelease/13.2from
sebros/polyglot-gh-models
Mar 4, 2026
Merged

Add GitHubModelName enum for polyglot export support#14923
davidfowl merged 2 commits intorelease/13.2from
sebros/polyglot-gh-models

Conversation

@sebastienros
Copy link
Contributor

  • 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

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.

- 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>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14923

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14923"

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 GitHubModelName enum plus GitHubModel.GetModelId(GitHubModelName) mapping in the GitHub Models codegen output.
  • Switch the exported polyglot addGitHubModel overload to use GitHubModelName, and ignore the string and GitHubModel overloads 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>
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
/// <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>

Copilot uses AI. Check for mistakes.
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.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an overload that takes a string model name as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

🎬 CLI E2E Test Recordings

The following terminal recordings are available for commit 8970570:

Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AgentInitCommand_WithMalformedMcpJson_ShowsErrorAndExitsNonZero ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
CreateAndDeployToDockerCompose ❌ Upload failed
CreateAndDeployToDockerComposeInteractive ▶️ View Recording
CreateAndPublishToKubernetes ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateEmptyAppHostProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateStartWaitAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording

📹 Recordings uploaded automatically from CI run #22651388952

@davidfowl davidfowl merged commit 247974b into release/13.2 Mar 4, 2026
758 of 761 checks passed
@davidfowl davidfowl deleted the sebros/polyglot-gh-models branch March 4, 2026 06:45
@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Mar 4, 2026
Copilot AI pushed a commit that referenced this pull request Mar 10, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants