Improving the local dev experience#4
Conversation
Using more DI aspects so that we can inject the IVectorStore rather than having it hard-coded for a specific implmenetation. Cleaned up a bunch of warnings from around the codebase
This means that you can run it locally without having to have provisioned any Azure resources
There was a problem hiding this comment.
Copilot reviewed 5 out of 12 changed files in this pull request and generated no comments.
Files not reviewed (7)
- src/Products/Products.csproj: Language not supported
- src/eShopAppHost/eShopAppHost.csproj: Language not supported
- src/Products/Data/ProductDataContext.cs: Evaluated as low risk
- src/Store/Components/Pages/Products.razor: Evaluated as low risk
- src/Store/Components/Pages/Search.razor: Evaluated as low risk
- src/Products/Models/DbInitializer.cs: Evaluated as low risk
- src/Products/Endpoints/ProductEndpoints.cs: Evaluated as low risk
Comments suppressed due to low confidence (6)
src/eShopAppHost/Program.cs:21
- [nitpick] The variable name chatDeploymentName is ambiguous. It should be renamed to azureChatDeploymentName.
var chatDeploymentName = "gpt-4o-mini";
src/eShopAppHost/Program.cs:22
- [nitpick] The variable name embeddingsDeploymentName is ambiguous. It should be renamed to azureEmbeddingsDeploymentName.
var embeddingsDeploymentName = "text-embedding-ada-002";
src/eShopAppHost/Program.cs:43
- Ensure that the new functionality for Ollama is properly covered by tests.
var ollama = builder.AddOllama("ollama")
src/Products/Memory/MemoryContext.cs:22
- The
_systemPromptis defined twice in theMemoryContextclass. Remove the duplicate definition.
private string _systemPrompt = "You are a useful assistant. You always reply with a short and funny message. If you do not know an answer, you say 'I don't know that.' You only answer questions related to outdoor camping products. For any other type of questions, explain to the user that you only answer outdoor camping products questions. Do not store memory of the chat conversation.";
src/Products/Memory/MemoryContext.cs:15
- [nitpick] The use of
loggerinstead of_loggermight be inconsistent with the rest of the class. Ensure consistent naming for the logger instance.
ILogger<MemoryContext> logger,
src/Store/Services/ProductService.cs:38
- The return type should be non-nullable 'SearchResponse' to match the method's return statement.
public async Task<SearchResponse?> Search(string searchTerm, bool semanticSearch = false)
|
Super cool! Let's add also the support for CodeSpaces and DevContainers and we'll merge this ... |
There's already a devcontainer.json file, so it should be fine |
|
I'm not sure Codespaces should be a priority at the moment as there's a bug until Aspire 9.1 is released - dotnet/aspire#1178 |
There was a problem hiding this comment.
Copilot reviewed 5 out of 12 changed files in this pull request and generated 8 comments.
Files not reviewed (7)
- src/Products/Products.csproj: Language not supported
- src/eShopAppHost/eShopAppHost.csproj: Language not supported
- src/Products/Data/ProductDataContext.cs: Evaluated as low risk
- src/Store/Components/Pages/Products.razor: Evaluated as low risk
- src/Store/Components/Pages/Search.razor: Evaluated as low risk
- src/Products/Models/DbInitializer.cs: Evaluated as low risk
- src/Products/Endpoints/ProductEndpoints.cs: Evaluated as low risk
Comments suppressed due to low confidence (7)
src/Products/Memory/MemoryContext.cs:15
- The logger variable is used without being defined in the constructor.
ILogger<MemoryContext> logger,
src/Products/Memory/MemoryContext.cs:59
- The logger variable is used without being defined in the constructor.
logger.LogInformation("Product added to memory: {Product} with recordId: {RecordId}", product.Name, recordId);
src/Products/Memory/MemoryContext.cs:127
- The logger variable is used without being defined in the constructor.
logger.LogInformation("{ChatHistory}", JsonConvert.SerializeObject(messages));
src/Products/Memory/MemoryContext.cs:150
- The logger variable is used without being defined in the constructor.
Products = [firstProduct ?? new Product()],
src/Store/Services/ProductService.cs:18
- The variable name 'responseText' should be enclosed in braces for structured logging.
logger.LogInformation("Http response content: {responseText}", responseText);
src/Store/Services/ProductService.cs:38
- Changing the return type from 'SearchResponse?' to 'SearchResponse' might lead to unintended behavior if the response is null. Consider handling the null case explicitly.
public async Task<SearchResponse> Search(string searchTerm, bool semanticSearch = false)
src/VectorEntities/ProductVector.cs:12
- The Name property should be nullable to match the base class property.
public override string Name { get => base.Name; set => base.Name = value; }
|
@elbruno looks like the Bicep has a problem in this sample compared to our validation requirements |
|
I also had error After changing it in Program.cs to 8 it worked fine, but I lost some time because first I was trying to change it in bicep too. I suggest to update quota to 8 in Program.cs for gpt-4o-mini |
Thanks @yoozek , we can add that as a note in the main readme.md, feel free to create a PR with this! And now that Aspire support Codespaces, and more, we can review the option to have this running locally with ollama, and with azure services in the cloud. We need some time to merge these changes with the latest library updates. |
|
I'll update the branch when I get a moment |
|
closing the pr, archiving the repository |
Purpose
Running the current sample means that you have to have an Azure subscription and have pre-deployed some resources to be able to run it. This is a bit of a pain when you want to prototype or just explore the sample.
With this PR, we now use Ollama when running locally and Azure when publishing/deployed.
Does this introduce a breaking change?
Pull Request Type
What kind of change does this Pull Request introduce?