-
Notifications
You must be signed in to change notification settings - Fork 829
Initial chat template #5837
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
Initial chat template #5837
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f175ae0
Building a near-empty project template
SteveSandersonMS d2671eb
Declare "preview" stage
SteveSandersonMS 9ef7c1b
Avoid build error
SteveSandersonMS 461f853
Reorganize projects to enable multi-project output in future
SteveSandersonMS 91855fd
Add content
SteveSandersonMS 4bc962e
Add symbols
SteveSandersonMS 15d3764
Build fixes
SteveSandersonMS f7559ac
Fix content inclusion
SteveSandersonMS 2c3882b
Fix reference
SteveSandersonMS c411944
Fix ingestion
SteveSandersonMS 5f6b171
Don't build the templated project itself in CI
SteveSandersonMS d6b93a0
Revert "Don't build the templated project itself in CI"
SteveSandersonMS eda3e57
To avoid build issues, have the template project csproj not be a cspr…
SteveSandersonMS 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# We're not tracking any package-lock.json files in source control here because | ||
# we don't ship pre-generated NPM lockfiles in the templates. But we don't put | ||
# them in the project template's .gitignore file because they should be tracked | ||
# in source control when people actually create projects from the templates. | ||
package-lock.json | ||
|
||
*/src/**/*.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,9 @@ | ||
<Project> | ||
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" /> | ||
|
||
<PropertyGroup> | ||
<NoWarn>$(NoWarn);SA1633;CS1591</NoWarn> | ||
<SkipAnalyzers>true</SkipAnalyzers> | ||
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally> | ||
</PropertyGroup> | ||
</Project> |
40 changes: 40 additions & 0 deletions
40
...ojectTemplates/Microsoft.Extensions.AI.Templates/Microsoft.Extensions.AI.Templates.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,40 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<PackageType>Template</PackageType> | ||
<TargetFrameworks>$(NetCoreTargetFrameworks);netstandard2.0</TargetFrameworks> | ||
<Description>Project templates for Microsoft.Extensions.AI.</Description> | ||
<PackageTags>dotnet-new;templates;ai</PackageTags> | ||
|
||
<Stage>preview</Stage> | ||
<SuppressFinalPackageVersion>true</SuppressFinalPackageVersion> | ||
<Workstream>AI</Workstream> | ||
<MinCodeCoverage>0</MinCodeCoverage> | ||
<MinMutationScore>0</MinMutationScore> | ||
|
||
<IsPackable>true</IsPackable> | ||
<IsProjectReferenceProvider>false</IsProjectReferenceProvider> | ||
<IncludeContentInPack>true</IncludeContentInPack> | ||
<IncludeBuildOutput>false</IncludeBuildOutput> | ||
<IncludeSymbols>false</IncludeSymbols> | ||
<ContentTargetFolders>content</ContentTargetFolders> | ||
<EnableDefaultItems>false</EnableDefaultItems> | ||
<NoDefaultExcludes>true</NoDefaultExcludes> | ||
<NoPackageAnalysis>true</NoPackageAnalysis> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="src\ChatWithCustomData\**\*" Exclude="**\bin\**;**\obj\**;**\node_modules\**;**\*.user;**\*.csproj.in;**\*.out.js;**\*.generated.css;**\package-lock.json" /> | ||
<Compile Remove="**\*" /> | ||
</ItemGroup> | ||
|
||
<!-- Copy the .csproj.in files to corresponding .csproj files --> | ||
<!-- The reason they are initially .csproj.in is that there's no other way to exclude them from the main build --> | ||
<Target Name="PrepareCsprojFiles" BeforeTargets="PrepareForBuild"> | ||
<ItemGroup> | ||
<_CsprojFiles Include="src\**\*.csproj.in" /> | ||
</ItemGroup> | ||
<Copy SourceFiles="@(_CsprojFiles)" DestinationFiles="@(_CsprojFiles->'$([System.String]::Copy('%(Identity)').Replace('.csproj.in', '.csproj'))')" SkipUnchangedFiles="true" /> | ||
</Target> | ||
|
||
</Project> |
Empty file.
3 changes: 3 additions & 0 deletions
3
src/ProjectTemplates/Microsoft.Extensions.AI.Templates/README.md
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,3 @@ | ||
# Microsoft.Extensions.AI.Templates | ||
|
||
Provides project templates for Microsoft.Extensions.AI. |
Binary file added
BIN
+5.42 KB
...rosoft.Extensions.AI.Templates/src/ChatWithCustomData/.template.config/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions
19
...s/Microsoft.Extensions.AI.Templates/src/ChatWithCustomData/.template.config/ide.host.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,19 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/ide.host", | ||
"order": 0, | ||
"icon": "icon.png", | ||
"symbolInfo": [ | ||
{ | ||
"id": "AiServiceProvider", | ||
"isVisible": true | ||
}, | ||
{ | ||
"id": "UseManagedIdentity", | ||
"isVisible": true | ||
}, | ||
{ | ||
"id": "VectorStore", | ||
"isVisible": true | ||
} | ||
] | ||
} |
212 changes: 212 additions & 0 deletions
212
...s/Microsoft.Extensions.AI.Templates/src/ChatWithCustomData/.template.config/template.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,212 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/template", | ||
"author": "Microsoft", | ||
"classifications": [ "Common", "AI", "Web" ], | ||
"identity": "Microsoft.Extensions.AI.Templates.Chat.CSharp", | ||
"name": "AI Chat with Custom Data", | ||
"description": "A project template for creating an AI chat application. It can perform retrieval-augmented generation (RAG) using your own data.", | ||
"shortName": "chat", | ||
"defaultName": "ChatApp", | ||
"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 | ||
"tags": { | ||
"language": "C#", | ||
"type": "project" | ||
}, | ||
"guids": [ | ||
"d5681fae-b21b-4114-b781-48180f08c0c4" | ||
], | ||
"sources": [{ | ||
"source": "./", | ||
"target": "./", | ||
"modifiers": [ | ||
{ | ||
// For now, we only produce single-project output. | ||
// Later when we support multi-project output with Qdrant on Docker, we'll also emit | ||
// a second project ChatWithCustomData.AppHost and hence will suppress this renaming. | ||
"rename": { | ||
"ChatWithCustomData.Web/": "./" | ||
} | ||
} | ||
] | ||
}], | ||
"symbols":{ | ||
"framework": { | ||
"type": "parameter", | ||
"description": "The target framework for the project.", | ||
"datatype": "choice", | ||
"choices": [ | ||
{ | ||
"choice": "net9.0", | ||
"description": "Target net9.0" | ||
} | ||
], | ||
"replaces": "net9.0", | ||
"defaultValue": "net9.0" | ||
}, | ||
"hostIdentifier": { | ||
"type": "bind", | ||
"binding": "HostIdentifier" | ||
}, | ||
"AiServiceProvider": { | ||
"type": "parameter", | ||
"displayName": "_AI service provider", | ||
"datatype": "choice", | ||
"defaultValue": "azureopenai", | ||
"choices": [ | ||
// { | ||
// "choice": "githubmodels", | ||
// "displayName": "GitHub Models", | ||
// "description": "Uses GitHub Models" | ||
// }, | ||
{ | ||
"choice": "azureopenai", | ||
"displayName": "Azure OpenAI", | ||
"description": "Uses Azure OpenAI service" | ||
}, | ||
{ | ||
"choice": "openai", | ||
"displayName": "OpenAI Platform", | ||
"description": "Uses the OpenAI Platform" | ||
}, | ||
{ | ||
"choice": "ollama", | ||
"displayName": "Ollama (for local development)", | ||
"description": "Uses Ollama with the llama3.2 model for local development" | ||
} | ||
// { | ||
// "choice": "azureaifoundry", | ||
// "displayName": "Azure AI Foundry (Preview)", | ||
// "description": "Uses Azure AI Foundry (Preview)" | ||
// } | ||
] | ||
}, | ||
"UseManagedIdentity": { | ||
"type": "parameter", | ||
"displayName": "Use managed identity", | ||
"datatype": "bool", | ||
"defaultValue": "true", | ||
"isEnabled": "(AiServiceProvider == \"azureopenai\")", | ||
"description": "Use managed identity to access Azure services" | ||
}, | ||
"VectorStore": { | ||
"type": "parameter", | ||
"displayName": "_Vector store", | ||
"datatype": "choice", | ||
"defaultValue": "local", | ||
"choices": [ | ||
{ | ||
"choice": "local", | ||
"displayName": "Local on-disk (for prototyping)", | ||
"description": "Uses a JSON file on disk. You can change the implementation to a real vector database before publishing." | ||
}, | ||
{ | ||
"choice": "azureaisearch", | ||
"displayName": "Azure AI Search", | ||
"description": "Uses Azure AI Search. This also avoids the need to define a data ingestion pipeline, since it's managed by Azure AI Search." | ||
} | ||
] | ||
}, | ||
"IsAzureOpenAi": { | ||
"type": "computed", | ||
"value": "(AiServiceProvider == \"azureopenai\")" | ||
}, | ||
"IsOpenAi": { | ||
"type": "computed", | ||
"value": "(AiServiceProvider == \"openai\")" | ||
}, | ||
"IsGHModels": { | ||
"type": "computed", | ||
"value": "(AiServiceProvider == \"githubmodels\")" | ||
}, | ||
"IsOllama": { | ||
"type": "computed", | ||
"value": "(AiServiceProvider == \"ollama\")" | ||
}, | ||
"IsAzureAiFoundry": { | ||
"type": "computed", | ||
"value": "(AiServiceProvider == \"azureaifoundry\")" | ||
}, | ||
"UseAzureAISearch": { | ||
"type": "computed", | ||
"value": "(VectorStore == \"azureaisearch\")" | ||
}, | ||
"UseLocalVectorStore": { | ||
"type": "computed", | ||
"value": "(VectorStore == \"local\")" | ||
}, | ||
"ChatModel": { | ||
"type": "parameter", | ||
"displayName": "Model/deployment for chat completions. Example: gpt-4o-mini", | ||
"description": "Model/deployment for chat completions. Example: gpt-4o-mini" | ||
}, | ||
"EmbeddingModel": { | ||
"type": "parameter", | ||
"displayName": "Model/deployment for embeddings. Example: text-embedding-3-small", | ||
"description": "Model/deployment for embeddings. Example: text-embedding-3-small" | ||
}, | ||
"OpenAiChatModelDefault": { | ||
"type": "generated", | ||
"generator": "constant", | ||
"parameters": { | ||
"value": "gpt-4o-mini" | ||
} | ||
}, | ||
"OpenAiEmbeddingModelDefault": { | ||
"type": "generated", | ||
"generator": "constant", | ||
"parameters": { | ||
"value": "text-embedding-3-small" | ||
} | ||
}, | ||
"OpenAiChatModel": { | ||
"type": "generated", | ||
"generator": "coalesce", | ||
"parameters": { | ||
"sourceVariableName": "ChatModel", | ||
"fallbackVariableName": "OpenAiChatModelDefault" | ||
}, | ||
"replaces": "gpt-4o-mini" | ||
}, | ||
"OpenAiEmbeddingModel": { | ||
"type": "generated", | ||
"generator": "coalesce", | ||
"parameters": { | ||
"sourceVariableName": "EmbeddingModel", | ||
"fallbackVariableName": "OpenAiEmbeddingModelDefault" | ||
}, | ||
"replaces": "text-embedding-3-small" | ||
}, | ||
"OllamaChatModelDefault": { | ||
"type": "generated", | ||
"generator": "constant", | ||
"parameters": { | ||
"value": "llama3.1" | ||
} | ||
}, | ||
"OllamaEmbeddingModelDefault": { | ||
"type": "generated", | ||
"generator": "constant", | ||
"parameters": { | ||
"value": "all-minilm" | ||
} | ||
}, | ||
"OllamaChatModel": { | ||
"type": "generated", | ||
"generator": "coalesce", | ||
"parameters": { | ||
"sourceVariableName": "ChatModel", | ||
"fallbackVariableName": "OllamaChatModelDefault" | ||
}, | ||
"replaces": "llama3.2" | ||
}, | ||
"OllamaEmbeddingModel": { | ||
"type": "generated", | ||
"generator": "coalesce", | ||
"parameters": { | ||
"sourceVariableName": "EmbeddingModel", | ||
"fallbackVariableName": "OllamaEmbeddingModelDefault" | ||
}, | ||
"replaces": "all-minilm" | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...icrosoft.Extensions.AI.Templates/src/ChatWithCustomData/ChatWithCustomData.Web/.gitignore
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,4 @@ | ||
*.db | ||
*.db-* | ||
wwwroot/lib.out.js | ||
wwwroot/*.generated.css |
48 changes: 48 additions & 0 deletions
48
....Templates/src/ChatWithCustomData/ChatWithCustomData.Web/ChatWithCustomData.Web.csproj.in
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,48 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<Import Project="Tailwind.targets" /> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<UserSecretsId>d5681fae-b21b-4114-b781-48180f08c0c4</UserSecretsId> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<!--#if (IsOllama) | ||
<PackageReference Include="OllamaSharp" Version="5.0.5" /> | ||
#elif (IsGHModels) | ||
<PackageReference Include="OpenAI" Version="2.1.0" /> | ||
#elif (IsAzureAiFoundry) | ||
<PackageReference Include="Azure.AI.Projects" Version="1.0.0-beta.3" /> | ||
<PackageReference Include="Azure.AI.OpenAI" Version="2.1.0" /> | ||
#else --> | ||
<PackageReference Include="Azure.AI.OpenAI" Version="2.1.0" /> | ||
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.1.0-preview.1.25064.3" /> | ||
<!--#endif --> | ||
<!--#if (UseManagedIdentity) --> | ||
<PackageReference Include="Azure.Identity" Version="1.13.2" /> | ||
<!--#endif --> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.AI" Version="9.1.0-preview.1.25064.3" /> | ||
<PackageReference Include="Microsoft.SemanticKernel.Core" Version="1.34.0" /> | ||
<PackageReference Include="PdfPig" Version="0.1.9" /> | ||
<PackageReference Include="System.Linq.Async" Version="6.0.1" /> | ||
<!--#if (UseAzureAISearch) | ||
<PackageReference Include="Azure.Search.Documents" Version="11.6.0" /> | ||
<PackageReference Include="Microsoft.SemanticKernel.Connectors.AzureAISearch" Version="1.34.0-preview" /> | ||
#endif --> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="Data\**" CopyToOutputDirectory="PreserveNewest" /> | ||
</ItemGroup> | ||
|
||
<Target Name="BuildNpmDependencies" BeforeTargets="PrepareForBuild" | ||
Inputs="package-lock.json; rollup.config.js; wwwroot\lib.js" Outputs="wwwroot\lib.out.js"> | ||
<Exec Command="npm install" /> | ||
<Exec Command="npm run build" EnvironmentVariables="FORCE_COLOR=0" /> | ||
</Target> | ||
|
||
</Project> |
24 changes: 24 additions & 0 deletions
24
...xtensions.AI.Templates/src/ChatWithCustomData/ChatWithCustomData.Web/Components/App.razor
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,24 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<base href="/" /> | ||
<link rel="stylesheet" href="@Assets["app.generated.css"]" /> | ||
<link rel="stylesheet" href="@Assets["ChatWithCustomData.Web.styles.css"]" /> | ||
<ImportMap /> | ||
<HeadOutlet @rendermode="@renderMode" /> | ||
</head> | ||
|
||
<body> | ||
<Routes @rendermode="@renderMode" /> | ||
<script src="lib.out.js"></script> | ||
<script src="_framework/blazor.web.js"></script> | ||
</body> | ||
|
||
</html> | ||
|
||
@code { | ||
private readonly IComponentRenderMode renderMode = new InteractiveServerRenderMode(prerender: false); | ||
} |
1 change: 1 addition & 0 deletions
1
...ates/src/ChatWithCustomData/ChatWithCustomData.Web/Components/Layout/LoadingSpinner.razor
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 @@ | ||
<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div> |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way to communicate that the choice made here can easily be changed later, e.g. the Ollama section suggests that's using llama3.2, but changing that later is changing a single string. Or is that expected to be implicitly understood for templates, that choices made at setup are easily alterable later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to resolve all the conversations before CI will let me merge this. I'll unresolve after it merges.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general no. Choices made at setup can be arbitrarily impactful. For example in the ASP.NET Core templates, whether or not you enable auth makes a huge difference and it's very much not easy to alter it later.
I don't think we need to provide specific guidance in the template wizard about what choices are easily changeable later. At least, it's not a thing we normally do.