Skip to content
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

DRAFT: Adding support for an AI + .NET Aspire template #6083

Closed
wants to merge 2 commits into from
Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "https://json.schemastore.org/dotnetcli.host",
"symbolInfo": {
"kestrelHttpPort": {
"isHidden": true
},
"kestrelHttpsPort": {
"isHidden": true
}
},
"usageExamples": [
""
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://json.schemastore.org/ide.host",
"order": 0,
"icon": "ide/icon.ico",
"displayOverviewPage": "",
"symbolInfo": [
{
"id": "AiServiceProvider",
"isVisible": true
},
{
"id": "UseManagedIdentity",
"isVisible": true
},
{
"id": "VectorStore",
"isVisible": true
}
]
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,349 @@
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: I'm going with a separate template, instead of this being an "Add Aspire Support" for the existing AI Chat Web App Template. This is because a) there's a different approach to configuration and project structure for Aspire support, b) we likely will have additional options for Aspire that you wouldn't see in a non-Aspire scenario, and c) it's a lot easier to merge 2 down to 1 later than to unravel a lot of #if conditional logic.

"$schema": "http://json.schemastore.org/template",
"author": "Microsoft",
"classifications": [ "Common", "AI", "Web", "Aspire" ],
"identity": "Microsoft.Extensions.AI.Templates.AspireChat.CSharp",
"name": "AI + .NET Aspire Chat App",
"description": "A project template for creating an AI chat application using .NET Aspire, which uses retrieval-augmented generation (RAG) to chat with your own data.",
"shortName": "aiaspirechat",
"defaultName": "AspireChatApp",
"preferNameDirectory": false,
// The placeholder sourceName needs to contain a dash to ensure the CSS bundle asset uses the assembly identity name
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Left this comment in for now until we know that we've addressed the issue raised here. I haven't tested it yet.

