Skip to content

Commit

Permalink
RavenDB-23471 Fixed CreateEmbeddingViaSmartComponentsLocalEmbedding a…
Browse files Browse the repository at this point in the history
…nd updated failing test
  • Loading branch information
Lwiel committed Jan 9, 2025
1 parent 109b66c commit 00b008a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private static VectorValue Quantize(ByteStringContext allocator, in VectorEmbedd
private static (IDisposable MemoryScope, Memory<byte> Memory, int UsedBytes) CreateEmbeddingViaSmartComponentsLocalEmbedding(ByteStringContext allocator, in string text, in int dimensions)
{
List ??= new List<string>(1);
List.Insert(0, text);
List.Add(text);

try
{
Expand All @@ -162,7 +162,7 @@ private static (IDisposable MemoryScope, Memory<byte> Memory, int UsedBytes) Cre
}
finally
{
List[0] = null;
List.Clear();
}
}

Expand Down
10 changes: 5 additions & 5 deletions test/SlowTests/Issues/RavenDB-23473.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void CanIndexVectorWhenPreviousElementsAreNullWithoutExplicitVectorFieldC
var errors = Indexes.WaitForIndexingErrors(store, errorsShouldExists: false);
Assert.Null(errors);
}
/*

[RavenFact(RavenTestCategory.Vector | RavenTestCategory.Indexes)]
public async Task CanUpdateNoExplicitlyConfiguredVectorFieldViaSubscriptionWithLoadDocument()
{
Expand All @@ -61,7 +61,6 @@ public async Task CanUpdateNoExplicitlyConfiguredVectorFieldViaSubscriptionWithL
var t = worker.Run(async x =>
{
using var session = x.OpenAsyncSession();
using var allocator = new ByteStringContext(SharedMultipleUseFlag.None);
foreach (var item in x.Items)
{
var q = item.Result;
Expand All @@ -71,8 +70,10 @@ public async Task CanUpdateNoExplicitlyConfiguredVectorFieldViaSubscriptionWithL
var localEmbedding = await session.LoadAsync<Embedding>(embeddingId);
if (localEmbedding == null)
{
var embedding = GenerateEmbeddings.FromText(allocator, new VectorOptions(), q.Body);
vector = embedding.GetEmbedding();
#pragma warning disable SKEXP0070
var embedding = await GenerateEmbeddings.Embedder.Value.GenerateEmbeddingsAsync(new List<string> {q.Body });
#pragma warning restore SKEXP0070
vector = embedding[0].ToArray().ToList();
localEmbedding = new Embedding { Vector = vector };
await session.StoreAsync(localEmbedding, embeddingId);
}
Expand Down Expand Up @@ -120,7 +121,6 @@ public async Task CanUpdateNoExplicitlyConfiguredVectorFieldViaSubscriptionWithL
}
}
}
*/

private class VectorIndex : AbstractIndexCreationTask<Question>
{
Expand Down

0 comments on commit 00b008a

Please sign in to comment.