-
Couldn't load subscription status.
- Fork 712
Add GitHub Models integration #10170
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
20 commits
Select commit
Hold shift + click to select a range
84a200d
Add GitHub Models integration
sebastienros 5ff8775
Fix parameters and doc
sebastienros df30820
Add package logo
sebastienros b483338
Support GITHUB_TOKEN env
sebastienros c3f086f
Fix test
sebastienros 48361bd
Merge branch 'main' into sebros/ghmodels
mitchdenny 0e25124
Merge branch 'main' into sebros/ghmodels
sebastienros 6f21fa5
Rename to GithubModel
sebastienros 52c2814
Merge branch 'sebros/ghmodels' of https://github.com/dotnet/aspire in…
sebastienros 9f3a02f
Remove iisexpress in launch
sebastienros a602f5b
Update playground/GitHubModelsEndToEnd/GitHubModelsEndToEnd.AppHost/G…
sebastienros a169ba2
Merge remote-tracking branch 'origin/main' into sebros/ghmodels
sebastienros ac0bbb3
Define running state on github models
sebastienros 82f49de
Add organization
sebastienros 2713765
Add tests
sebastienros 0dc7f2a
Add health checks
sebastienros c20d894
Add manifest files
sebastienros dc50bc6
Make health checks opt-in
sebastienros 60a70f3
Feedback
sebastienros 105b05c
Fix test
sebastienros 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
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
23 changes: 23 additions & 0 deletions
23
...und/GitHubModelsEndToEnd/GitHubModelsEndToEnd.AppHost/GitHubModelsEndToEnd.AppHost.csproj
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,23 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>$(DefaultTargetFramework)</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| <IsAspireHost>true</IsAspireHost> | ||
| <UserSecretsId>b8e8b8c7-4a45-4b2e-8c7d-9e8f7a6b5c4d</UserSecretsId> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Compile Include="..\..\KnownResourceNames.cs" Link="KnownResourceNames.cs" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <AspireProjectOrPackageReference Include="Aspire.Hosting.Azure.AppContainers" /> | ||
| <AspireProjectOrPackageReference Include="Aspire.Hosting.AppHost" /> | ||
| <AspireProjectOrPackageReference Include="Aspire.Hosting.GitHub.Models" /> | ||
| <ProjectReference Include="..\GitHubModelsEndToEnd.WebStory\GitHubModelsEndToEnd.WebStory.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
27 changes: 27 additions & 0 deletions
27
playground/GitHubModelsEndToEnd/GitHubModelsEndToEnd.AppHost/Program.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,27 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| var builder = DistributedApplication.CreateBuilder(args); | ||
| builder.AddAzureContainerAppEnvironment("env"); | ||
|
|
||
| var chat = builder.AddGitHubModel("chat", "openai/gpt-4o-mini"); | ||
|
|
||
| // To set the GitHub Models API key define the value for the following parameter in User Secrets. | ||
| // Alternatively, you can set the environment variable GITHUB_TOKEN and comment the line below. | ||
| chat.WithApiKey(builder.AddParameter("github-api-key", secret: true)); | ||
|
|
||
| builder.AddProject<Projects.GitHubModelsEndToEnd_WebStory>("webstory") | ||
| .WithExternalHttpEndpoints() | ||
| .WithReference(chat).WaitFor(chat); | ||
|
|
||
| #if !SKIP_DASHBOARD_REFERENCE | ||
| // This project is only added in playground projects to support development/debugging | ||
| // of the dashboard. It is not required in end developer code. Comment out this code | ||
| // or build with `/p:SkipDashboardReference=true`, to test end developer | ||
| // dashboard launch experience, Refer to Directory.Build.props for the path to | ||
| // the dashboard binary (defaults to the Aspire.Dashboard bin output in the | ||
| // artifacts dir). | ||
| builder.AddProject<Projects.Aspire_Dashboard>(KnownResourceNames.AspireDashboard); | ||
| #endif | ||
|
|
||
| builder.Build().Run(); | ||
40 changes: 40 additions & 0 deletions
40
playground/GitHubModelsEndToEnd/GitHubModelsEndToEnd.AppHost/Properties/launchSettings.json
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 @@ | ||
| { | ||
| "$schema": "http://json.schemastore.org/launchsettings.json", | ||
| "profiles": { | ||
| "https": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": true, | ||
| "applicationUrl": "https://localhost:15215;http://localhost:15216", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development", | ||
| "DOTNET_ENVIRONMENT": "Development", | ||
| "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:16195", | ||
| "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:17037" | ||
| } | ||
| }, | ||
| "http": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": true, | ||
| "applicationUrl": "http://localhost:15216", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development", | ||
| "DOTNET_ENVIRONMENT": "Development", | ||
| "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16195", | ||
| "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:17038", | ||
| "ASPIRE_ALLOW_UNSECURED_TRANSPORT": "true" | ||
| } | ||
| }, | ||
| "generate-manifest": { | ||
| "commandName": "Project", | ||
| "launchBrowser": true, | ||
| "dotnetRunMessages": true, | ||
| "commandLineArgs": "--publisher manifest --output-path aspire-manifest.json", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development", | ||
| "DOTNET_ENVIRONMENT": "Development" | ||
| } | ||
| } | ||
| } | ||
| } |
65 changes: 65 additions & 0 deletions
65
playground/GitHubModelsEndToEnd/GitHubModelsEndToEnd.AppHost/aspire-manifest.json
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,65 @@ | ||
| { | ||
| "$schema": "https://json.schemastore.org/aspire-8.0.json", | ||
| "resources": { | ||
| "env": { | ||
| "type": "azure.bicep.v0", | ||
| "path": "env.module.bicep", | ||
| "params": { | ||
| "userPrincipalId": "" | ||
| } | ||
| }, | ||
| "chat": { | ||
| "type": "value.v0", | ||
| "connectionString": "Endpoint=https://models.github.ai/inference;Key={github-api-key.value};Model=openai/gpt-4o-mini;DeploymentId=openai/gpt-4o-mini" | ||
| }, | ||
| "github-api-key": { | ||
| "type": "parameter.v0", | ||
| "value": "{github-api-key.inputs.value}", | ||
| "inputs": { | ||
| "value": { | ||
| "type": "string", | ||
| "secret": true | ||
| } | ||
| } | ||
| }, | ||
| "webstory": { | ||
| "type": "project.v1", | ||
| "path": "../GitHubModelsEndToEnd.WebStory/GitHubModelsEndToEnd.WebStory.csproj", | ||
| "deployment": { | ||
| "type": "azure.bicep.v0", | ||
| "path": "webstory.module.bicep", | ||
| "params": { | ||
| "env_outputs_azure_container_apps_environment_default_domain": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}", | ||
| "env_outputs_azure_container_apps_environment_id": "{env.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}", | ||
| "env_outputs_azure_container_registry_endpoint": "{env.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}", | ||
| "env_outputs_azure_container_registry_managed_identity_id": "{env.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}", | ||
| "webstory_containerimage": "{webstory.containerImage}", | ||
| "webstory_containerport": "{webstory.containerPort}", | ||
| "github_api_key_value": "{github-api-key.value}" | ||
| } | ||
| }, | ||
| "env": { | ||
| "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", | ||
| "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", | ||
| "OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory", | ||
| "ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true", | ||
| "HTTP_PORTS": "{webstory.bindings.http.targetPort}", | ||
| "ConnectionStrings__chat": "{chat.connectionString}" | ||
| }, | ||
| "bindings": { | ||
| "http": { | ||
| "scheme": "http", | ||
| "protocol": "tcp", | ||
| "transport": "http", | ||
| "external": true | ||
| }, | ||
| "https": { | ||
| "scheme": "https", | ||
| "protocol": "tcp", | ||
| "transport": "http", | ||
| "external": true | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
87 changes: 87 additions & 0 deletions
87
playground/GitHubModelsEndToEnd/GitHubModelsEndToEnd.AppHost/env.module.bicep
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,87 @@ | ||
| @description('The location for the resource(s) to be deployed.') | ||
| param location string = resourceGroup().location | ||
|
|
||
| param userPrincipalId string | ||
|
|
||
| param tags object = { } | ||
|
|
||
| resource env_mi 'Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30' = { | ||
| name: take('env_mi-${uniqueString(resourceGroup().id)}', 128) | ||
| location: location | ||
| tags: tags | ||
| } | ||
|
|
||
| resource env_acr 'Microsoft.ContainerRegistry/registries@2025-04-01' = { | ||
| name: take('envacr${uniqueString(resourceGroup().id)}', 50) | ||
| location: location | ||
| sku: { | ||
| name: 'Basic' | ||
| } | ||
| tags: tags | ||
| } | ||
|
|
||
| resource env_acr_env_mi_AcrPull 'Microsoft.Authorization/roleAssignments@2022-04-01' = { | ||
| name: guid(env_acr.id, env_mi.id, subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d')) | ||
| properties: { | ||
| principalId: env_mi.properties.principalId | ||
| roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d') | ||
| principalType: 'ServicePrincipal' | ||
| } | ||
| scope: env_acr | ||
| } | ||
|
|
||
| resource env_law 'Microsoft.OperationalInsights/workspaces@2025-02-01' = { | ||
| name: take('envlaw-${uniqueString(resourceGroup().id)}', 63) | ||
| location: location | ||
| properties: { | ||
| sku: { | ||
| name: 'PerGB2018' | ||
| } | ||
| } | ||
| tags: tags | ||
| } | ||
|
|
||
| resource env 'Microsoft.App/managedEnvironments@2025-01-01' = { | ||
| name: take('env${uniqueString(resourceGroup().id)}', 24) | ||
| location: location | ||
| properties: { | ||
| appLogsConfiguration: { | ||
| destination: 'log-analytics' | ||
| logAnalyticsConfiguration: { | ||
| customerId: env_law.properties.customerId | ||
| sharedKey: env_law.listKeys().primarySharedKey | ||
| } | ||
| } | ||
| workloadProfiles: [ | ||
| { | ||
| name: 'consumption' | ||
| workloadProfileType: 'Consumption' | ||
| } | ||
| ] | ||
| } | ||
| tags: tags | ||
| } | ||
|
|
||
| resource aspireDashboard 'Microsoft.App/managedEnvironments/dotNetComponents@2024-10-02-preview' = { | ||
| name: 'aspire-dashboard' | ||
| properties: { | ||
| componentType: 'AspireDashboard' | ||
| } | ||
| parent: env | ||
| } | ||
|
|
||
| output AZURE_LOG_ANALYTICS_WORKSPACE_NAME string = env_law.name | ||
|
|
||
| output AZURE_LOG_ANALYTICS_WORKSPACE_ID string = env_law.id | ||
|
|
||
| output AZURE_CONTAINER_REGISTRY_NAME string = env_acr.name | ||
|
|
||
| output AZURE_CONTAINER_REGISTRY_ENDPOINT string = env_acr.properties.loginServer | ||
|
|
||
| output AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID string = env_mi.id | ||
|
|
||
| output AZURE_CONTAINER_APPS_ENVIRONMENT_NAME string = env.name | ||
|
|
||
| output AZURE_CONTAINER_APPS_ENVIRONMENT_ID string = env.id | ||
|
|
||
| output AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN string = env.properties.defaultDomain |
93 changes: 93 additions & 0 deletions
93
playground/GitHubModelsEndToEnd/GitHubModelsEndToEnd.AppHost/webstory.module.bicep
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,93 @@ | ||
| @description('The location for the resource(s) to be deployed.') | ||
| param location string = resourceGroup().location | ||
|
|
||
| param env_outputs_azure_container_apps_environment_default_domain string | ||
|
|
||
| param env_outputs_azure_container_apps_environment_id string | ||
|
|
||
| param env_outputs_azure_container_registry_endpoint string | ||
|
|
||
| param env_outputs_azure_container_registry_managed_identity_id string | ||
|
|
||
| param webstory_containerimage string | ||
|
|
||
| param webstory_containerport string | ||
|
|
||
| @secure() | ||
| param github_api_key_value string | ||
|
|
||
| resource webstory 'Microsoft.App/containerApps@2025-02-02-preview' = { | ||
| name: 'webstory' | ||
| location: location | ||
| properties: { | ||
| configuration: { | ||
| secrets: [ | ||
| { | ||
| name: 'connectionstrings--chat' | ||
| value: 'Endpoint=https://models.github.ai/inference;Key=${github_api_key_value};Model=openai/gpt-4o-mini;DeploymentId=openai/gpt-4o-mini' | ||
| } | ||
| ] | ||
| activeRevisionsMode: 'Single' | ||
| ingress: { | ||
| external: true | ||
| targetPort: int(webstory_containerport) | ||
| transport: 'http' | ||
| } | ||
| registries: [ | ||
| { | ||
| server: env_outputs_azure_container_registry_endpoint | ||
| identity: env_outputs_azure_container_registry_managed_identity_id | ||
| } | ||
| ] | ||
| runtime: { | ||
| dotnet: { | ||
| autoConfigureDataProtection: true | ||
| } | ||
| } | ||
| } | ||
| environmentId: env_outputs_azure_container_apps_environment_id | ||
| template: { | ||
| containers: [ | ||
| { | ||
| image: webstory_containerimage | ||
| name: 'webstory' | ||
| env: [ | ||
| { | ||
| name: 'OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES' | ||
| value: 'true' | ||
| } | ||
| { | ||
| name: 'OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES' | ||
| value: 'true' | ||
| } | ||
| { | ||
| name: 'OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY' | ||
| value: 'in_memory' | ||
| } | ||
| { | ||
| name: 'ASPNETCORE_FORWARDEDHEADERS_ENABLED' | ||
| value: 'true' | ||
| } | ||
| { | ||
| name: 'HTTP_PORTS' | ||
| value: webstory_containerport | ||
| } | ||
| { | ||
| name: 'ConnectionStrings__chat' | ||
| secretRef: 'connectionstrings--chat' | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| scale: { | ||
| minReplicas: 1 | ||
| } | ||
| } | ||
| } | ||
| identity: { | ||
| type: 'UserAssigned' | ||
| userAssignedIdentities: { | ||
| '${env_outputs_azure_container_registry_managed_identity_id}': { } | ||
| } | ||
| } | ||
| } |
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.