mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-08-11 19:12:11 +00:00
28 lines
1.1 KiB
C#
28 lines
1.1 KiB
C#
using AIStudio.Tools.Databases.EmbeddingState;
|
|
using AIStudio.Tools.Databases.VectorStore;
|
|
|
|
namespace AIStudio.Tools.Services;
|
|
|
|
public sealed partial class DataSourceEmbeddingService
|
|
{
|
|
private async Task ResetPersistedStateAsync(
|
|
string dataSourceName,
|
|
string dataSourceId,
|
|
VectorStoreClient? vectorStore,
|
|
EmbeddingStateClient? embeddingState,
|
|
CancellationToken token)
|
|
{
|
|
await this.DeleteCollectionAsync(this.GetCollectionName(dataSourceName, dataSourceId), vectorStore, token);
|
|
|
|
embeddingState ??= await databaseClientProvider.GetEmbeddingStateAsync(token);
|
|
if (!embeddingState.IsAvailable)
|
|
{
|
|
logger.LogWarning("Could not delete local RAG index state for data source '{DataSourceId}' because the database '{DatabaseName}' is unavailable.", dataSourceId, embeddingState.Name);
|
|
return;
|
|
}
|
|
|
|
await embeddingState.DeleteDataSourceAsync(dataSourceId, token);
|
|
logger.LogInformation("Reset persisted local RAG index state for data source '{DataSourceId}'.", dataSourceId);
|
|
}
|
|
}
|