Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion MEVD/src/AzureAISearch/AzureAISearch.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<AssemblyName>CommunityToolkit.VectorData.AzureAISearch</AssemblyName>
<RootNamespace>$(AssemblyName)</RootNamespace>
<TargetFrameworks>net10.0;net8.0;netstandard2.0;net462</TargetFrameworks>
Expand Down
10 changes: 10 additions & 0 deletions MEVD/src/AzureAISearch/AzureAISearchCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,11 @@ public override async IAsyncEnumerable<VectorSearchResult<TRecord>> SearchAsync<
Throw.IfLessThan(top, 1);

options ??= s_defaultVectorSearchOptions;
if (options.IncludeVectors && _model.EmbeddingGenerationRequired)
{
throw new NotSupportedException(VectorDataStrings.IncludeVectorsNotSupportedWithEmbeddingGeneration);
}

var vectorProperty = _model.GetVectorPropertyOrSingle(options);
var floatVector = await GetSearchVectorAsync(searchValue, vectorProperty, cancellationToken).ConfigureAwait(false);

Expand Down Expand Up @@ -429,6 +434,11 @@ public async IAsyncEnumerable<VectorSearchResult<TRecord>> HybridSearchAsync<TIn

// Resolve options.
options ??= s_defaultKeywordVectorizedHybridSearchOptions;
if (options.IncludeVectors && _model.EmbeddingGenerationRequired)
{
throw new NotSupportedException(VectorDataStrings.IncludeVectorsNotSupportedWithEmbeddingGeneration);
}

var vectorProperty = _model.GetVectorPropertyOrSingle<TRecord>(new() { VectorProperty = options.VectorProperty });
var floatVector = await GetSearchVectorAsync(searchValue, vectorProperty, cancellationToken).ConfigureAwait(false);

Expand Down
2 changes: 1 addition & 1 deletion MEVD/src/Qdrant/Qdrant.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<AssemblyName>CommunityToolkit.VectorData.Qdrant</AssemblyName>
<RootNamespace>$(AssemblyName)</RootNamespace>
<TargetFrameworks>net10.0;net8.0;netstandard2.0;net462</TargetFrameworks>
Expand Down
5 changes: 5 additions & 0 deletions MEVD/src/Qdrant/QdrantCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,11 @@ public async IAsyncEnumerable<VectorSearchResult<TRecord>> HybridSearchAsync<TIn

// Resolve options.
options ??= s_defaultKeywordVectorizedHybridSearchOptions;
if (options.IncludeVectors && _model.EmbeddingGenerationRequired)
{
throw new NotSupportedException(VectorDataStrings.IncludeVectorsNotSupportedWithEmbeddingGeneration);
}

var vectorProperty = _model.GetVectorPropertyOrSingle<TRecord>(new() { VectorProperty = options.VectorProperty });
var vectorArray = await GetSearchVectorArrayAsync(searchValue, vectorProperty, cancellationToken).ConfigureAwait(false);
var textDataProperty = _model.GetFullTextDataPropertyOrSingle(options.AdditionalProperty);
Expand Down
2 changes: 1 addition & 1 deletion MEVD/src/Weaviate/Weaviate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<!-- THIS PROPERTY GROUP MUST COME FIRST -->
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<AssemblyName>CommunityToolkit.VectorData.Weaviate</AssemblyName>
<RootNamespace>$(AssemblyName)</RootNamespace>
<TargetFrameworks>net10.0;net8.0;netstandard2.0;net462</TargetFrameworks>
Expand Down
5 changes: 5 additions & 0 deletions MEVD/src/Weaviate/WeaviateCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,11 @@ public async IAsyncEnumerable<VectorSearchResult<TRecord>> HybridSearchAsync<TIn
Throw.IfLessThan(top, 1);

options ??= s_defaultKeywordVectorizedHybridSearchOptions;
if (options.IncludeVectors && _model.EmbeddingGenerationRequired)
{
throw new NotSupportedException(VectorDataStrings.IncludeVectorsNotSupportedWithEmbeddingGeneration);
}

var vectorProperty = _model.GetVectorPropertyOrSingle<TRecord>(new() { VectorProperty = options.VectorProperty });
var vector = await GetSearchVectorAsync(searchValue, vectorProperty, cancellationToken).ConfigureAwait(false);
var textDataProperty = _model.GetFullTextDataPropertyOrSingle(options.AdditionalProperty);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

<ItemGroup>
<Compile Include="../Shared/AssertExtensions.cs" Link="%(RecursiveDir)%(Filename)%(Extension)" />
<Compile Include="../Shared/FakeEmbeddingGenerator.cs" Link="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Linq;
using System.Threading.Tasks;
using Azure.Search.Documents.Indexes;
using CommunityToolkit.VectorData.AzureAISearch;
using CommunityToolkit.VectorData.UnitTests;
using Microsoft.Extensions.VectorData;
using Moq;
using Xunit;

namespace AzureAISearch.UnitTests;

