Skip to content

Commit eed887a

Browse files
CopilotIEvangelist
andauthored
Update Azure AI Foundry and GitHub Models documentation to use strongly-typed model constants (#5302)
* Initial plan * Update documentation to use AIFoundryModel and GitHubModel constants Co-authored-by: IEvangelist <[email protected]> * Update compatibility matrix to use GitHubModel constant Co-authored-by: IEvangelist <[email protected]> * Apply suggestions from code review --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: IEvangelist <[email protected]> Co-authored-by: David Pine <[email protected]>
1 parent bea2f8e commit eed887a

File tree

4 files changed

+38
-23
lines changed

4 files changed

+38
-23
lines changed

docs/azureai/ai-integrations-compatibility-matrix.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ The [Aspire.Hosting.GitHub.Models](https://www.nuget.org/packages/Aspire.Hosting
117117
```csharp
118118
var builder = DistributedApplication.CreateBuilder(args);
119119

120-
var chat = builder.AddGitHubModel("chat", "openai/gpt-4o-mini");
120+
var model = GitHubModel.OpenAI.OpenAIGpt4oMini;
121+
var chat = builder.AddGitHubModel("chat", model);
121122

122123
builder.AddProject<Projects.ExampleProject>()
123124
.WithReference(chat);

docs/azureai/azureai-foundry-integration.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ var builder = DistributedApplication.CreateBuilder(args);
6262

6363
var foundry = builder.AddAzureAIFoundry("foundry");
6464

65-
var chat = foundry.AddDeployment("chat", "Phi-4", "1", "Microsoft");
65+
var model = AIFoundryModel.Microsoft.Phi4;
66+
var chat = foundry.AddDeployment("chat", model);
6667

6768
builder.AddProject<Projects.ExampleProject>()
6869
.WithReference(chat)
@@ -74,17 +75,18 @@ builder.AddProject<Projects.ExampleProject>()
7475
The preceding code:
7576

7677
- Adds an Azure AI Foundry resource named `foundry`.
77-
- Adds an Azure AI Foundry deployment resource named `chat` with a model name of `Phi-4`. The model name must correspond to an [available model](/azure/ai-foundry/foundry-models/concepts/models) in the Azure AI Foundry service.
78+
- Adds an Azure AI Foundry deployment resource named `chat` using the <xref:Aspire.Hosting.Azure.AIFoundryModel> constant for Phi-4. The model must correspond to an [available model](/azure/ai-foundry/foundry-models/concepts/models) in the Azure AI Foundry service.
7879

79-
> [!NOTE]
80-
> The `format` parameter of the `AddDeployment(...)` method can be found in the Azure AI Foundry portal in the details page of the model, right after the `Quick facts` text.
80+
> [!TIP]
81+
> Use the strongly-typed <xref:Aspire.Hosting.Azure.AIFoundryModel> constants to avoid typos and ensure you're using valid model identifiers. These constants are grouped by publisher (for example, `AIFoundryModel.Microsoft.Phi4`, `AIFoundryModel.OpenAI.Gpt4o`).
8182
8283
### Configure deployment properties
8384

8485
You can customize deployment properties using the <xref:Aspire.Hosting.AzureAIFoundryExtensions.WithProperties*> method:
8586

8687
```csharp
87-
var chat = foundry.AddDeployment("chat", "Phi-4", "1", "Microsoft")
88+
var model = AIFoundryModel.Microsoft.Phi4;
89+
var chat = foundry.AddDeployment("chat", model)
8890
.WithProperties(deployment =>
8991
{
9092
deployment.SkuName = "Standard";
@@ -130,7 +132,8 @@ var builder = DistributedApplication.CreateBuilder(args);
130132
var foundry = builder.AddAzureAIFoundry("foundry")
131133
.RunAsFoundryLocal();
132134

133-
var chat = foundry.AddDeployment("chat", "phi-3.5-mini", "1", "Microsoft");
135+
var model = AIFoundryModel.Local.Phi35Mini;
136+
var chat = foundry.AddDeployment("chat", model);
134137

135138
builder.AddProject<Projects.ExampleProject>()
136139
.WithReference(chat)
@@ -143,6 +146,9 @@ When the AppHost starts up, the local foundry service is also started. This requ
143146

144147
The <xref:Aspire.Hosting.AzureAIFoundryExtensions.RunAsFoundryLocal*> method configures the resource to run as an emulator. It downloads and loads the specified models locally. The method provides health checks for the local service and automatically manages the Foundry Local lifecycle.
145148

149+
> [!TIP]
150+
> Use the strongly-typed `AIFoundryModel.Local` constants for local development models. These constants are specifically optimized for Foundry Local (for example, `AIFoundryModel.Local.Phi4Mini`, `AIFoundryModel.Local.DeepseekR17b`).
151+
146152
### Assign roles to resources
147153

148154
You can assign specific roles to resources that need to access the Azure AI Foundry service. Use the <xref:Aspire.Hosting.AzureAIFoundryExtensions.WithRoleAssignments*> method:

docs/github/github-models-integration.md

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,19 @@ To add a `GitHubModelResource` to your AppHost project, call the `AddGitHubModel
3939
```csharp
4040
var builder = DistributedApplication.CreateBuilder(args);
4141

42-
var chat = builder.AddGitHubModel("chat", "openai/gpt-4o-mini");
42+
var model = GitHubModel.OpenAI.OpenAIGpt4oMini;
43+
var chat = builder.AddGitHubModel("chat", model);
4344

4445
builder.AddProject<Projects.ExampleProject>()
4546
.WithReference(chat);
4647

4748
// After adding all resources, run the app...
4849
```
4950

50-
The preceding code adds a GitHub Model resource named `chat` using the `openai/gpt-4o-mini` model. The <xref:Aspire.Hosting.ResourceBuilderExtensions.WithReference*> method passes the connection information to the `ExampleProject` project.
51+
The preceding code adds a GitHub Model resource named `chat` using the <xref:Aspire.Hosting.GitHub.GitHubModel> constant for OpenAI's GPT-4o-mini model. The <xref:Aspire.Hosting.ResourceBuilderExtensions.WithReference*> method passes the connection information to the `ExampleProject` project.
52+
53+
> [!TIP]
54+
> Use the strongly-typed <xref:Aspire.Hosting.GitHub.GitHubModel> constants to avoid typos and ensure you're using valid model identifiers. These constants are grouped by publisher (for example, `GitHubModel.OpenAI.OpenAIGpt4oMini`, `GitHubModel.Microsoft.Phi4MiniInstruct`, `GitHubModel.DeepSeek.DeepSeekV30324`).
5155
5256
### Specify an organization
5357

@@ -57,7 +61,8 @@ For organization-specific requests, you can specify an organization parameter:
5761
var builder = DistributedApplication.CreateBuilder(args);
5862

5963
var organization = builder.AddParameter("github-org");
60-
var chat = builder.AddGitHubModel("chat", "openai/gpt-4o-mini", organization);
64+
var model = GitHubModel.OpenAI.OpenAIGpt4oMini;
65+
var chat = builder.AddGitHubModel("chat", model, organization);
6166

6267
builder.AddProject<Projects.ExampleProject>()
6368
.WithReference(chat);
@@ -76,7 +81,8 @@ The GitHub Models integration supports multiple ways to configure authentication
7681
By default, the integration creates a parameter named `{resource_name}-gh-apikey` that automatically falls back to the `GITHUB_TOKEN` environment variable:
7782

7883
```csharp
79-
var chat = builder.AddGitHubModel("chat", "openai/gpt-4o-mini");
84+
var model = GitHubModel.OpenAI.OpenAIGpt4oMini;
85+
var chat = builder.AddGitHubModel("chat", model);
8086
```
8187

8288
Then in user secrets:
@@ -95,7 +101,8 @@ You can also specify a custom parameter for the API key:
95101

96102
```csharp
97103
var apiKey = builder.AddParameter("my-api-key", secret: true);
98-
var chat = builder.AddGitHubModel("chat", "openai/gpt-4o-mini")
104+
var model = GitHubModel.OpenAI.OpenAIGpt4oMini;
105+
var chat = builder.AddGitHubModel("chat", model)
99106
.WithApiKey(apiKey);
100107
```
101108

@@ -114,7 +121,8 @@ Then in user secrets:
114121
You can add health checks to verify the GitHub Models endpoint accessibility and API key validity:
115122

116123
```csharp
117-
var chat = builder.AddGitHubModel("chat", "openai/gpt-4o-mini")
124+
var model = GitHubModel.OpenAI.OpenAIGpt4oMini;
125+
var chat = builder.AddGitHubModel("chat", model)
118126
.WithHealthCheck();
119127
```
120128

@@ -123,14 +131,14 @@ var chat = builder.AddGitHubModel("chat", "openai/gpt-4o-mini")
123131
124132
### Available models
125133

126-
GitHub Models supports various AI models. Some popular options include:
134+
GitHub Models supports various AI models. Use the strongly-typed <xref:Aspire.Hosting.GitHub.GitHubModel> constants for the most up-to-date list of available models. Some popular options include:
127135

128-
- `openai/gpt-4o-mini`
129-
- `openai/gpt-4o`
130-
- `deepseek/DeepSeek-V3-0324`
131-
- `microsoft/Phi-4-mini-instruct`
136+
- `GitHubModel.OpenAI.OpenAIGpt4oMini`
137+
- `GitHubModel.OpenAI.OpenAIGpt41Mini`
138+
- `GitHubModel.DeepSeek.DeepSeekV30324`
139+
- `GitHubModel.Microsoft.Phi4MiniInstruct`
132140

133-
Check the [GitHub Models documentation](https://docs.github.com/github-models) for the most up-to-date list of available models.
141+
Check the [GitHub Models documentation](https://docs.github.com/github-models) for more information about these models and their capabilities.
134142

135143
## Client integration
136144

@@ -171,7 +179,6 @@ public class ExampleService(ChatCompletionsClient client)
171179
public async Task<string> GetResponseAsync(string prompt)
172180
{
173181
var response = await client.GetChatCompletionsAsync(
174-
"openai/gpt-4o-mini",
175182
new[]
176183
{
177184
new ChatMessage(ChatRole.User, prompt)
@@ -237,7 +244,7 @@ public class ChatService(OpenAIClient client)
237244
{
238245
public async Task<string> GetChatResponseAsync(string prompt)
239246
{
240-
var chatClient = client.GetChatClient("openai/gpt-4o-mini");
247+
var chatClient = client.GetChatClient(GitHubModel.OpenAI.OpenAIGpt4oMini);
241248

242249
var response = await chatClient.CompleteChatAsync(
243250
new[]
@@ -271,7 +278,8 @@ When running an app in GitHub Codespaces or GitHub Actions, the `GITHUB_TOKEN` e
271278

272279
```csharp
273280
// No additional configuration needed in Codespaces/GitHub Actions
274-
var chat = builder.AddGitHubModel("chat", "openai/gpt-4o-mini");
281+
var model = GitHubModel.OpenAI.OpenAIGpt4oMini;
282+
var chat = builder.AddGitHubModel("chat", model);
275283
```
276284

277285
##### Personal access tokens for local development

docs/snippets/azure/AppHost/AppHost.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
var foundryDeployment = foundry.AddDeployment(
77
name: "chat",
88
modelName: "Phi-4",
9-
modelVersion: "1",
9+
modelVersion: "7",
1010
format: "Microsoft");
1111

1212
builder.AddAzureAppConfiguration("config");

0 commit comments

Comments
 (0)