Merge branch 'vectordb' of https://github.com/PaulKoudelka/AI-Studio into vectordb

This commit is contained in:
PaulKoudelka 2026-01-16 20:57:06 +01:00
commit 657ba066c6
8 changed files with 30 additions and 19 deletions

View File

@ -44,7 +44,8 @@ public static class Qdrant
{ {
using var archive = new ZipArchive(zStream, ZipArchiveMode.Read); using var archive = new ZipArchive(zStream, ZipArchiveMode.Read);
archive.ExtractToDirectory(qdrantTmpExtractPath.FullName, overwriteFiles: true); archive.ExtractToDirectory(qdrantTmpExtractPath.FullName, overwriteFiles: true);
} else }
else
{ {
await using var uncompressedStream = new GZipStream(zStream, CompressionMode.Decompress); await using var uncompressedStream = new GZipStream(zStream, CompressionMode.Decompress);
await TarFile.ExtractToDirectoryAsync(uncompressedStream, qdrantTmpExtractPath.FullName, true); await TarFile.ExtractToDirectoryAsync(uncompressedStream, qdrantTmpExtractPath.FullName, true);

View File

@ -24,4 +24,6 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=ieri/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=ieri/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=mwais/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=mwais/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ollama/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=ollama/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Qdrant/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=qdrant/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=tauri_0027s/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> <s:Boolean x:Key="/Default/UserDictionary/Words/=tauri_0027s/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -87,7 +87,7 @@ internal sealed class Program
} }
var qdrantInfo = await rust.GetQdrantInfo(); 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."); Console.WriteLine("Error: Failed to get the Qdrant path from Rust.");
return; return;

View File

@ -3,7 +3,9 @@
public abstract class DatabaseClient(string name, string path) public abstract class DatabaseClient(string name, string path)
{ {
public string Name => name; public string Name => name;
private string Path => path; private string Path => path;
protected ILogger<DatabaseClient>? logger; protected ILogger<DatabaseClient>? logger;
public abstract IAsyncEnumerable<(string Label, string Value)> GetDisplayInfo(); public abstract IAsyncEnumerable<(string Label, string Value)> GetDisplayInfo();

View File

@ -6,10 +6,13 @@ namespace AIStudio.Tools.Databases.Qdrant;
public class QdrantClientImplementation : DatabaseClient public class QdrantClientImplementation : DatabaseClient
{ {
private int HttpPort { get; } private int HttpPort { get; }
private int GrpcPort { get; } private int GrpcPort { get; }
private string IpAddress => "localhost";
private QdrantClient GrpcClient { get; } private QdrantClient GrpcClient { get; }
private string Fingerprint { get; } private string Fingerprint { get; }
private string ApiToken { get; } private string ApiToken { get; }
public QdrantClientImplementation(string name, string path, int httpPort, int grpcPort, string fingerprint, string apiToken): base(name, path) 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(); this.GrpcClient = this.CreateQdrantClient();
} }
private const string IP_ADDRESS = "localhost";
public QdrantClient CreateQdrantClient() public QdrantClient CreateQdrantClient()
{ {
var address = "https://" + this.IpAddress + ":" + this.GrpcPort; var address = "https://" + IP_ADDRESS + ":" + this.GrpcPort;
var channel = QdrantChannel.ForAddress(address, new ClientConfiguration var channel = QdrantChannel.ForAddress(address, new ClientConfiguration
{ {
ApiKey = this.ApiToken, ApiKey = this.ApiToken,

View File

@ -3,13 +3,15 @@
/// <summary> /// <summary>
/// The response of the Qdrant information request. /// The response of the Qdrant information request.
/// </summary> /// </summary>
/// <param name="portHTTP">The port number for HTTP communication with Qdrant.</param> public readonly record struct QdrantInfo
/// <param name="portGRPC">The port number for gRPC communication with Qdrant</param>
public record struct QdrantInfo
{ {
public string Path { get; init; } public string Path { get; init; }
public int PortHttp { get; init; } public int PortHttp { get; init; }
public int PortGrpc { get; init; } public int PortGrpc { get; init; }
public string Fingerprint { get; init; } public string Fingerprint { get; init; }
public string ApiToken { get; init; } public string ApiToken { get; init; }
} }

View File

@ -14,15 +14,12 @@ public sealed partial class RustService
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e); if(this.logger is not null)
return new QdrantInfo this.logger.LogError(e, "Error while fetching Qdrant info from Rust service.");
{ else
Path = string.Empty, Console.WriteLine($"Error while fetching Qdrant info from Rust service: '{e}'.");
PortHttp = 0,
PortGrpc = 0, return default;
Fingerprint = string.Empty,
ApiToken = string.Empty,
};
} }
} }
} }

View File

@ -118,10 +118,12 @@ pub fn start_qdrant_server(){
} else { } else {
debug!(Source = "Qdrant Server"; "{line}"); debug!(Source = "Qdrant Server"; "{line}");
} }
} },
CommandEvent::Stderr(line) => { CommandEvent::Stderr(line) => {
error!(Source = "Qdrant Server (stderr)"; "{line}"); error!(Source = "Qdrant Server (stderr)"; "{line}");
} },
_ => {} _ => {}
} }
} }
@ -139,6 +141,7 @@ pub fn stop_qdrant_server() {
} else { } else {
warn!(Source = "Qdrant"; "Qdrant server process was not started or is already stopped."); warn!(Source = "Qdrant"; "Qdrant server process was not started or is already stopped.");
} }
drop_tmpdir(); drop_tmpdir();
if let Err(e) = cleanup_qdrant(){ if let Err(e) = cleanup_qdrant(){
warn!(Source = "Qdrant"; "Error during the cleanup of Qdrant: {}", e); 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<d
let cert = generate_certificate(); let cert = generate_certificate();
let temp_dir = init_tmpdir_in(path); let temp_dir = init_tmpdir_in(path);
let cert_path = temp_dir.join("cert.pem"); let cert_path = temp_dir.join("cert.pem");
let key_path = temp_dir.join("key.pem"); let key_path = temp_dir.join("key.pem");