Skip to content

Commit fa798ad

Browse files
Initial chat template (#5837)
1 parent d63f2b4 commit fa798ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1855
-0
lines changed

src/ProjectTemplates/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# We're not tracking any package-lock.json files in source control here because
2+
# we don't ship pre-generated NPM lockfiles in the templates. But we don't put
3+
# them in the project template's .gitignore file because they should be tracked
4+
# in source control when people actually create projects from the templates.
5+
package-lock.json
6+
7+
*/src/**/*.csproj
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project>
2+
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
3+
4+
<PropertyGroup>
5+
<NoWarn>$(NoWarn);SA1633;CS1591</NoWarn>
6+
<SkipAnalyzers>true</SkipAnalyzers>
7+
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
8+
</PropertyGroup>
9+
</Project>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<PackageType>Template</PackageType>
5+
<TargetFrameworks>$(NetCoreTargetFrameworks);netstandard2.0</TargetFrameworks>
6+
<Description>Project templates for Microsoft.Extensions.AI.</Description>
7+
<PackageTags>dotnet-new;templates;ai</PackageTags>
8+
9+
<Stage>preview</Stage>
10+
<SuppressFinalPackageVersion>true</SuppressFinalPackageVersion>
11+
<Workstream>AI</Workstream>
12+
<MinCodeCoverage>0</MinCodeCoverage>
13+
<MinMutationScore>0</MinMutationScore>
14+
15+
<IsPackable>true</IsPackable>
16+
<IsProjectReferenceProvider>false</IsProjectReferenceProvider>
17+
<IncludeContentInPack>true</IncludeContentInPack>
18+
<IncludeBuildOutput>false</IncludeBuildOutput>
19+
<IncludeSymbols>false</IncludeSymbols>
20+
<ContentTargetFolders>content</ContentTargetFolders>
21+
<EnableDefaultItems>false</EnableDefaultItems>
22+
<NoDefaultExcludes>true</NoDefaultExcludes>
23+
<NoPackageAnalysis>true</NoPackageAnalysis>
24+
</PropertyGroup>
25+
26+
<ItemGroup>
27+
<Content Include="src\ChatWithCustomData\**\*" Exclude="**\bin\**;**\obj\**;**\node_modules\**;**\*.user;**\*.csproj.in;**\*.out.js;**\*.generated.css;**\package-lock.json" />
28+
<Compile Remove="**\*" />
29+
</ItemGroup>
30+
31+
<!-- Copy the .csproj.in files to corresponding .csproj files -->
32+
<!-- The reason they are initially .csproj.in is that there's no other way to exclude them from the main build -->
33+
<Target Name="PrepareCsprojFiles" BeforeTargets="PrepareForBuild">
34+
<ItemGroup>
35+
<_CsprojFiles Include="src\**\*.csproj.in" />
36+
</ItemGroup>
37+
<Copy SourceFiles="@(_CsprojFiles)" DestinationFiles="@(_CsprojFiles->'$([System.String]::Copy('%(Identity)').Replace('.csproj.in', '.csproj'))')" SkipUnchangedFiles="true" />
38+
</Target>
39+
40+
</Project>

src/ProjectTemplates/Microsoft.Extensions.AI.Templates/Microsoft.Extensions.AI.Templates.json

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Microsoft.Extensions.AI.Templates
2+
3+
Provides project templates for Microsoft.Extensions.AI.
5.42 KB
Loading
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "https://json.schemastore.org/ide.host",
3+
"order": 0,
4+
"icon": "icon.png",
5+
"symbolInfo": [
6+
{
7+
"id": "AiServiceProvider",
8+
"isVisible": true
9+
},
10+
{
11+
"id": "UseManagedIdentity",
12+
"isVisible": true
13+
},
14+
{
15+
"id": "VectorStore",
16+
"isVisible": true
17+
}
18+
]
19+
}
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
{
2+
"$schema": "http://json.schemastore.org/template",
3+
"author": "Microsoft",
4+
"classifications": [ "Common", "AI", "Web" ],
5+
"identity": "Microsoft.Extensions.AI.Templates.Chat.CSharp",
6+
"name": "AI Chat with Custom Data",
7+
"description": "A project template for creating an AI chat application. It can perform retrieval-augmented generation (RAG) using your own data.",
8+
"shortName": "chat",
9+
"defaultName": "ChatApp",
10+
"sourceName": "ChatWithCustomData.Web", // TODO: When we support multi-project output, this needs to change to ChatWithCustomData, then we need some other technique to make it avoid emitting a .Web suffix in the single-project case
11+
"tags": {
12+
"language": "C#",
13+
"type": "project"
14+
},
15+
"guids": [
16+
"d5681fae-b21b-4114-b781-48180f08c0c4"
17+
],
18+
"sources": [{
19+
"source": "./",
20+
"target": "./",
21+
"modifiers": [
22+
{
23+
// For now, we only produce single-project output.
24+
// Later when we support multi-project output with Qdrant on Docker, we'll also emit
25+
// a second project ChatWithCustomData.AppHost and hence will suppress this renaming.
26+
"rename": {
27+
"ChatWithCustomData.Web/": "./"
28+
}
29+
}
30+
]
31+
}],
32+
"symbols":{
33+
"framework": {
34+
"type": "parameter",
35+
"description": "The target framework for the project.",
36+
"datatype": "choice",
37+
"choices": [
38+
{
39+
"choice": "net9.0",
40+
"description": "Target net9.0"
41+
}
42+
],
43+
"replaces": "net9.0",
44+
"defaultValue": "net9.0"
45+
},
46+
"hostIdentifier": {
47+
"type": "bind",
48+
"binding": "HostIdentifier"
49+
},
50+
"AiServiceProvider": {
51+
"type": "parameter",
52+
"displayName": "_AI service provider",
53+
"datatype": "choice",
54+
"defaultValue": "azureopenai",
55+
"choices": [
56+
// {
57+
// "choice": "githubmodels",
58+
// "displayName": "GitHub Models",
59+
// "description": "Uses GitHub Models"
60+
// },
61+
{
62+
"choice": "azureopenai",
63+
"displayName": "Azure OpenAI",
64+
"description": "Uses Azure OpenAI service"
65+
},
66+
{
67+
"choice": "openai",
68+
"displayName": "OpenAI Platform",
69+
"description": "Uses the OpenAI Platform"
70+
},
71+
{
72+
"choice": "ollama",
73+
"displayName": "Ollama (for local development)",
74+
"description": "Uses Ollama with the llama3.2 model for local development"
75+
}
76+
// {
77+
// "choice": "azureaifoundry",
78+
// "displayName": "Azure AI Foundry (Preview)",
79+
// "description": "Uses Azure AI Foundry (Preview)"
80+
// }
81+
]
82+
},
83+
"UseManagedIdentity": {
84+
"type": "parameter",
85+
"displayName": "Use managed identity",
86+
"datatype": "bool",
87+
"defaultValue": "true",
88+
"isEnabled": "(AiServiceProvider == \"azureopenai\")",
89+
"description": "Use managed identity to access Azure services"
90+
},
91+
"VectorStore": {
92+
"type": "parameter",
93+
"displayName": "_Vector store",
94+
"datatype": "choice",
95+
"defaultValue": "local",
96+
"choices": [
97+
{
98+
"choice": "local",
99+
"displayName": "Local on-disk (for prototyping)",
100+
"description": "Uses a JSON file on disk. You can change the implementation to a real vector database before publishing."
101+
},
102+
{
103+
"choice": "azureaisearch",
104+
"displayName": "Azure AI Search",
105+
"description": "Uses Azure AI Search. This also avoids the need to define a data ingestion pipeline, since it's managed by Azure AI Search."
106+
}
107+
]
108+
},
109+
"IsAzureOpenAi": {
110+
"type": "computed",
111+
"value": "(AiServiceProvider == \"azureopenai\")"
112+
},
113+
"IsOpenAi": {
114+
"type": "computed",
115+
"value": "(AiServiceProvider == \"openai\")"
116+
},
117+
"IsGHModels": {
118+
"type": "computed",
119+
"value": "(AiServiceProvider == \"githubmodels\")"
120+
},
121+
"IsOllama": {
122+
"type": "computed",
123+
"value": "(AiServiceProvider == \"ollama\")"
124+
},
125+
"IsAzureAiFoundry": {
126+
"type": "computed",
127+
"value": "(AiServiceProvider == \"azureaifoundry\")"
128+
},
129+
"UseAzureAISearch": {
130+
"type": "computed",
131+
"value": "(VectorStore == \"azureaisearch\")"
132+
},
133+
"UseLocalVectorStore": {
134+
"type": "computed",
135+
"value": "(VectorStore == \"local\")"
136+
},
137+
"ChatModel": {
138+
"type": "parameter",
139+
"displayName": "Model/deployment for chat completions. Example: gpt-4o-mini",
140+
"description": "Model/deployment for chat completions. Example: gpt-4o-mini"
141+
},
142+
"EmbeddingModel": {
143+
"type": "parameter",
144+
"displayName": "Model/deployment for embeddings. Example: text-embedding-3-small",
145+
"description": "Model/deployment for embeddings. Example: text-embedding-3-small"
146+
},
147+
"OpenAiChatModelDefault": {
148+
"type": "generated",
149+
"generator": "constant",
150+
"parameters": {
151+
"value": "gpt-4o-mini"
152+
}
153+
},
154+
"OpenAiEmbeddingModelDefault": {
155+
"type": "generated",
156+
"generator": "constant",
157+
"parameters": {
158+
"value": "text-embedding-3-small"
159+
}
160+
},
161+
"OpenAiChatModel": {
162+
"type": "generated",
163+
"generator": "coalesce",
164+
"parameters": {
165+
"sourceVariableName": "ChatModel",
166+
"fallbackVariableName": "OpenAiChatModelDefault"
167+
},
168+
"replaces": "gpt-4o-mini"
169+
},
170+
"OpenAiEmbeddingModel": {
171+
"type": "generated",
172+
"generator": "coalesce",
173+
"parameters": {
174+
"sourceVariableName": "EmbeddingModel",
175+
"fallbackVariableName": "OpenAiEmbeddingModelDefault"
176+
},
177+
"replaces": "text-embedding-3-small"
178+
},
179+
"OllamaChatModelDefault": {
180+
"type": "generated",
181+
"generator": "constant",
182+
"parameters": {
183+
"value": "llama3.1"
184+
}
185+
},
186+
"OllamaEmbeddingModelDefault": {
187+
"type": "generated",
188+
"generator": "constant",
189+
"parameters": {
190+
"value": "all-minilm"
191+
}
192+
},
193+
"OllamaChatModel": {
194+
"type": "generated",
195+
"generator": "coalesce",
196+
"parameters": {
197+
"sourceVariableName": "ChatModel",
198+
"fallbackVariableName": "OllamaChatModelDefault"
199+
},
200+
"replaces": "llama3.2"
201+
},
202+
"OllamaEmbeddingModel": {
203+
"type": "generated",
204+
"generator": "coalesce",
205+
"parameters": {
206+
"sourceVariableName": "EmbeddingModel",
207+
"fallbackVariableName": "OllamaEmbeddingModelDefault"
208+
},
209+
"replaces": "all-minilm"
210+
}
211+
}
212+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.db
2+
*.db-*
3+
wwwroot/lib.out.js
4+
wwwroot/*.generated.css
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<Import Project="Tailwind.targets" />
4+
5+
<PropertyGroup>
6+
<TargetFramework>net9.0</TargetFramework>
7+
<Nullable>enable</Nullable>
8+
<ImplicitUsings>enable</ImplicitUsings>
9+
<UserSecretsId>d5681fae-b21b-4114-b781-48180f08c0c4</UserSecretsId>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<!--#if (IsOllama)
14+
<PackageReference Include="OllamaSharp" Version="5.0.5" />
15+
#elif (IsGHModels)
16+
<PackageReference Include="OpenAI" Version="2.1.0" />
17+
#elif (IsAzureAiFoundry)
18+
<PackageReference Include="Azure.AI.Projects" Version="1.0.0-beta.3" />
19+
<PackageReference Include="Azure.AI.OpenAI" Version="2.1.0" />
20+
#else -->
21+
<PackageReference Include="Azure.AI.OpenAI" Version="2.1.0" />
22+
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.1.0-preview.1.25064.3" />
23+
<!--#endif -->
24+
<!--#if (UseManagedIdentity) -->
25+
<PackageReference Include="Azure.Identity" Version="1.13.2" />
26+
<!--#endif -->
27+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0" />
28+
<PackageReference Include="Microsoft.Extensions.AI" Version="9.1.0-preview.1.25064.3" />
29+
<PackageReference Include="Microsoft.SemanticKernel.Core" Version="1.34.0" />
30+
<PackageReference Include="PdfPig" Version="0.1.9" />
31+
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
32+
<!--#if (UseAzureAISearch)
33+
<PackageReference Include="Azure.Search.Documents" Version="11.6.0" />
34+
<PackageReference Include="Microsoft.SemanticKernel.Connectors.AzureAISearch" Version="1.34.0-preview" />
35+
#endif -->
36+
</ItemGroup>
37+
38+
<ItemGroup>
39+
<Content Include="Data\**" CopyToOutputDirectory="PreserveNewest" />
40+
</ItemGroup>
41+
42+
<Target Name="BuildNpmDependencies" BeforeTargets="PrepareForBuild"
43+
Inputs="package-lock.json; rollup.config.js; wwwroot\lib.js" Outputs="wwwroot\lib.out.js">
44+
<Exec Command="npm install" />
45+
<Exec Command="npm run build" EnvironmentVariables="FORCE_COLOR=0" />
46+
</Target>
47+
48+
</Project>

0 commit comments

Comments
 (0)