-
-
Notifications
You must be signed in to change notification settings - Fork 42
Add Qdrant as vector database #580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
dec2c27
Added functionality to download Qdrant and execute it as a background…
PaulKoudelka e16e3e0
Merge branch 'main' into vectordb
PaulKoudelka a79a299
Added pipeline to retrieve information for .NET runtime to create Qdr…
PaulKoudelka d5a396e
Merge branch 'vectordb' of https://github.com/PaulKoudelka/AI-Studio …
PaulKoudelka 8400422
Merge branch 'main' into vectordb
PaulKoudelka 1dcfd19
Added TLS and API token support for Qdrant communication.
PaulKoudelka 3f7b230
Formatting
SommerEngineering ef3d17d
Use a const instead
SommerEngineering 42d538d
Removed not used documentation
SommerEngineering cb453dc
Use a readonly record struct
SommerEngineering d9bec27
Improved logging
SommerEngineering e92b7be
Fixed C# syntax
SommerEngineering e383072
Added Qdrant to dict
SommerEngineering a4e0ee2
Formatting
SommerEngineering f579731
Drop the temp. directory last
SommerEngineering 1a0a6e2
Updated packages
SommerEngineering 8d850d8
Added handling of zombie processes in case of crashes and streamlined…
PaulKoudelka 657ba06
Merge branch 'vectordb' of https://github.com/PaulKoudelka/AI-Studio …
PaulKoudelka e9c8cbd
Merge branch 'main' into vectordb
PaulKoudelka 3589ec0
added a minor cleanup
PaulKoudelka d96ca6d
Merge branch 'main' into vectordb
PaulKoudelka ccb4967
fixed github build pipeline
PaulKoudelka 91bf83e
fixed jemalloc error for macOS
PaulKoudelka 223d288
fixed issues with stale processes
PaulKoudelka 84ddcb5
Merge branch 'main' into vectordb
PaulKoudelka b949660
Removed no longer needed imports
SommerEngineering 62758ae
Removed redundant default
SommerEngineering 95c6d19
Refactored list to use a data class instead of a tuple
SommerEngineering 0dd7d65
Improved logging behaviour
PaulKoudelka 2be5250
Changed I18N
PaulKoudelka a00fa48
improved build instruction guide
PaulKoudelka 6e6c4dd
Added deep link to the licence
SommerEngineering 0c0ad31
Revised added libraries descriptions & updated I18N
SommerEngineering 631092f
Formatting
SommerEngineering 0488b6e
Merge branch 'main' into pr/580
SommerEngineering f0b4cf2
Updated changelog
SommerEngineering f869101
Updated RAG work plan
SommerEngineering File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| namespace Build.Commands; | ||
|
|
||
| public record Database(string Path, string Filename); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| using System.Diagnostics.Eventing.Reader; | ||
| using System.Formats.Tar; | ||
| using System.IO.Compression; | ||
|
|
||
| using SharedTools; | ||
|
|
||
| namespace Build.Commands; | ||
|
|
||
| public static class Qdrant | ||
| { | ||
| public static async Task InstallAsync(RID rid, string version) | ||
| { | ||
| Console.Write($"- Installing Qdrant {version} for {rid.ToUserFriendlyName()} ..."); | ||
|
|
||
| var cwd = Environment.GetRustRuntimeDirectory(); | ||
| var qdrantTmpDownloadPath = Path.GetTempFileName(); | ||
| var qdrantTmpExtractPath = Directory.CreateTempSubdirectory(); | ||
| var qdrantUrl = GetQdrantDownloadUrl(rid, version); | ||
|
|
||
| // | ||
| // Download the file: | ||
| // | ||
| Console.Write(" downloading ..."); | ||
| using (var client = new HttpClient()) | ||
| { | ||
| var response = await client.GetAsync(qdrantUrl); | ||
| if (!response.IsSuccessStatusCode) | ||
| { | ||
| Console.WriteLine($" failed to download Qdrant {version} for {rid.ToUserFriendlyName()} from {qdrantUrl}"); | ||
| return; | ||
| } | ||
|
|
||
| await using var fileStream = File.Create(qdrantTmpDownloadPath); | ||
| await response.Content.CopyToAsync(fileStream); | ||
| } | ||
|
|
||
| // | ||
| // Extract the downloaded file: | ||
| // | ||
| Console.Write(" extracting ..."); | ||
| await using(var zStream = File.Open(qdrantTmpDownloadPath, FileMode.Open, FileAccess.Read, FileShare.Read)) | ||
| { | ||
| if (rid == RID.WIN_X64) | ||
| { | ||
| using var archive = new ZipArchive(zStream, ZipArchiveMode.Read); | ||
| archive.ExtractToDirectory(qdrantTmpExtractPath.FullName, overwriteFiles: true); | ||
| } else | ||
| { | ||
| await using var uncompressedStream = new GZipStream(zStream, CompressionMode.Decompress); | ||
| await TarFile.ExtractToDirectoryAsync(uncompressedStream, qdrantTmpExtractPath.FullName, true); | ||
| } | ||
| } | ||
|
|
||
| // | ||
| // Copy the database to the target directory: | ||
| // | ||
| Console.Write(" deploying ..."); | ||
| var database = GetDatabasePath(rid); | ||
| if (string.IsNullOrWhiteSpace(database.Path)) | ||
| { | ||
| Console.WriteLine($" failed to find the database path for {rid.ToUserFriendlyName()}"); | ||
| return; | ||
| } | ||
|
|
||
| var qdrantDBSourcePath = Path.Join(qdrantTmpExtractPath.FullName, database.Path); | ||
| var qdrantDBTargetPath = Path.Join(cwd, "resources", "databases", "qdrant",database.Filename); | ||
| if (!File.Exists(qdrantDBSourcePath)) | ||
| { | ||
| Console.WriteLine($" failed to find the database file '{qdrantDBSourcePath}'"); | ||
| return; | ||
| } | ||
|
|
||
| Directory.CreateDirectory(Path.Join(cwd, "resources", "databases", "qdrant")); | ||
| if (File.Exists(qdrantDBTargetPath)) | ||
| File.Delete(qdrantDBTargetPath); | ||
|
|
||
| File.Copy(qdrantDBSourcePath, qdrantDBTargetPath); | ||
|
|
||
| // | ||
| // Cleanup: | ||
| // | ||
| Console.Write(" cleaning up ..."); | ||
| File.Delete(qdrantTmpDownloadPath); | ||
| Directory.Delete(qdrantTmpExtractPath.FullName, true); | ||
|
|
||
| Console.WriteLine(" done."); | ||
| } | ||
|
|
||
| private static Database GetDatabasePath(RID rid) => rid switch | ||
| { | ||
| RID.OSX_ARM64 => new("qdrant", "qdrant-aarch64-apple-darwin"), | ||
| RID.OSX_X64 => new("qdrant", "qdrant-x86_64-apple-darwin"), | ||
|
|
||
| RID.LINUX_ARM64 => new("qdrant", "qdrant-aarch64-unknown-linux-musl"), | ||
| RID.LINUX_X64 => new("qdrant", "qdrant-x86_64-unknown-linux-gnu"), | ||
|
|
||
| RID.WIN_X64 => new("qdrant.exe", "qdrant-x86_64-pc-windows-msvc.exe"), | ||
| RID.WIN_ARM64 => new("qdrant.exe", "qdrant-aarch64-pc-windows-msvc.exe"), | ||
PaulKoudelka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| _ => new(string.Empty, string.Empty), | ||
| }; | ||
|
|
||
| private static string GetQdrantDownloadUrl(RID rid, string version) | ||
| { | ||
| var baseUrl = $"https://github.com/qdrant/qdrant/releases/download/v{version}/qdrant-"; | ||
| return rid switch | ||
| { | ||
| RID.LINUX_ARM64 => $"{baseUrl}aarch64-unknown-linux-musl.tar.gz", | ||
| RID.LINUX_X64 => $"{baseUrl}x86_64-unknown-linux-gnu.tar.gz", | ||
|
|
||
| RID.OSX_ARM64 => $"{baseUrl}aarch64-apple-darwin.tar.gz", | ||
| RID.OSX_X64 => $"{baseUrl}x86_64-apple-darwin.tar.gz", | ||
|
|
||
| RID.WIN_X64 => $"{baseUrl}x86_64-pc-windows-msvc.zip", | ||
| RID.WIN_ARM64 => $"{baseUrl}x86_64-pc-windows-msvc.zip", | ||
|
|
||
| _ => string.Empty, | ||
| }; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SommerEngineering marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.