-
Notifications
You must be signed in to change notification settings - Fork 788
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
Closed
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions
14
...s/Microsoft.Extensions.AI.Templates/src/AspireAIChat/.template.config/dotnetcli.host.json
This file contains 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,14 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/dotnetcli.host", | ||
"symbolInfo": { | ||
"kestrelHttpPort": { | ||
"isHidden": true | ||
}, | ||
"kestrelHttpsPort": { | ||
"isHidden": true | ||
} | ||
}, | ||
"usageExamples": [ | ||
"" | ||
] | ||
} |
20 changes: 20 additions & 0 deletions
20
...mplates/Microsoft.Extensions.AI.Templates/src/AspireAIChat/.template.config/ide.host.json
This file contains 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,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 added
BIN
+12.8 KB
...emplates/Microsoft.Extensions.AI.Templates/src/AspireAIChat/.template.config/ide/icon.ico
Binary file not shown.
349 changes: 349 additions & 0 deletions
349
...mplates/Microsoft.Extensions.AI.Templates/src/AspireAIChat/.template.config/template.json
This file contains 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,349 @@ | ||
{ | ||
"$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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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++" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
Oops, something went wrong.
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.
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.