mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-12 07:01:37 +00:00
Optimized code
This commit is contained in:
parent
4eb58eb56d
commit
34317fc219
@ -24,7 +24,7 @@
|
|||||||
<MudText Typo="Typo.body1">
|
<MudText Typo="Typo.body1">
|
||||||
@this.VersionDatabase
|
@this.VersionDatabase
|
||||||
</MudText>
|
</MudText>
|
||||||
<MudCollapse Expanded="@showDatabaseDetails">
|
<MudCollapse Expanded="@this.showDatabaseDetails">
|
||||||
<MudText Typo="Typo.body1" Class="mt-2 mb-2">
|
<MudText Typo="Typo.body1" Class="mt-2 mb-2">
|
||||||
@foreach (var item in this.databaseDisplayInfo)
|
@foreach (var item in this.databaseDisplayInfo)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,11 +6,11 @@ public abstract class DatabaseClient(string name, string path)
|
|||||||
|
|
||||||
private string Path => path;
|
private string Path => path;
|
||||||
|
|
||||||
protected ILogger<DatabaseClient>? logger;
|
private ILogger<DatabaseClient>? logger;
|
||||||
|
|
||||||
public abstract IAsyncEnumerable<(string Label, string Value)> GetDisplayInfo();
|
public abstract IAsyncEnumerable<(string Label, string Value)> GetDisplayInfo();
|
||||||
|
|
||||||
public string GetStorageSize()
|
protected string GetStorageSize()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(this.Path))
|
if (string.IsNullOrWhiteSpace(this.Path))
|
||||||
{
|
{
|
||||||
@ -29,7 +29,7 @@ public abstract class DatabaseClient(string name, string path)
|
|||||||
return FormatBytes(size);
|
return FormatBytes(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string FormatBytes(long size)
|
private static string FormatBytes(long size)
|
||||||
{
|
{
|
||||||
string[] suffixes = { "B", "KB", "MB", "GB", "TB", "PB" };
|
string[] suffixes = { "B", "KB", "MB", "GB", "TB", "PB" };
|
||||||
int suffixIndex = 0;
|
int suffixIndex = 0;
|
||||||
|
|||||||
@ -26,7 +26,7 @@ public class QdrantClientImplementation : DatabaseClient
|
|||||||
|
|
||||||
private const string IP_ADDRESS = "localhost";
|
private const string IP_ADDRESS = "localhost";
|
||||||
|
|
||||||
public QdrantClient CreateQdrantClient()
|
private QdrantClient CreateQdrantClient()
|
||||||
{
|
{
|
||||||
var address = "https://" + IP_ADDRESS + ":" + this.GrpcPort;
|
var address = "https://" + IP_ADDRESS + ":" + this.GrpcPort;
|
||||||
var channel = QdrantChannel.ForAddress(address, new ClientConfiguration
|
var channel = QdrantChannel.ForAddress(address, new ClientConfiguration
|
||||||
@ -38,13 +38,13 @@ public class QdrantClientImplementation : DatabaseClient
|
|||||||
return new QdrantClient(grpcClient);
|
return new QdrantClient(grpcClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string> GetVersion()
|
private async Task<string> GetVersion()
|
||||||
{
|
{
|
||||||
var operation = await this.GrpcClient.HealthAsync();
|
var operation = await this.GrpcClient.HealthAsync();
|
||||||
return "v"+operation.Version;
|
return "v"+operation.Version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string> GetCollectionsAmount()
|
private async Task<string> GetCollectionsAmount()
|
||||||
{
|
{
|
||||||
var operation = await this.GrpcClient.ListCollectionsAsync();
|
var operation = await this.GrpcClient.ListCollectionsAsync();
|
||||||
return operation.Count.ToString();
|
return operation.Count.ToString();
|
||||||
@ -59,8 +59,5 @@ public class QdrantClientImplementation : DatabaseClient
|
|||||||
yield return ("Amount of collections", await this.GetCollectionsAmount());
|
yield return ("Amount of collections", await this.GetCollectionsAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose() => this.GrpcClient.Dispose();
|
||||||
{
|
|
||||||
this.GrpcClient.Dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user