Skip to content

Commit 7a1b0a2

Browse files
committed
Remove --no-devui. Fix OpenAI clients. Fix execution test sandbox ignores.
1 parent 581f948 commit 7a1b0a2

File tree

24 files changed

+71
-374
lines changed

24 files changed

+71
-374
lines changed

src/ProjectTemplates/.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ package-lock.json
1212
*/src/**/Directory.Build.props
1313
*/src/**/ingestioncache.*
1414

15-
# The aichatweb template includes hard-coded launchSettings.json files in the template
16-
!Microsoft.Extensions.AI.Templates/src/ChatWithCustomData/*/Properties/launchSettings.json
15+
# The project templates include hard-coded launchSettings.json files
16+
!*/src/**/Properties/launchSettings.json
1717

1818
# Templates include JS dependencies in dist folders.
1919
!**/dist/*

src/ProjectTemplates/GeneratedContent.targets

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
Specifies external packages that get referenced in generated template content.
3535
-->
3636
<PropertyGroup>
37-
<TemplatePackageVersion_MicrosoftAgentsAI>1.0.0-preview.251107.2</TemplatePackageVersion_MicrosoftAgentsAI>
38-
<TemplatePackageVersion_MicrosoftAgentsAIHostingOpenAI>1.0.0-alpha.251107.2</TemplatePackageVersion_MicrosoftAgentsAIHostingOpenAI>
37+
<TemplatePackageVersion_MicrosoftAgentsAI>1.0.0-local.251108.1</TemplatePackageVersion_MicrosoftAgentsAI>
38+
<TemplatePackageVersion_MicrosoftAgentsAIHostingOpenAI>1.0.0-local.251108.1</TemplatePackageVersion_MicrosoftAgentsAIHostingOpenAI>
3939
<TemplatePackageVersion_Aspire>9.5.1</TemplatePackageVersion_Aspire>
4040
<TemplatePackageVersion_Aspire_Preview>9.5.1-preview.1.25502.11</TemplatePackageVersion_Aspire_Preview>
4141
<TemplatePackageVersion_AzureAIProjects>1.0.0</TemplatePackageVersion_AzureAIProjects>
@@ -89,9 +89,6 @@
8989
<GeneratedContent
9090
Include="$(_WebApiAgentRoot)WebApiAgent-CSharp\WebApiAgent-CSharp.csproj.in"
9191
OutputPath="$(_WebApiAgentRoot)WebApiAgent-CSharp\WebApiAgent-CSharp.csproj" />
92-
<GeneratedContent
93-
Include="$(_WebApiAgentRoot)WebApiAgent-CSharp\Properties\launchSettings.json.in"
94-
OutputPath="$(_WebApiAgentRoot)WebApiAgent-CSharp\Properties\launchSettings.json" />
9592
<GeneratedContent
9693
Include="$(_ChatWithCustomDataContentRoot)ChatWithCustomData-CSharp.sln.in"
9794
OutputPath="$(_ChatWithCustomDataContentRoot)ChatWithCustomData-CSharp.sln" />

src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/dotnetcli.host.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@
1616
"longName": "managed-identity",
1717
"shortName": ""
1818
},
19-
"UseDevUI": {
20-
"isHidden": "true"
21-
},
22-
"DoNotUseDevUI": {
23-
"longName": "no-devui",
24-
"shortName": ""
25-
},
2619
"httpPort": {
2720
"isHidden": "true",
2821
"longName": "httpPort",

src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/ide.host.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@
1515
{
1616
"id": "UseManagedIdentity",
1717
"isVisible": true
18-
},
19-
{
20-
"id": "UseDevUI",
21-
"isVisible": true
22-
},
23-
{
24-
"id": "DoNotUseDevUI",
25-
"isVisible": false
2618
}
2719
]
2820
}

src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/.template.config/template.json

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,6 @@
9393
"isEnabled": "(AiServiceProvider == \"azureopenai\")",
9494
"description": "Use managed identity to access Azure services"
9595
},
96-
"UseDevUI": {
97-
"type": "parameter",
98-
"displayName": "Enable the Agent Framework developer UI",
99-
"datatype": "bool",
100-
"defaultValue": "true",
101-
"description": "Add the Agent Framework developer UI for use in the development environment"
102-
},
103-
"DoNotUseDevUI": {
104-
"type": "parameter",
105-
"displayName": "Disable the Agent Framework developer UI",
106-
"datatype": "bool",
107-
"defaultValue": "false",
108-
"description": "Do not add the Agent Framework developer UI"
109-
},
11096
"ChatModel": {
11197
"type": "parameter",
11298
"displayName": "Model/deployment for chat completions. Example: gpt-4o-mini",
@@ -116,10 +102,6 @@
116102
"type": "computed",
117103
"value": "(UseManagedIdentity)"
118104
},
119-
"IsDevUIEnabled": {
120-
"type": "computed",
121-
"value": "(UseDevUI && !DoNotUseDevUI)"
122-
},
123105
"IsAzureOpenAI": {
124106
"type": "computed",
125107
"value": "(AiServiceProvider == \"azureopenai\")"

src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/Program.cs

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@
88
using Azure.Identity;
99
#endif
1010
using Microsoft.Agents.AI;
11-
#if (IsDevUIEnabled)
1211
using Microsoft.Agents.AI.DevUI;
13-
#endif
1412
using Microsoft.Agents.AI.Hosting;
1513
using Microsoft.Agents.AI.Workflows;
1614
using Microsoft.Extensions.AI;
1715
#if (IsOllama)
1816
using OllamaSharp;
19-
#elif (IsGHModels || IsOpenAI || IsAzureOpenAI)
17+
#endif
18+
#if (IsGHModels || IsAzureOpenAI)
2019
using OpenAI;
2120
#endif
22-
#if (IsGHModels)
21+
#if (IsGHModels || IsOpenAI || IsAzureOpenAI)
2322
using OpenAI.Chat;
2423
#endif
2524

@@ -35,21 +34,15 @@
3534
new ApiKeyCredential(builder.Configuration["GitHubModels:Token"] ?? throw new InvalidOperationException("Missing configuration: GitHubModels:Token.")),
3635
new OpenAIClientOptions { Endpoint = new Uri("https://models.inference.ai.azure.com") })
3736
.AsIChatClient();
38-
#elif (IsOllama)
39-
// You will need to have Ollama running locally with the llama3.2 model installed
40-
// Visit https://ollama.com for installation instructions
41-
var chatClient = new OllamaApiClient(new Uri("http://localhost:11434"), "llama3.2");
4237
#elif (IsOpenAI)
4338
// You will need to set the API key to your own value
4439
// You can do this using Visual Studio's "Manage User Secrets" UI, or on the command line:
4540
// cd this-project-directory
4641
// dotnet user-secrets set OpenAI:Key YOUR-API-KEY
47-
var openAIClient = new OpenAIClient(
48-
new ApiKeyCredential(builder.Configuration["OpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: OpenAI:Key.")));
49-
50-
#pragma warning disable OPENAI001 // GetOpenAIResponseClient(string) is experimental and subject to change or removal in future updates.
51-
var chatClient = openAIClient.GetOpenAIResponseClient("gpt-4o-mini").AsIChatClient();
52-
#pragma warning restore OPENAI001
42+
var chatClient = new ChatClient(
43+
"gpt-4o-mini",
44+
new ApiKeyCredential(builder.Configuration["OpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: OpenAI:Key.")))
45+
.AsIChatClient();
5346
#elif (IsAzureOpenAI)
5447
// You will need to set the endpoint to your own value
5548
// You can do this using Visual Studio's "Manage User Secrets" UI, or on the command line:
@@ -59,20 +52,26 @@
5952
// dotnet user-secrets set AzureOpenAI:Key YOUR-API-KEY
6053
#endif
6154
var azureOpenAIEndpoint = new Uri(new Uri(builder.Configuration["AzureOpenAI:Endpoint"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Endpoint.")), "/openai/v1");
62-
#if (IsManagedIdentity)
63-
#pragma warning disable OPENAI001 // OpenAIClient(AuthenticationPolicy, OpenAIClientOptions) and GetOpenAIResponseClient(string) are experimental and subject to change or removal in future updates.
64-
var azureOpenAI = new OpenAIClient(
65-
new BearerTokenPolicy(new DefaultAzureCredential(), "https://ai.azure.com/.default"),
66-
new OpenAIClientOptions { Endpoint = azureOpenAIEndpoint });
67-
68-
#elif (!IsManagedIdentity)
69-
var openAIOptions = new OpenAIClientOptions { Endpoint = azureOpenAIEndpoint };
70-
var azureOpenAI = new OpenAIClient(new ApiKeyCredential(builder.Configuration["AzureOpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Key.")), openAIOptions);
7155

72-
#pragma warning disable OPENAI001 // GetOpenAIResponseClient(string) is experimental and subject to change or removal in future updates.
73-
#endif
74-
var chatClient = azureOpenAI.GetOpenAIResponseClient("gpt-4o-mini").AsIChatClient();
56+
#if (IsManagedIdentity)
57+
#pragma warning disable OPENAI001 // The overload accepting an AuthenticationPolicy is experimental and may change or be removed in future releases.
58+
var chatClient = new ChatClient(
59+
"gpt-4o-mini",
60+
new BearerTokenPolicy(new DefaultAzureCredential(), "https://ai.azure.com/.default"),
61+
new OpenAIClientOptions { Endpoint = azureOpenAIEndpoint })
62+
.AsIChatClient();
7563
#pragma warning restore OPENAI001
64+
#else
65+
var chatClient = new ChatClient(
66+
"gpt-4o-mini",
67+
new ApiKeyCredential(builder.Configuration["AzureOpenAI:Key"] ?? throw new InvalidOperationException("Missing configuration: AzureOpenAI:Key.")),
68+
new OpenAIClientOptions { Endpoint = azureOpenAIEndpoint })
69+
.AsIChatClient();
70+
#endif
71+
#elif (IsOllama)
72+
// You will need to have Ollama running locally with the llama3.2 model installed
73+
// Visit https://ollama.com for installation instructions
74+
var chatClient = new OllamaApiClient(new Uri("http://localhost:11434"), "llama3.2");
7675
#endif
7776

7877
builder.Services.AddChatClient(chatClient);
@@ -92,31 +91,23 @@
9291
sp.GetRequiredKeyedService<AIAgent>("editor")
9392
)).AddAsAIAgent();
9493

95-
// Register services for OpenAI responses and conversations
96-
#if (IsDevUIEnabled)
97-
// This is also required for DevUI
98-
#endif
94+
// Register services for OpenAI responses and conversations (also required for DevUI)
9995
builder.Services.AddOpenAIResponses();
10096
builder.Services.AddOpenAIConversations();
10197

10298
var app = builder.Build();
10399
app.UseHttpsRedirection();
104100

105-
// Map endpoints for OpenAI responses and conversations
106-
#if (IsDevUIEnabled)
107-
// This is also required for DevUI
108-
#endif
101+
// Map endpoints for OpenAI responses and conversations (also required for DevUI)
109102
app.MapOpenAIResponses();
110103
app.MapOpenAIConversations();
111104

112-
#if (IsDevUIEnabled)
113105
if (builder.Environment.IsDevelopment())
114106
{
115107
// Map DevUI endpoint to /devui
116108
app.MapDevUI();
117109
}
118110

119-
#endif
120111
app.Run();
121112

122113
[Description("Formats the story for publication, revealing its title.")]
Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44
"http": {
55
"commandName": "Project",
66
"dotnetRunMessages": true,
7-
//#if (IsDevUIEnabled)
87
"launchBrowser": true,
98
"launchUrl": "devui/",
10-
//#else
11-
"launchBrowser": false,
12-
//#endif
139
"applicationUrl": "http://localhost:5056",
1410
"environmentVariables": {
1511
"ASPNETCORE_ENVIRONMENT": "Development"
@@ -18,12 +14,8 @@
1814
"https": {
1915
"commandName": "Project",
2016
"dotnetRunMessages": true,
21-
//#if (IsDevUIEnabled)
2217
"launchBrowser": true,
2318
"launchUrl": "devui/",
24-
//#else
25-
"launchBrowser": false,
26-
//#endif
2719
"applicationUrl": "https://localhost:7041;http://localhost:5056",
2820
"environmentVariables": {
2921
"ASPNETCORE_ENVIRONMENT": "Development"

src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,8 @@ The application will start and listen on:
165165

166166
The application exposes OpenAI-compatible API endpoints. You can interact with the AI agents using any OpenAI-compatible client or tools.
167167

168-
<!--#if (IsDevUIEnabled) -->
169168
In development environments, a `/devui/` route is mapped to the Agent Framework development UI (DevUI), and when the app is launched through an IDE a browser will open to this URL. DevUI provides a web-based UI for interacting with agents and workflows. DevUI operates as an OpenAI-compatible client using the Responses and Conversations endpoints.
170169

171-
<!--#endif -->
172170
## How It Works
173171

174172
This application demonstrates Agent Framework with:

src/ProjectTemplates/Microsoft.Agents.AI.Templates/src/WebApiAgent/WebApiAgent-CSharp/WebApiAgent-CSharp.csproj.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99

1010
<ItemGroup>
1111
<PackageReference Include="Microsoft.Agents.AI" Version="${TemplatePackageVersion_MicrosoftAgentsAI}" />
12-
<!--#if (IsDevUIEnabled) -->
1312
<PackageReference Include="Microsoft.Agents.AI.DevUI" Version="${TemplatePackageVersion_MicrosoftAgentsAI}" />
14-
<!--#endif -->
1513
<PackageReference Include="Microsoft.Agents.AI.Hosting" Version="${TemplatePackageVersion_MicrosoftAgentsAI}" />
1614
<PackageReference Include="Microsoft.Agents.AI.Hosting.OpenAI" Version="${TemplatePackageVersion_MicrosoftAgentsAIHostingOpenAI}" />
1715
<!--#if (IsOpenAI || IsAzureOpenAI || IsGHModels) -->

test/ProjectTemplates/Microsoft.Agents.AI.Templates.IntegrationTests/Microsoft.Agents.AI.Templates.Tests.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717

1818
<ItemGroup>
1919
<Compile Include="..\Infrastructure\*.cs" Link="Infrastructure\%(Filename)%(Extension)" />
20+
<Compile Remove="ExecutionTestSandbox\**" />
2021

2122
<Compile Remove="Snapshots\**\*.*" />
2223
<None Include="Snapshots\**\*.*" />
2324

24-
<Compile Remove="ExecutionTemplateSandbox\**\*.*" />
25-
<None Include="ExecutionTemplateSandbox\**\*.*" />
25+
<Content Remove="ExecutionTestSandbox\**" />
26+
<Compile Remove="ExecutionTestSandbox\**" />
27+
<EmbeddedResource Remove="ExecutionTestSandbox\**" />
28+
<None Remove="ExecutionTestSandbox\**" />
2629

2730
<None Include="README.md" />
2831
</ItemGroup>

0 commit comments

Comments
 (0)