mirror of
https://github.com/marcominerva/SqlDatabaseVectorSearch.git
synced 2026-08-04 09:48:57 +00:00
Refactor scope creation and update namespace imports
Replaced `IServiceProvider` with `IServiceScopeFactory` for async scope creation, updated injected services and usages, switched namespace import from `System.Text.RegularExpressions` to `Microsoft.Extensions.AI`, and simplified the `FormatTokenUsageDetails` method signature to use the unqualified `UsageDetails` type.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
@page "/ask"
|
||||
@using System.Text.RegularExpressions
|
||||
@using Microsoft.Extensions.AI
|
||||
|
||||
@inject IServiceProvider ServiceProvider
|
||||
@inject IServiceScopeFactory ServiceScopeFactory
|
||||
@inject IJSRuntime JSRuntime
|
||||
|
||||
<PageTitle>Chat with your data</PageTitle>
|
||||
@@ -176,7 +176,7 @@
|
||||
|
||||
try
|
||||
{
|
||||
await using var scope = ServiceProvider.CreateAsyncScope();
|
||||
await using var scope = ServiceScopeFactory.CreateAsyncScope();
|
||||
var vectorSearchService = scope.ServiceProvider.GetRequiredService<VectorSearchService>();
|
||||
|
||||
var response = vectorSearchService.AskStreamingAsync(userQuestion);
|
||||
@@ -260,7 +260,7 @@
|
||||
|
||||
return $"{reformulation}{question}";
|
||||
|
||||
static string FormatTokenUsageDetails(Microsoft.Extensions.AI.UsageDetails? tokenUsage)
|
||||
static string FormatTokenUsageDetails(UsageDetails? tokenUsage)
|
||||
{
|
||||
if (tokenUsage is null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user