-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Open
PaulKoudelka
wants to merge
5
commits into
MindWorkAI:main
Choose a base branch
from
PaulKoudelka:vectordb
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 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 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,119 @@ | ||
| 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-gnu"), | ||
| RID.LINUX_X64 => new("qdrant", "qdrant-x86_64-unknown-linux-gnu"), | ||
|
|
||
| RID.WIN_X64 => new("qdrant.exe", "qdrant-x86_64-pc-windows-msvc.exe"), | ||
|
|
||
| _ => 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", | ||
| #warning We have to handle Qdrant for Windows ARM | ||
|
|
||
| _ => 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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will then also need to update the German language