Skip to content

Conversation

@sebastienros
Copy link
Member

@sebastienros sebastienros commented Jul 1, 2025

Description

Adds a new hosting integration for GitHub Models.

Fixes #9569 #7649

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

@Copilot Copilot AI review requested due to automatic review settings July 1, 2025 18:36
@github-actions github-actions bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Jul 1, 2025
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

This PR introduces a new hosting integration for GitHub Models by providing a resource type, builder extensions, tests, documentation, and solution updates.

  • Added GitHubModelsResource and connection‐string support
  • Provided extension methods AddGitHubModel, WithEndpoint, and WithApiKey
  • Included unit tests, README docs, and solution/project registrations

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Aspire.Hosting.GitHub.Models/GitHubModelsResource.cs Defines the GitHubModelsResource class with connection string
src/Aspire.Hosting.GitHub.Models/GitHubModelsExtensions.cs Adds extension methods on IDistributedApplicationBuilder
tests/Aspire.Hosting.GitHub.Models.Tests/GitHubModelsExtensionTests.cs Adds unit tests for the new extension methods
src/Aspire.Hosting.GitHub.Models/README.md Documents installation and usage examples
Aspire.slnx Registers new projects and playground folders
Comments suppressed due to low confidence (2)

src/Aspire.Hosting.GitHub.Models/GitHubModelsExtensions.cs:21

  • Public API methods lack <remarks> and <code> examples in their XML comments. Please add <remarks> to explain scenarios and <code> snippets showing typical usage.
    public static IResourceBuilder<GitHubModelsResource> AddGitHubModel(this IDistributedApplicationBuilder builder, [ResourceName] string name, string model)

tests/Aspire.Hosting.GitHub.Models.Tests/GitHubModelsExtensionTests.cs:28

  • Consider adding tests to verify the argument guards for AddGitHubModel, WithEndpoint, and WithApiKey, ensuring they throw the appropriate exceptions on null or empty inputs.
        var customEndpoint = "https://custom.endpoint.com";

@mitchdenny
Copy link
Member

Great to see this finally coming in. Probably one of the easiest ways to get started with an LLM in Aspire.

I've got a few suggestions for improvements.

The first is that we should consider scanning the environment for the GITHUB_TOKEN. If you are running in a Codespaces and GitHub Actions (I think) this variable is available.

We might want to consider using the new dashboard message bar APIs to prompt for consent before using that token since there is usage fees attached. Alternatively have an extension like WithCodespaceToken or something like that.

Copy link
Contributor

@aaronpowell aaronpowell left a comment

Choose a reason for hiding this comment

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

I agree with @mitchdenny on it using the GITHUB_TOKEN environment variable convention.

@sebastienros
Copy link
Member Author

Couldn't find a way to create a health check that would take the key into account. There is no documented endpoint that doesn't consume tokens.

I also want to try embedding models and add support if possible.

@davidfowl
Copy link
Member

@DamianEdwards tku made the external resource “running” yes? Parameters are now “active”, do we just. Make everything running ?

@GMouaad
Copy link
Contributor

GMouaad commented Jul 9, 2025

Can't wait to try this one out!!

@DamianEdwards
Copy link
Member

@DamianEdwards tku made the external resource “running” yes? Parameters are now “active”, do we just. Make everything running ?

Yes I made the ExternalServiceResource "Running" because that's required to make it support health checks currently. I think it's fine to have a different status for things that really don't have a lifecycle (like parameters) but there's at all a lifecycle associated with what's being modeled and/or a benefit to it having a health check, we should likely keep it "Running".

@sebastienros
Copy link
Member Author

Yes I made the ExternalServiceResource "Running" because that's required to make it support health checks

That's also something that bugged me.

@davidfowl
Copy link
Member

@sebastienros can you share a video of the end to end?

{
var builder = new DbConnectionStringBuilder() { ConnectionString = await connectionString().ConfigureAwait(false) };

using var request = new HttpRequestMessage(HttpMethod.Post, new Uri($"{builder["Endpoint"]}/chat/completions"));
Copy link
Member

Choose a reason for hiding this comment

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

new UriBuilder(builder["Endpoint"]) { Path = "/chat/completions" }.Build()?

Copy link
Member Author

Choose a reason for hiding this comment

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

With more !.ToString()!, it becomes quite ugly to read. Do you care much?

@eerhardt eerhardt merged commit 5f0ec57 into main Jul 10, 2025
502 of 504 checks passed
@eerhardt eerhardt deleted the sebros/ghmodels branch July 10, 2025 20:10
@eerhardt eerhardt mentioned this pull request Jul 10, 2025
1 task
@eerhardt
Copy link
Member

/backport to release/9.4

@github-actions
Copy link
Contributor

@github-actions
Copy link
Contributor

@eerhardt backporting to "release/9.4" failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Add GitHub Models integration
.git/rebase-apply/patch:262: trailing whitespace.
    
.git/rebase-apply/patch:764: trailing whitespace.
        
.git/rebase-apply/patch:766: trailing whitespace.
        
.git/rebase-apply/patch:776: trailing whitespace.
        
.git/rebase-apply/patch:780: trailing whitespace.
        
warning: squelched 7 whitespace errors
warning: 12 lines add whitespace errors.
Using index info to reconstruct a base tree...
M	Aspire.slnx
Falling back to patching base and 3-way merge...
Auto-merging Aspire.slnx
CONFLICT (content): Merge conflict in Aspire.slnx
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Add GitHub Models integration
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

eerhardt added a commit to eerhardt/aspire that referenced this pull request Jul 10, 2025
* Add GitHub Models integration

* Fix parameters and doc

* Add package logo

* Support GITHUB_TOKEN env

* Fix test

* Rename to GithubModel

* Remove iisexpress in launch

* Update playground/GitHubModelsEndToEnd/GitHubModelsEndToEnd.AppHost/GitHubModelsEndToEnd.AppHost.csproj

Co-authored-by: Eric Erhardt <[email protected]>

* Define running state on github models

* Add organization

* Add tests

* Add health checks

* Add manifest files

* Make health checks opt-in

* Feedback

* Fix test

---------

Co-authored-by: Mitch Denny <[email protected]>
Co-authored-by: Eric Erhardt <[email protected]>
danmoseley added a commit that referenced this pull request Jul 10, 2025
* Add GitHub Models integration (#10170)

* Add GitHub Models integration

* Fix parameters and doc

* Add package logo

* Support GITHUB_TOKEN env

* Fix test

* Rename to GithubModel

* Remove iisexpress in launch

* Update playground/GitHubModelsEndToEnd/GitHubModelsEndToEnd.AppHost/GitHubModelsEndToEnd.AppHost.csproj

Co-authored-by: Eric Erhardt <[email protected]>

* Define running state on github models

* Add organization

* Add tests

* Add health checks

* Add manifest files

* Make health checks opt-in

* Feedback

* Fix test

---------

Co-authored-by: Mitch Denny <[email protected]>
Co-authored-by: Eric Erhardt <[email protected]>

* Apply suggestions from code review

Co-authored-by: Dan Moseley <[email protected]>
Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Sébastien Ros <[email protected]>
Co-authored-by: Mitch Denny <[email protected]>
Co-authored-by: Dan Moseley <[email protected]>
Co-authored-by: Copilot <[email protected]>
danmoseley pushed a commit to danmoseley/aspire that referenced this pull request Jul 10, 2025
eerhardt added a commit that referenced this pull request Jul 10, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Aug 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support GitHub Models

7 participants