2026-08-14 12:37:50 +02:00
using AIStudio.Tools.Databases.IndexStore ;
2026-05-27 20:02:43 +02:00
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 dataSourceId ,
VectorStoreClient ? vectorStore ,
2026-08-14 12:37:50 +02:00
IndexStoreClient ? indexStore ,
2026-07-28 15:25:10 +02:00
CancellationToken token )
2026-05-13 18:13:34 +02:00
{
2026-08-12 14:19:32 +02:00
await this . DeleteCollectionAsync ( DataSourceEmbeddingNames . GetCollectionName ( dataSourceId ), vectorStore , token );
2026-05-13 18:13:34 +02:00
2026-08-14 12:37:50 +02:00
indexStore ??= await databaseClientProvider . GetIndexStoreAsync ( token );
if (! indexStore . IsAvailable )
2026-05-13 18:13:34 +02:00
{
2026-08-14 12:37:50 +02:00
logger . LogWarning ( "Could not delete local RAG embedding state for data source '{DataSourceId}' because the database '{DatabaseName}' is unavailable." , dataSourceId , indexStore . 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-08-14 12:37:50 +02:00
await indexStore . DeleteDataSourceAsync ( dataSourceId , token );
logger . LogInformation ( "Reset persisted local RAG embedding state for data source '{DataSourceId}'." , dataSourceId );
2026-05-13 18:13:34 +02:00
}
}