Skip to content
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

Initial work for Qdrant resource and component #3131

Merged
merged 23 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
be52204
Initial draft of QdrantServerResource
timheuer Mar 23, 2024
195b576
Fix-up after main rebase on removing InputAnnotation
timheuer Mar 24, 2024
c518502
Remove dashboard in Publish mode
timheuer Mar 24, 2024
3e584ab
Fixup code style violations
timheuer Mar 24, 2024
82062d3
Change ApiKey reference
timheuer Mar 24, 2024
988323b
Initial Qdrant component work
timheuer Mar 24, 2024
77d6e6c
Changed rest endpoint name
timheuer Mar 24, 2024
e8d6a44
Addressing PR feedback
timheuer Mar 25, 2024
7c1896c
Fixing volume mounts to correct target location
timheuer Mar 25, 2024
c529d5d
Add missing README to component
timheuer Mar 25, 2024
805f8d9
Adding logo usage comment to readme after permission from Andrey V fr…
timheuer Mar 25, 2024
e257502
Changed playground sample
timheuer Mar 25, 2024
637c4f7
PR Feedback: Name maps to client name used
timheuer Mar 28, 2024
8a8b80a
PR feedback on connection sring
timheuer Mar 28, 2024
ca9d778
Updating readme/comments to match config
timheuer Mar 28, 2024
d098349
Endpoint property typo fix
timheuer Mar 28, 2024
281846e
PR Feedback
timheuer Mar 29, 2024
9f341df
Cleanup of ServiceDefaults
timheuer Mar 29, 2024
c12a646
More PR Feedback
timheuer Mar 29, 2024
ea360c8
PR feedback
eerhardt Apr 4, 2024
58b6548
Merge remote-tracking branch 'upstream/main' into qdrant
eerhardt Apr 4, 2024
1418710
Fix up the playground to run with latest changes.
eerhardt Apr 4, 2024
26c5f88
Rename QdrantSettings to QdrantClientSettings to match the pattern in…
eerhardt Apr 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Aspire.sln
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,22 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.Hosting.Azure.Sql",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.Hosting.Azure.Storage", "src\Aspire.Hosting.Azure.Storage\Aspire.Hosting.Azure.Storage.csproj", "{89E9F2B8-662C-4FFA-8F69-360680362653}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.Hosting.Qdrant", "src\Aspire.Hosting.Qdrant\Aspire.Hosting.Qdrant.csproj", "{D3CDBA75-7707-4884-908D-1BA22B8DF8E7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "qdrant", "qdrant", "{A4800EE3-F902-4B7B-AF53-01A85514E6B9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Qdrant.ServiceDefaults", "playground\Qdrant\Qdrant.ServiceDefaults\Qdrant.ServiceDefaults.csproj", "{F6861204-D0A8-4E7D-9479-FA3E2F4DE93F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Qdrant.AppHost", "playground\Qdrant\Qdrant.AppHost\Qdrant.AppHost.csproj", "{F43586B8-FE36-490D-9EFA-82CFFB83A304}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Qdrant.ApiService", "playground\Qdrant\Qdrant.ApiService\Qdrant.ApiService.csproj", "{6B6D3953-E961-4720-B27E-9466A69BED1A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.Hosting.Tests.SharedShim", "tests\Aspire.Hosting.Tests.SharedShim\Aspire.Hosting.Tests.SharedShim.csproj", "{74644A4D-8F61-4314-B6E8-5CE3802CD6C2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.Hosting.Azure.KeyVault", "src\Aspire.Hosting.Azure.KeyVault\Aspire.Hosting.Azure.KeyVault.csproj", "{427F4D7C-8969-4015-AD1A-5EFFE921A184}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.Qdrant", "src\Components\Aspire.Qdrant\Aspire.Qdrant.csproj", "{E0E1B557-D3CF-4446-B993-E5CE719234FB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1077,6 +1089,22 @@ Global
{89E9F2B8-662C-4FFA-8F69-360680362653}.Debug|Any CPU.Build.0 = Debug|Any CPU
{89E9F2B8-662C-4FFA-8F69-360680362653}.Release|Any CPU.ActiveCfg = Release|Any CPU
{89E9F2B8-662C-4FFA-8F69-360680362653}.Release|Any CPU.Build.0 = Release|Any CPU
{D3CDBA75-7707-4884-908D-1BA22B8DF8E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3CDBA75-7707-4884-908D-1BA22B8DF8E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3CDBA75-7707-4884-908D-1BA22B8DF8E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3CDBA75-7707-4884-908D-1BA22B8DF8E7}.Release|Any CPU.Build.0 = Release|Any CPU
{F6861204-D0A8-4E7D-9479-FA3E2F4DE93F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F6861204-D0A8-4E7D-9479-FA3E2F4DE93F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6861204-D0A8-4E7D-9479-FA3E2F4DE93F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F6861204-D0A8-4E7D-9479-FA3E2F4DE93F}.Release|Any CPU.Build.0 = Release|Any CPU
{F43586B8-FE36-490D-9EFA-82CFFB83A304}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F43586B8-FE36-490D-9EFA-82CFFB83A304}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F43586B8-FE36-490D-9EFA-82CFFB83A304}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F43586B8-FE36-490D-9EFA-82CFFB83A304}.Release|Any CPU.Build.0 = Release|Any CPU
{6B6D3953-E961-4720-B27E-9466A69BED1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6B6D3953-E961-4720-B27E-9466A69BED1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B6D3953-E961-4720-B27E-9466A69BED1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6B6D3953-E961-4720-B27E-9466A69BED1A}.Release|Any CPU.Build.0 = Release|Any CPU
{74644A4D-8F61-4314-B6E8-5CE3802CD6C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74644A4D-8F61-4314-B6E8-5CE3802CD6C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74644A4D-8F61-4314-B6E8-5CE3802CD6C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -1085,6 +1113,10 @@ Global
{427F4D7C-8969-4015-AD1A-5EFFE921A184}.Debug|Any CPU.Build.0 = Debug|Any CPU
{427F4D7C-8969-4015-AD1A-5EFFE921A184}.Release|Any CPU.ActiveCfg = Release|Any CPU
{427F4D7C-8969-4015-AD1A-5EFFE921A184}.Release|Any CPU.Build.0 = Release|Any CPU
{E0E1B557-D3CF-4446-B993-E5CE719234FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E0E1B557-D3CF-4446-B993-E5CE719234FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E0E1B557-D3CF-4446-B993-E5CE719234FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E0E1B557-D3CF-4446-B993-E5CE719234FB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1281,8 +1313,14 @@ Global
{CB7CAE39-F041-4B20-A0C4-D6F44920A647} = {77CFE74A-32EE-400C-8930-5025E8555256}
{9FF853BD-FA56-4DA5-A50A-9867F2FAB1F0} = {77CFE74A-32EE-400C-8930-5025E8555256}
{89E9F2B8-662C-4FFA-8F69-360680362653} = {77CFE74A-32EE-400C-8930-5025E8555256}
{D3CDBA75-7707-4884-908D-1BA22B8DF8E7} = {B80354C7-BE58-43F6-8928-9F3A74AB7F47}
{A4800EE3-F902-4B7B-AF53-01A85514E6B9} = {D173887B-AF42-4576-B9C1-96B9E9B3D9C0}
{F6861204-D0A8-4E7D-9479-FA3E2F4DE93F} = {A4800EE3-F902-4B7B-AF53-01A85514E6B9}
{F43586B8-FE36-490D-9EFA-82CFFB83A304} = {A4800EE3-F902-4B7B-AF53-01A85514E6B9}
{6B6D3953-E961-4720-B27E-9466A69BED1A} = {A4800EE3-F902-4B7B-AF53-01A85514E6B9}
{74644A4D-8F61-4314-B6E8-5CE3802CD6C2} = {4981B3A5-4AFD-4191-BF7D-8692D9783D60}
{427F4D7C-8969-4015-AD1A-5EFFE921A184} = {77CFE74A-32EE-400C-8930-5025E8555256}
{E0E1B557-D3CF-4446-B993-E5CE719234FB} = {27381127-6C45-4B4C-8F18-41FF48DFE4B2}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6DCEDFEC-988E-4CB3-B45B-191EB5086E0C}
Expand Down
5 changes: 3 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- Workaround https://github.com/dependabot/dependabot-core/issues/8490 -->
<!-- This file gets imported for out-of-tree test runs also where eng/Versions.props isn't
available -->
<Import Project="eng/Versions.props" Condition="'$(MajorVersion)' == '' and Exists('eng/Versions.props')"/>
<Import Project="eng/Versions.props" Condition="'$(MajorVersion)' == '' and Exists('eng/Versions.props')" />
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<TestcontainersPackageVersion>3.7.0</TestcontainersPackageVersion>
Expand Down Expand Up @@ -99,6 +99,7 @@
<PackageVersion Include="Polly.Core" Version="8.3.0" />
<PackageVersion Include="Polly.Extensions" Version="8.3.0" />
<PackageVersion Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.1" />
<PackageVersion Include="Qdrant.Client" Version="1.7.0" />
eerhardt marked this conversation as resolved.
Show resolved Hide resolved
<PackageVersion Include="RabbitMQ.Client" Version="6.8.1" />
<PackageVersion Include="StackExchange.Redis" Version="2.7.27" />
<PackageVersion Include="System.IO.Hashing" Version="8.0.0" />
Expand Down Expand Up @@ -144,4 +145,4 @@
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<!-- Introduced by Microsoft.Azure.Cosmos, https://github.com/Azure/azure-cosmos-dotnet-v3/issues/4302 -->
</ItemGroup>
</Project>
</Project>
59 changes: 59 additions & 0 deletions playground/Qdrant/Qdrant.ApiService/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Qdrant.Client;
using Qdrant.Client.Grpc;

var builder = WebApplication.CreateBuilder(args);

// Add service defaults & Aspire components.
builder.AddServiceDefaults();

// Add services to the container.
builder.Services.AddProblemDetails();

builder.AddQdrantClient("qdrant");

var app = builder.Build();

// Configure the HTTP request pipeline.
app.UseExceptionHandler();

//var connectionString = builder.Configuration.GetConnectionString("qdrant") ?? "http://localhost:6334";
//var client = new QdrantClient(new Uri(connectionString), builder.Configuration["Parameters:qdrant-ApiKey"]);
var random = new Random();

app.MapGet("/create", async (QdrantClient client) =>
{
await client.CreateCollectionAsync("my_collection", new VectorParams { Size = 100, Distance = Distance.Cosine });

// generate some vectors
var points = Enumerable.Range(1, 100).Select(i => new PointStruct
{
Id = (ulong)i,
Vectors = Enumerable.Range(1, 100).Select(_ => (float)random.NextDouble()).ToArray(),
Payload =
{
["color"] = "red",
["rand_number"] = i % 10
}
}).ToList();

var updateResult = await client.UpsertAsync("my_collection", points);

return updateResult.Status;
});

app.MapGet("/search", async (QdrantClient client) =>
{
var queryVector = Enumerable.Range(1, 100).Select(_ => (float)random.NextDouble()).ToArray();

// return the 5 closest points
var points = await client.SearchAsync(
"my_collection",
queryVector,
limit: 5);

return points;
});

app.MapDefaultEndpoints();

app.Run();
15 changes: 15 additions & 0 deletions playground/Qdrant/Qdrant.ApiService/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "",
"applicationUrl": "http://localhost:5450",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
15 changes: 15 additions & 0 deletions playground/Qdrant/Qdrant.ApiService/Qdrant.ApiService.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>1e49caab-af46-4c24-8011-953ec12b4069</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Components\Aspire.Qdrant\Aspire.Qdrant.csproj" />
<ProjectReference Include="..\Qdrant.ServiceDefaults\Qdrant.ServiceDefaults.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions playground/Qdrant/Qdrant.ApiService/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
8 changes: 8 additions & 0 deletions playground/Qdrant/Qdrant.AppHost/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

<!-- NOTE: This line is only required because we are using P2P references, not NuGet. It will not exist in real apps. -->
<Import Project="../../../src/Aspire.Hosting.AppHost/build/Aspire.Hosting.AppHost.props" />

</Project>
9 changes: 9 additions & 0 deletions playground/Qdrant/Qdrant.AppHost/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />

<!-- NOTE: These lines are only required because we are using P2P references, not NuGet. They will not exist in real apps. -->
<Import Project="..\..\..\src\Aspire.Hosting.AppHost\build\Aspire.Hosting.AppHost.targets" />
<Import Project="..\..\..\src\Aspire.Hosting.Sdk\SDK\Sdk.targets" />

</Project>
13 changes: 13 additions & 0 deletions playground/Qdrant/Qdrant.AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

var builder = DistributedApplication.CreateBuilder(args);

//var key = builder.AddParameter("QdrantApiKey", true);

var qdrant = builder.AddQdrant("qdrant");

builder.AddProject<Projects.Qdrant_ApiService>("apiservice")
.WithReference(qdrant);

builder.Build().Run();
16 changes: 16 additions & 0 deletions playground/Qdrant/Qdrant.AppHost/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15206",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16022"
}
}
}
}
23 changes: 23 additions & 0 deletions playground/Qdrant/Qdrant.AppHost/Qdrant.AppHost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
<UserSecretsId>10c36641-05e0-4bfb-ad9d-a588431430f0</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<Compile Include="$(SharedDir)KnownResourceNames.cs" Link="KnownResourceNames.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Aspire.Dashboard\Aspire.Dashboard.csproj" />
<ProjectReference Include="..\..\..\src\Aspire.Hosting.AppHost\Aspire.Hosting.AppHost.csproj" IsAspireProjectResource="false" />
<ProjectReference Include="..\..\..\src\Aspire.Hosting.Qdrant\Aspire.Hosting.Qdrant.csproj" IsAspireProjectResource="false" />
<ProjectReference Include="..\Qdrant.ApiService\Qdrant.ApiService.csproj" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions playground/Qdrant/Qdrant.AppHost/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions playground/Qdrant/Qdrant.AppHost/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}
Loading