public sealed class AzureAISearchHybridSearchEmbeddingGenerationTests
{
[Fact]
public async Task HybridSearchAsync_WithIncludeVectorsAndEmbeddingGeneration_ThrowsNotSupported()
{
using AzureAISearchCollection<string, Record> collection = CreateCollection();

await Assert.ThrowsAsync<NotSupportedException>(async () =>
await collection.HybridSearchAsync("search text", ["keyword"], top: 3, new() { IncludeVectors = true }).ToListAsync());
}

[Fact]
public async Task SearchAsync_WithIncludeVectorsAndEmbeddingGeneration_ThrowsNotSupported()
{
using AzureAISearchCollection<string, Record> collection = CreateCollection();

await Assert.ThrowsAsync<NotSupportedException>(async () =>
await collection.SearchAsync("search text", top: 3, new() { IncludeVectors = true }).ToListAsync());
}

private static AzureAISearchCollection<string, Record> CreateCollection()
=> new(new Mock<SearchIndexClient>().Object, "collection", new() { EmbeddingGenerator = new FakeEmbeddingGenerator() });

public sealed class Record
{
[VectorStoreKey]
public string Id { get; set; } = string.Empty;

[VectorStoreData(IsFullTextIndexed = true)]
public string Text { get; set; } = string.Empty;

[VectorStoreVector(3)]
public string Embedding { get; set; } = string.Empty;
}
}
2 changes: 2 additions & 0 deletions MEVD/test/Qdrant.UnitTests/Qdrant.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
Link="%(RecursiveDir)%(Filename)%(Extension)"/>
<Compile Include="../Shared/HttpMessageHandlerStub.cs"
Link="%(RecursiveDir)%(Filename)%(Extension)"/>
<Compile Include="../Shared/FakeEmbeddingGenerator.cs"
Link="%(RecursiveDir)%(Filename)%(Extension)"/>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Linq;
using System.Threading.Tasks;
using CommunityToolkit.VectorData.UnitTests;
using Microsoft.Extensions.VectorData;
using Moq;
using Xunit;

namespace CommunityToolkit.VectorData.Qdrant.UnitTests;

public sealed class QdrantHybridSearchEmbeddingGenerationTests
{
[Fact]
public async Task HybridSearchAsync_WithIncludeVectorsAndEmbeddingGeneration_ThrowsNotSupported()
{
using QdrantCollection<ulong, Record> collection = CreateCollection();

await Assert.ThrowsAsync<NotSupportedException>(async () =>
await collection.HybridSearchAsync("search text", ["keyword"], top: 3, new() { IncludeVectors = true }).ToListAsync());
}

[Fact]
public async Task SearchAsync_WithIncludeVectorsAndEmbeddingGeneration_ThrowsNotSupported()
{
using QdrantCollection<ulong, Record> collection = CreateCollection();

await Assert.ThrowsAsync<NotSupportedException>(async () =>
await collection.SearchAsync("search text", top: 3, new() { IncludeVectors = true }).ToListAsync());
}

private static QdrantCollection<ulong, Record> CreateCollection()
=> new(() => new Mock<MockableQdrantClient>(MockBehavior.Strict).Object, "collection", new() { EmbeddingGenerator = new FakeEmbeddingGenerator() });

public sealed class Record
{
[VectorStoreKey]
public ulong Id { get; set; }

[VectorStoreData(IsFullTextIndexed = true)]
public string Text { get; set; } = string.Empty;

[VectorStoreVector(3)]
public string Embedding { get; set; } = string.Empty;
}
}
2 changes: 2 additions & 0 deletions MEVD/test/Weaviate.UnitTests/Weaviate.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
<ItemGroup>
<Compile Include="../Shared/HttpMessageHandlerStub.cs"
Link="%(RecursiveDir)%(Filename)%(Extension)"/>
<Compile Include="../Shared/FakeEmbeddingGenerator.cs"
Link="%(RecursiveDir)%(Filename)%(Extension)"/>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using CommunityToolkit.VectorData.UnitTests;
using CommunityToolkit.VectorData.Weaviate;
using Microsoft.Extensions.VectorData;
using Xunit;

namespace Weaviate.UnitTests;

public sealed class WeaviateHybridSearchEmbeddingGenerationTests : IDisposable
{
private readonly HttpMessageHandlerStub _messageHandlerStub = new();
private readonly HttpClient _httpClient;

public WeaviateHybridSearchEmbeddingGenerationTests()
{
this._httpClient = new(this._messageHandlerStub, false) { BaseAddress = new Uri("http://default-endpoint") };
}

public void Dispose()
{
this._httpClient.Dispose();
this._messageHandlerStub.Dispose();
}

[Fact]
public async Task HybridSearchAsync_WithIncludeVectorsAndEmbeddingGeneration_ThrowsNotSupported()
{
using WeaviateCollection<Guid, Record> collection = this.CreateCollection();

await Assert.ThrowsAsync<NotSupportedException>(async () =>
await collection.HybridSearchAsync("search text", ["keyword"], top: 3, new() { IncludeVectors = true }).ToListAsync());
}

[Fact]
public async Task SearchAsync_WithIncludeVectorsAndEmbeddingGeneration_ThrowsNotSupported()
{
using WeaviateCollection<Guid, Record> collection = this.CreateCollection();

await Assert.ThrowsAsync<NotSupportedException>(async () =>
await collection.SearchAsync("search text", top: 3, new() { IncludeVectors = true }).ToListAsync());
}

private WeaviateCollection<Guid, Record> CreateCollection()
=> new(this._httpClient, "Collection", new() { EmbeddingGenerator = new FakeEmbeddingGenerator() });

public sealed class Record
{
[VectorStoreKey]
public Guid Id { get; set; }

[VectorStoreData(IsFullTextIndexed = true)]
public string Text { get; set; } = string.Empty;

[VectorStoreVector(3)]
public string Embedding { get; set; } = string.Empty;
}
}
Loading