Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Improving the local dev experience#4

Closed
aaronpowell wants to merge 3 commits intoAzure-Samples:mainfrom
aaronpowell:improved-local
Closed

Improving the local dev experience#4
aaronpowell wants to merge 3 commits intoAzure-Samples:mainfrom
aaronpowell:improved-local

Conversation

@aaronpowell
Copy link
Member

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?

[x] Yes
[ ] No

Pull Request Type

What kind of change does this Pull Request introduce?

[ ] Bugfix
[x] Feature
[x] Code style update (formatting, local variables)
[x] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

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
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 _systemPrompt is defined twice in the MemoryContext class. 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 logger instead of _logger might 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)

@elbruno
Copy link
Contributor

elbruno commented Dec 17, 2024

Super cool! Let's add also the support for CodeSpaces and DevContainers and we'll merge this ...
Once merged, I'll update the main Readme to reflect these changes

@aaronpowell
Copy link
Member Author

Super cool! Let's add also the support for CodeSpaces and DevContainers and we'll merge this ... Once merged, I'll update the main Readme to reflect these changes

There's already a devcontainer.json file, so it should be fine

@aaronpowell
Copy link
Member Author

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

@elbruno elbruno self-assigned this Jan 13, 2025
@elbruno elbruno added the enhancement New feature or request label Jan 13, 2025
@aaronpowell aaronpowell requested a review from Copilot January 23, 2025 23:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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; }

@aaronpowell
Copy link
Member Author

@elbruno looks like the Bicep has a problem in this sample compared to our validation requirements

@yoozek
Copy link

yoozek commented Mar 16, 2025

I also had error
This operation require 10 new capacity in quota Tokens Per Minute (thousands) - gpt-4o-mini - GlobalStandard, which is bigger than the current available capacity 8. The current quota usage is 0 and the quota limit is 8 for quota Tokens Per Minute (thousands) - gpt-4o-mini - GlobalStandard.

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

@elbruno
Copy link
Contributor

elbruno commented Mar 16, 2025

I also had error This operation require 10 new capacity in quota Tokens Per Minute (thousands) - gpt-4o-mini - GlobalStandard, which is bigger than the current available capacity 8. The current quota usage is 0 and the quota limit is 8 for quota Tokens Per Minute (thousands) - gpt-4o-mini - GlobalStandard.

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.

@aaronpowell
Copy link
Member Author

I'll update the branch when I get a moment

@elbruno elbruno closed this Apr 24, 2025
@elbruno
Copy link
Contributor

elbruno commented Apr 24, 2025

closing the pr, archiving the repository

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants