diff --git a/app/Build/Commands/Qdrant.cs b/app/Build/Commands/Qdrant.cs index 923b5a47..3693c6f8 100644 --- a/app/Build/Commands/Qdrant.cs +++ b/app/Build/Commands/Qdrant.cs @@ -44,7 +44,8 @@ public static class Qdrant { using var archive = new ZipArchive(zStream, ZipArchiveMode.Read); archive.ExtractToDirectory(qdrantTmpExtractPath.FullName, overwriteFiles: true); - } else + } + else { await using var uncompressedStream = new GZipStream(zStream, CompressionMode.Decompress); await TarFile.ExtractToDirectoryAsync(uncompressedStream, qdrantTmpExtractPath.FullName, true); diff --git a/app/MindWork AI Studio.sln.DotSettings b/app/MindWork AI Studio.sln.DotSettings index faaedb6b..a304dae6 100644 --- a/app/MindWork AI Studio.sln.DotSettings +++ b/app/MindWork AI Studio.sln.DotSettings @@ -24,4 +24,6 @@ True True True + True + True True \ No newline at end of file diff --git a/app/MindWork AI Studio/Program.cs b/app/MindWork AI Studio/Program.cs index b67cdcfe..4c495bb3 100644 --- a/app/MindWork AI Studio/Program.cs +++ b/app/MindWork AI Studio/Program.cs @@ -87,7 +87,7 @@ internal sealed class Program } var qdrantInfo = await rust.GetQdrantInfo(); - if (qdrantInfo.Path == String.Empty) + if (qdrantInfo.Path == string.Empty) { Console.WriteLine("Error: Failed to get the Qdrant path from Rust."); return; diff --git a/app/MindWork AI Studio/Tools/Databases/DatabaseClient.cs b/app/MindWork AI Studio/Tools/Databases/DatabaseClient.cs index 3881a9fc..5ea457ec 100644 --- a/app/MindWork AI Studio/Tools/Databases/DatabaseClient.cs +++ b/app/MindWork AI Studio/Tools/Databases/DatabaseClient.cs @@ -3,7 +3,9 @@ public abstract class DatabaseClient(string name, string path) { public string Name => name; + private string Path => path; + protected ILogger? logger; public abstract IAsyncEnumerable<(string Label, string Value)> GetDisplayInfo(); diff --git a/app/MindWork AI Studio/Tools/Databases/Qdrant/QdrantClientImplementation.cs b/app/MindWork AI Studio/Tools/Databases/Qdrant/QdrantClientImplementation.cs index 4ef49dc1..77ae3636 100644 --- a/app/MindWork AI Studio/Tools/Databases/Qdrant/QdrantClientImplementation.cs +++ b/app/MindWork AI Studio/Tools/Databases/Qdrant/QdrantClientImplementation.cs @@ -6,10 +6,13 @@ namespace AIStudio.Tools.Databases.Qdrant; public class QdrantClientImplementation : DatabaseClient { private int HttpPort { get; } + private int GrpcPort { get; } - private string IpAddress => "localhost"; + private QdrantClient GrpcClient { get; } + private string Fingerprint { get; } + private string ApiToken { get; } public QdrantClientImplementation(string name, string path, int httpPort, int grpcPort, string fingerprint, string apiToken): base(name, path) @@ -21,9 +24,11 @@ public class QdrantClientImplementation : DatabaseClient this.GrpcClient = this.CreateQdrantClient(); } + private const string IP_ADDRESS = "localhost"; + public QdrantClient CreateQdrantClient() { - var address = "https://" + this.IpAddress + ":" + this.GrpcPort; + var address = "https://" + IP_ADDRESS + ":" + this.GrpcPort; var channel = QdrantChannel.ForAddress(address, new ClientConfiguration { ApiKey = this.ApiToken, diff --git a/app/MindWork AI Studio/Tools/Rust/QdrantInfo.cs b/app/MindWork AI Studio/Tools/Rust/QdrantInfo.cs index 6f9b2e5c..c847235f 100644 --- a/app/MindWork AI Studio/Tools/Rust/QdrantInfo.cs +++ b/app/MindWork AI Studio/Tools/Rust/QdrantInfo.cs @@ -3,13 +3,15 @@ /// /// The response of the Qdrant information request. /// -/// The port number for HTTP communication with Qdrant. -/// The port number for gRPC communication with Qdrant -public record struct QdrantInfo +public readonly record struct QdrantInfo { public string Path { get; init; } + public int PortHttp { get; init; } + public int PortGrpc { get; init; } + public string Fingerprint { get; init; } + public string ApiToken { get; init; } } \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/Services/RustService.Databases.cs b/app/MindWork AI Studio/Tools/Services/RustService.Databases.cs index a4e0eade..a43f6c61 100644 --- a/app/MindWork AI Studio/Tools/Services/RustService.Databases.cs +++ b/app/MindWork AI Studio/Tools/Services/RustService.Databases.cs @@ -14,15 +14,12 @@ public sealed partial class RustService } catch (Exception e) { - Console.WriteLine(e); - return new QdrantInfo - { - Path = string.Empty, - PortHttp = 0, - PortGrpc = 0, - Fingerprint = string.Empty, - ApiToken = string.Empty, - }; + if(this.logger is not null) + this.logger.LogError(e, "Error while fetching Qdrant info from Rust service."); + else + Console.WriteLine($"Error while fetching Qdrant info from Rust service: '{e}'."); + + return default; } } } \ No newline at end of file diff --git a/runtime/src/qdrant.rs b/runtime/src/qdrant.rs index 3dac0e8c..5be5720a 100644 --- a/runtime/src/qdrant.rs +++ b/runtime/src/qdrant.rs @@ -118,10 +118,12 @@ pub fn start_qdrant_server(){ } else { debug!(Source = "Qdrant Server"; "{line}"); } - } + }, + CommandEvent::Stderr(line) => { error!(Source = "Qdrant Server (stderr)"; "{line}"); - } + }, + _ => {} } } @@ -139,6 +141,7 @@ pub fn stop_qdrant_server() { } else { warn!(Source = "Qdrant"; "Qdrant server process was not started or is already stopped."); } + drop_tmpdir(); if let Err(e) = cleanup_qdrant(){ warn!(Source = "Qdrant"; "Error during the cleanup of Qdrant: {}", e); @@ -150,7 +153,6 @@ pub fn create_temp_tls_files(path: &PathBuf) -> Result<(PathBuf, PathBuf), Box