Files
AI-Studio/app/MindWork AI Studio/Tools/Services/DataSourceEmbeddingService.State.cs
T

27 lines
1.1 KiB
C#
Raw Normal View History

2026-07-28 15:25:10 +02:00
using AIStudio.Tools.Databases.EmbeddingState;
using AIStudio.Tools.Databases.VectorStore;
2026-05-13 18:13:34 +02:00
namespace AIStudio.Tools.Services;
public sealed partial class DataSourceEmbeddingService
{
2026-07-28 15:25:10 +02:00
private async Task ResetPersistedStateAsync(
string dataSourceName,
string dataSourceId,
VectorStoreClient? vectorStore,
EmbeddingStateClient? embeddingState,
CancellationToken token)
2026-05-13 18:13:34 +02:00
{
2026-07-28 15:25:10 +02:00
await this.DeleteCollectionAsync(this.GetCollectionName(dataSourceName, dataSourceId), vectorStore, token);
2026-05-13 18:13:34 +02:00
2026-07-28 15:25:10 +02:00
embeddingState ??= await databaseClientProvider.GetEmbeddingStateAsync(token);
if (!embeddingState.IsAvailable)
2026-05-13 18:13:34 +02:00
{
logger.LogWarning("Could not delete local RAG index state for data source '{DataSourceId}' because the database '{DatabaseName}' is unavailable.", dataSourceId, embeddingState.Name);
2026-05-13 18:13:34 +02:00
return;
2026-07-28 15:25:10 +02:00
}
2026-05-13 18:13:34 +02:00
2026-07-28 15:25:10 +02:00
await embeddingState.DeleteDataSourceAsync(dataSourceId, token);
logger.LogInformation("Reset persisted local RAG index state for data source '{DataSourceId}'.", dataSourceId);
2026-05-13 18:13:34 +02:00
}
}