diff --git a/Directory.Build.props b/Directory.Build.props
index 533050c..e1a7b73 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -9,7 +9,7 @@
https://github.com/qdrant/qdrant-dotnet
https://github.com/qdrant/qdrant-dotnet/releases
qdrant, database, vector, search
- v1.15.0
+ dev
diff --git a/src/Qdrant.Client/Grpc/Vector.cs b/src/Qdrant.Client/Grpc/Vector.cs
index e584f87..da4d3b0 100644
--- a/src/Qdrant.Client/Grpc/Vector.cs
+++ b/src/Qdrant.Client/Grpc/Vector.cs
@@ -10,7 +10,10 @@ public partial class Vector
///
/// the array of floats
/// a new instance of
- public static implicit operator Vector(float[] values) => new() { Data = { values } };
+ public static implicit operator Vector(float[] values) => new()
+ {
+ Dense = new DenseVector { Data = { values } }
+ };
///
/// Implicitly converts a tuple of sparse values array of
@@ -20,8 +23,7 @@ public partial class Vector
/// a new instance of
public static implicit operator Vector((float[], uint[]) sparseValues) => new()
{
- Data = { sparseValues.Item1 },
- Indices = new SparseIndices { Data = { sparseValues.Item2 } }
+ Sparse = new SparseVector { Values = { sparseValues.Item1 }, Indices = { sparseValues.Item2 } }
};
///
@@ -31,8 +33,7 @@ public partial class Vector
/// a new instance of
public static implicit operator Vector((float, uint)[] sparseValues) => new()
{
- Data = { sparseValues.Select(v => v.Item1) },
- Indices = new SparseIndices { Data = { sparseValues.Select(v => v.Item2) } }
+ Sparse = new SparseVector { Values = { sparseValues.Select(v => v.Item1) }, Indices = { sparseValues.Select(v => v.Item2) } }
};
///
@@ -43,13 +44,11 @@ public partial class Vector
/// a new instance of
public static implicit operator Vector(float[][] values)
{
- var vectorsCount = (uint)values.Length;
- var flatVector = values.SelectMany(v => v).ToArray();
+ var denseVectors = values.Select(v => new DenseVector { Data = { v } }).ToArray();
return new Vector
{
- Data = { flatVector },
- VectorsCount = vectorsCount,
+ MultiDense = new MultiDenseVector { Vectors = { denseVectors } },
};
}
diff --git a/src/Qdrant.Client/Grpc/VectorOutput.cs b/src/Qdrant.Client/Grpc/VectorOutput.cs
new file mode 100644
index 0000000..07a09ad
--- /dev/null
+++ b/src/Qdrant.Client/Grpc/VectorOutput.cs
@@ -0,0 +1,89 @@
+namespace Qdrant.Client.Grpc;
+
+///
+/// Partial class for to add helper methods for extracting vector data.
+///
+public partial class VectorOutput
+{
+ ///
+ /// Gets the from this .
+ ///
+ /// A or null if no dense vector data is available
+ public DenseVector? GetDenseVector()
+ {
+ if (Data.Count > 0)
+ {
+ return new DenseVector { Data = { Data } };
+ }
+
+ if (VectorCase == VectorOneofCase.Dense)
+ {
+ return Dense;
+ }
+
+ return null;
+ }
+
+ ///
+ /// Gets the from this .
+ ///
+ /// A or null if no sparse vector data is available
+ public SparseVector? GetSparseVector()
+ {
+ if (Data.Count > 0)
+ {
+ if (Indices == null)
+ {
+ return null;
+ }
+
+ return new SparseVector
+ {
+ Values = { Data },
+ Indices = { Indices.Data }
+ };
+ }
+
+ if (VectorCase == VectorOneofCase.Sparse)
+ {
+ return Sparse;
+ }
+
+ return null;
+ }
+
+ ///
+ /// Gets the from this .
+ ///
+ /// A or null if no multi-dense vector data is available
+ public MultiDenseVector? GetMultiVector()
+ {
+ if (Data.Count > 0)
+ {
+ var vectorsCount = VectorsCount;
+ if (vectorsCount == 0)
+ {
+ return null;
+ }
+
+ var vectorSize = Data.Count / (int)vectorsCount;
+ var vectors = new DenseVector[(int)vectorsCount];
+
+ for (var i = 0; i < vectors.Length; i++)
+ {
+ var start = i * vectorSize;
+ var end = start + vectorSize;
+ vectors[i] = new DenseVector { Data = { Data.Skip(start).Take(vectorSize) } };
+ }
+
+ return new MultiDenseVector { Vectors = { vectors } };
+ }
+
+ if (VectorCase == VectorOneofCase.MultiDense)
+ {
+ return MultiDense;
+ }
+
+ return null;
+ }
+}
diff --git a/src/Qdrant.Client/Grpc/Vectors.cs b/src/Qdrant.Client/Grpc/Vectors.cs
index 3b78982..7068a40 100644
--- a/src/Qdrant.Client/Grpc/Vectors.cs
+++ b/src/Qdrant.Client/Grpc/Vectors.cs
@@ -11,7 +11,7 @@ public partial class Vectors
/// the array of floats
/// a new instance of
public static implicit operator Vectors(float[] values) =>
- new() { Vector = new() { Data = { values } } };
+ new() { Vector = new Vector { Dense = new DenseVector { Data = { values } } } };
///
/// Implicitly converts a nested array of representing a multi-vector
@@ -21,15 +21,16 @@ public static implicit operator Vectors(float[] values) =>
/// a new instance of
public static implicit operator Vectors(float[][] values)
{
- var vectorsCount = (uint)values.Length;
- var flatVector = values.SelectMany(v => v).ToArray();
+ var denseVector = values.Select(v => new DenseVector { Data = { v } }).ToArray();
return new Vectors
{
Vector = new Vector
{
- Data = { flatVector },
- VectorsCount = vectorsCount,
+ MultiDense = new MultiDenseVector
+ {
+ Vectors = { denseVector }
+ },
}
};
}
@@ -86,12 +87,11 @@ public static implicit operator Vectors((string, Vector) value)
Vector = document,
};
-
///
/// Implicitly converts an instance of to a new instance of for cloud inference.
///
/// An instance of to vectorize
- /// /// a new instance of
+ /// a new instance of
public static implicit operator Vectors(Image image) => new()
{
Vector = image,
diff --git a/tests/Qdrant.Client.Tests/ApiKeyCertificateThumbprintTests.cs b/tests/Qdrant.Client.Tests/ApiKeyCertificateThumbprintTests.cs
index 504e687..90449f8 100644
--- a/tests/Qdrant.Client.Tests/ApiKeyCertificateThumbprintTests.cs
+++ b/tests/Qdrant.Client.Tests/ApiKeyCertificateThumbprintTests.cs
@@ -57,9 +57,8 @@ public void ClientConfiguredWithApiKeyAndCertValidationCanConnect()
var client = new QdrantGrpcClient(callInvoker);
- var response = client.Qdrant.HealthCheck(new HealthCheckRequest());
- response.Title.Should().NotBeNullOrEmpty();
- response.Version.Should().NotBeNullOrEmpty();
+ var response = client.Collections.ListAliases(new ListAliasesRequest());
+ response.Aliases.Should().NotBeNull();
}
[Fact]
@@ -83,7 +82,7 @@ public void ClientConfiguredWithoutApiKeyCannotConnect()
var client = new QdrantGrpcClient(callInvoker);
- var exception = Assert.Throws(() => client.Qdrant.HealthCheck(new HealthCheckRequest()));
+ var exception = Assert.Throws(() => client.Collections.ListAliases(new ListAliasesRequest()));
#if NETFRAMEWORK
exception.Status.StatusCode.Should().BeOneOf(StatusCode.Unavailable, StatusCode.Unauthenticated);
#else
@@ -115,7 +114,7 @@ public void ClientConfiguredWithoutCertificateThumbprintCannotConnect()
var client = new QdrantGrpcClient(callInvoker);
- var exception = Assert.Throws(() => client.Qdrant.HealthCheck(new HealthCheckRequest()));
+ var exception = Assert.Throws(() => client.Collections.ListAliases(new ListAliasesRequest()));
exception.Status.StatusCode.Should().Be(StatusCode.Internal);
exception.InnerException.Should().BeOfType();