Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/ProjectTemplates/.gitignore
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
9 changes: 9 additions & 0 deletions src/ProjectTemplates/Directory.Build.props
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>
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>
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
}
]
}
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": {
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or is that expected to be implicitly understood for templates, that choices made at setup are easily alterable later?

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.

"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"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.db
*.db-*
wwwroot/lib.out.js
wwwroot/*.generated.css
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>
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);
}
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>
Loading