mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-12 20:53:48 +00:00
added manual refresh and cleaned up code
This commit is contained in:
1 parent
ac677c5ac7
commit
637bf9701b
19 files changed
+920
-642
No files matched your search
@@ -35,14 +35,15 @@ public abstract class EmbeddingStore(string name, string path)
|
||||
{
|
||||
string[] suffixes = { "B", "KB", "MB", "GB", "TB", "PB" };
|
||||
int suffixIndex = 0;
|
||||
double convertedSize = size;
|
||||
|
||||
while (size >= 1024 && suffixIndex < suffixes.Length - 1)
|
||||
while (convertedSize >= 1024 && suffixIndex < suffixes.Length - 1)
|
||||
{
|
||||
size /= 1024;
|
||||
convertedSize /= 1024;
|
||||
suffixIndex++;
|
||||
}
|
||||
|
||||
return $"{size:0##} {suffixes[suffixIndex]}";
|
||||
return $"{convertedSize:0.##} {suffixes[suffixIndex]}";
|
||||
}
|
||||
|
||||
public void SetLogger(ILogger<EmbeddingStore> logService)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Qdrant.Client;
|
||||
using Qdrant.Client.Grpc;
|
||||
using Grpc.Core;
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
using static Qdrant.Client.Grpc.Conditions;
|
||||
|
||||
@@ -104,14 +105,32 @@ public class QdrantClientImplementation : EmbeddingStore
|
||||
return this.GrpcClient.UpsertAsync(collectionName, qdrantPoints, true, null, null, token);
|
||||
}
|
||||
|
||||
public override Task DeleteEmbeddingByFile(string collectionName, string filePath, CancellationToken token)
|
||||
public override async Task DeleteEmbeddingByFile(string collectionName, string filePath, CancellationToken token)
|
||||
{
|
||||
return this.GrpcClient.DeleteAsync(collectionName, MatchKeyword("file_path", filePath), true, null, null, token);
|
||||
try
|
||||
{
|
||||
await this.GrpcClient.DeleteAsync(collectionName, MatchKeyword("file_path", filePath), true, null, null, token);
|
||||
}
|
||||
catch (RpcException exception) when (exception.StatusCode is StatusCode.NotFound)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override Task DeleteEmbeddingStore(string collectionName, CancellationToken token)
|
||||
public override async Task DeleteEmbeddingStore(string collectionName, CancellationToken token)
|
||||
{
|
||||
return this.GrpcClient.DeleteCollectionAsync(collectionName, cancellationToken: token);
|
||||
var exists = await this.GrpcClient.CollectionExistsAsync(collectionName, token);
|
||||
if (!exists)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
await this.GrpcClient.DeleteCollectionAsync(collectionName, cancellationToken: token);
|
||||
}
|
||||
catch (RpcException exception) when (exception.StatusCode is StatusCode.NotFound)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Dispose() => this.GrpcClient.Dispose();
|
||||
|
||||
Reference in new issue
Block a user