// 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.
"sourceName": "AspireAIChat",
"tags": {
"language": "C#",
"type": "solution"
},
"guids": [
"7a0b8fb8-9be3-4771-a14c-5892e4244146",
"78c91fd1-cfe4-4e7d-a7bc-0227914b67b7",

],
"primaryOutputs": [
{
"path": "AspireAIChat.sln",
"condition": "(hostIdentifier == \"dotnetcli\" || hostIdentifier == \"dotnetcli-preview\")"
},
{"path": "./AspireAIChat.Web/AspireAIChat.Web.csproj"},
{"path": "./AspireAIChat.AppHost/AspireAIChat.AppHost.csproj"},
{"path": "./AspireAIChat.ServiceDefaults/AspireAIChat.ServiceDefaults.csproj"},
{"path": "./README.md"}
],
"sources": [{
"source": "./",
"target": "./",
"modifiers": [
{
"condition": "(hostIdentifier != \"dotnetcli\" && hostIdentifier != \"dotnetcli-preview\")",
"exclude": [
"*.sln"
]
}]
}],
"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",
"displayName": "Framework"
},
"hostIdentifier": {
"type": "bind",
"binding": "HostIdentifier"
},
"AiServiceProvider": {
"type": "parameter",
"displayName": "_AI service provider",
"datatype": "choice",
"defaultValue": "githubmodels",
"choices": [
{
"choice": "azureopenai",
"displayName": "Azure OpenAI",
"description": "Uses Azure OpenAI service"
},
{
"choice": "githubmodels",
"displayName": "GitHub Models",
"description": "Uses GitHub Models"
},
{
"choice": "ollama",
"displayName": "Ollama (for local development)",
"description": "Uses Ollama with the llama3.2 and all-minilm models"
},
{
"choice": "openai",
"displayName": "OpenAI Platform",
"description": "Uses the OpenAI Platform"
}
]
},
"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."
}
]
},
"UseManagedIdentity": {
"type": "parameter",
"displayName": "Use keyless authentication for Azure services",
"datatype": "bool",
"defaultValue": "true",
"isEnabled": "(AiServiceProvider == \"azureopenai\" || AiServiceProvider == \"azureaifoundry\" || VectorStore == \"azureaisearch\")",
"description": "Use managed identity to access Azure services"
},
"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\")"
},
"UseAzure": {
"type": "computed",
"value": "(IsAzureOpenAI || IsAzureAiFoundry || UseAzureAISearch)"
},
"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.2"
}
},
"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"
},
"kestrelHttpPort": {
"type": "parameter",
"datatype": "integer",
"description": "Port number to use for the HTTP endpoint in launchSettings.json."
},
"kestrelHttpPortGenerated": {
"type": "generated",
"generator": "port",
"parameters": {
"low": 5000,
"high": 5300
}
},
"kestrelHttpPortReplacer": {
"type": "generated",
"generator": "coalesce",
"parameters": {
"sourceVariableName": "kestrelHttpPort",
"fallbackVariableName": "kestrelHttpPortGenerated"
},
"replaces": "5000",
"onlyIf": [{
"after": "localhost:"
}]
},
"kestrelHttpsPort": {
"type": "parameter",
"datatype": "integer",
"description": "Port number to use for the HTTPS endpoint in launchSettings.json."
},
"kestrelHttpsPortGenerated": {
"type": "generated",
"generator": "port",
"parameters": {
"low": 7000,
"high": 7300
}
},
"kestrelHttpsPortReplacer": {
"type": "generated",
"generator": "coalesce",
"parameters": {
"sourceVariableName": "kestrelHttpsPort",
"fallbackVariableName": "kestrelHttpsPortGenerated"
},
"replaces": "5001",
"onlyIf": [{
"after": "localhost:"
}]
},
"vectorStoreIndexNameReplacer": {
"type": "derived",
"valueSource": "name",
"valueTransform": "vectorStoreIndexNameTransform",
"replaces": "data-ChatWithCustomData.Web-CSharp-ingestion"
}
},
"forms": {
"vectorStoreIndexNameTransform": {
"identifier": "chain",
"steps": [
"lowerCaseForm",
"vectorStoreIndexName_ReplaceIllegalCharacters",
"vectoreStoreIndexName_CollapseConsecutiveDashesUnderscores",
"vectorStoreIndexName_LengthLimit",
"vectorStoreIndexName_PrefixSuffix"
],
"description": "See https://learn.microsoft.com/rest/api/searchservice/naming-rules"
},
"lowerCaseForm": {
"identifier": "lowerCase"
},
"vectorStoreIndexName_ReplaceIllegalCharacters": {
"identifier": "replace",
"pattern": "[^a-z0-9-_]",
"replacement": "_",
"description": "Only letters, numbers, dashes, and underscores are allowed"
},
"vectoreStoreIndexName_CollapseConsecutiveDashesUnderscores": {
"identifier": "replace",
"pattern": "([-_])\\1+",
"replacement": "$1",
"description": "No consecutive dashes are underscores are allowed"
},
"vectorStoreIndexName_LengthLimit": {
"identifier": "replace",
"pattern": "^(.{0,114}).*",
"replacement": "$1",
"description": "Length is limited to 128 characters, including the 14 characters of prefix and suffix to be added."
},
"vectorStoreIndexName_PrefixSuffix": {
"identifier": "replace",
"pattern": "^(.*)$",
"replacement": "data-$1-ingested",
"description": "Produces a meaningful name parameterized by project name; ensures first, second, and last characters are valid"
}
},
"postActions": [{
"condition": "(hostIdentifier != \"dotnetcli\")",
"description": "Opens README file in the editor",
"manualInstructions": [ ],
"actionId": "84C0DA21-51C8-4541-9940-6CA19AF04EE6",
"args": {
"files": "1"
},
"continueOnError": true
}],
"SpecialCustomOperations": {
"**/*.md": {
"operations": [
{
"type": "conditional",
"configuration": {
"if": ["#### ---#if"],
"else": ["#### ---#else"],
"elseif": ["#### ---#elseif", "#### ---#elif"],
"endif": ["#### ---#endif"],
"trim" : "true",
"wholeLine": "true",
"evaluator": "C++"
}
}
]
}
}
}
Loading
Loading