Skip to content

Commit baddf4d

Browse files
authored
Address PR feedback: remove null check, avoid var, use explicit content checks
1 parent 42a1c28 commit baddf4d

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/Libraries/Microsoft.Extensions.DataIngestion/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The vector store must be configured with an embedding generator that accepts `AI
3939
IEmbeddingGenerator<AIContent, Embedding<float>> aiContentEmbeddingGenerator =
4040
stringEmbeddingGenerator.AsAIContentEmbeddingGenerator();
4141

42-
using var vectorStore = new InMemoryVectorStore(new()
42+
using VectorStore vectorStore = new InMemoryVectorStore(new()
4343
{
4444
EmbeddingGenerator = aiContentEmbeddingGenerator
4545
});

src/Libraries/Microsoft.Extensions.DataIngestion/Writers/EmbeddingGeneratorExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public Task<GeneratedEmbeddings<TEmbedding>> GenerateAsync(
5454
{
5555
if (content is TextContent tc)
5656
{
57-
return tc.Text ?? string.Empty;
57+
return tc.Text;
5858
}
5959

6060
throw new NotSupportedException(

test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Chunkers/SemanticSimilarityChunkerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public async Task TwoTopicsParagraphs()
7777
}
7878
});
7979

80-
using var customGenerator = new Microsoft.Extensions.AI.TestEmbeddingGenerator<AIContent, Embedding<float>>
80+
using Microsoft.Extensions.AI.TestEmbeddingGenerator<AIContent, Embedding<float>> customGenerator = new()
8181
{
8282
GenerateAsyncCallback = async (values, options, ct) =>
8383
{
@@ -154,7 +154,7 @@ public async Task TwoSeparateTopicsWithAllKindsOfElements()
154154
}
155155
});
156156

157-
using var customGenerator = new Microsoft.Extensions.AI.TestEmbeddingGenerator<AIContent, Embedding<float>>
157+
using Microsoft.Extensions.AI.TestEmbeddingGenerator<AIContent, Embedding<float>> customGenerator = new()
158158
{
159159
GenerateAsyncCallback = async (values, options, ct) =>
160160
{

test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Writers/VectorStoreWriterTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public async Task CanWriteChunksWithCustomDefinition()
6262
Assert.NotEqual(Guid.Empty, record.Key);
6363
Assert.Equal(documentId, record.DocumentId);
6464
Assert.NotEmpty(record.SerializedContent);
65-
Assert.Equal("custom schema content", ((TextContent)record.Content!).Text);
65+
Assert.Equal(((TextContent)chunks[0].Content).Text, ((TextContent)record.Content!).Text);
6666
}
6767

6868
[Fact]
@@ -94,7 +94,7 @@ public async Task CanWriteChunks()
9494
Assert.NotEqual(Guid.Empty, record.Key);
9595
Assert.Equal(documentId, record.DocumentId);
9696
Assert.NotEmpty(record.SerializedContent);
97-
Assert.Equal("some content", ((TextContent)record.Content!).Text);
97+
Assert.Equal(((TextContent)chunks[0].Content).Text, ((TextContent)record.Content!).Text);
9898
Assert.True(testEmbeddingGenerator.WasCalled);
9999
}
100100

@@ -125,7 +125,7 @@ public async Task CanWriteChunksWithMetadata()
125125
Assert.NotNull(record);
126126
Assert.Equal(documentId, record.DocumentId);
127127
Assert.NotEmpty(record.SerializedContent);
128-
Assert.Equal("some content", ((TextContent)record.Content!).Text);
128+
Assert.Equal(((TextContent)chunks[0].Content).Text, ((TextContent)record.Content!).Text);
129129
Assert.Equal("important", record.Classification);
130130
}
131131

0 commit comments

Comments
 (0)