Implementation:Microsoft Semantic kernel Vertex Embeddings TestData
| Knowledge Sources | |
|---|---|
| Domains | Google_Vertex_AI, Embeddings, Unit_Testing, Test_Data |
| Last Updated | 2026-02-11 00:00 GMT |
Overview
Concrete mock Google Vertex AI embeddings API response JSON file used in unit tests, provided by the Connectors.Google.UnitTests project.
Description
vertex_embeddings_response.json is a test fixture file containing a mock response from the Google Vertex AI embeddings API. At 1560 lines, the file uses the Vertex AI response format, which differs from the standard Google AI format by wrapping embeddings inside a predictions array. Each prediction contains an embeddings object with a statistics sub-object (including truncated boolean and token_count integer) and a values array of floating-point embedding vector components.
The Vertex AI format includes additional metadata not present in the standard Google AI response:
- statistics.truncated -- Boolean indicating whether the input text was truncated to fit the model's maximum token limit
- statistics.token_count -- Integer count of tokens in the input text (e.g., 6)
This file is consumed by the VertexAIClientEmbeddingsGenerationTests test class to validate the Vertex AI connector's response parsing logic.
Usage
This file is loaded at test time by the Vertex AI embeddings unit tests. The test class declares private const string TestDataFilePath = "./TestData/vertex_embeddings_response.json"; and reads it via File.ReadAllText() to populate mock HTTP response content. Developers modify this file when the Vertex AI API response schema changes or when adding new test scenarios for the Vertex AI embeddings connector.
Code Reference
Source Location
- Repository: Microsoft_Semantic_kernel
- File: dotnet/src/Connectors/Connectors.Google.UnitTests/TestData/vertex_embeddings_response.json
- Lines: 1-1560
Signature
{
"predictions": [
{
"embeddings": {
"statistics": {
"truncated": false,
"token_count": 6
},
"values": [
0.008624583,
-0.030451821,
-0.042496547,
-0.029230341,
0.05486475,
0.006694871,
0.004025645,
-0.007294857,
0.0057651913,
0.037203953,
0.08070716,
0.032692064,
0.0015699493,
-0.038671605,
-0.021397846,
0.040436137,
0.040364444,
0.023915485,
0.03318194,
-0.052099578
]
}
}
]
}
Import
// In VertexAIClientEmbeddingsGenerationTests.cs:
private const string TestDataFilePath = "./TestData/vertex_embeddings_response.json";
// Loading the test data:
var responseContent = File.ReadAllText(TestDataFilePath);
this._messageHandlerStub.ResponseToReturn.Content = new StringContent(responseContent);
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| N/A (static file) | JSON file | N/A | This is a static test fixture; it has no runtime inputs |
Outputs
| Name | Type | Description |
|---|---|---|
| predictions | array | Array of prediction objects from the Vertex AI endpoint |
| predictions[].embeddings.statistics.truncated | boolean | Whether the input was truncated before embedding |
| predictions[].embeddings.statistics.token_count | integer | Number of tokens in the input text |
| predictions[].embeddings.values | float[] | Array of floating-point embedding vector components (hundreds of dimensions) |
Usage Examples
Loading in a Vertex AI Unit Test
using System.IO;
using System.Net.Http;
public class VertexAIClientEmbeddingsGenerationTests
{
private const string TestDataFilePath = "./TestData/vertex_embeddings_response.json";
public VertexAIClientEmbeddingsGenerationTests()
{
this._messageHandlerStub.ResponseToReturn.Content =
new StringContent(File.ReadAllText(TestDataFilePath));
this._httpClient = new HttpClient(this._messageHandlerStub, false);
}
[Fact]
public async Task ShouldReturnVertexEmbeddings()
{
// Arrange - mock response loaded in constructor
// Act - invoke the Vertex AI embeddings client
// Assert - verify parsed embeddings and statistics metadata
var testDataResponse = JsonSerializer.Deserialize<VertexAIEmbeddingResponse>(
await File.ReadAllTextAsync(TestDataFilePath))!;
Assert.NotNull(testDataResponse.Predictions);
Assert.False(testDataResponse.Predictions[0].Embeddings.Statistics.Truncated);
Assert.Equal(6, testDataResponse.Predictions[0].Embeddings.Statistics.TokenCount);
}
}
Related Pages
- Environment:Microsoft_Semantic_kernel_DotNet_SDK_Environment
- Microsoft_Semantic_kernel_Google_Embeddings_TestData -- Similar mock data for standard Google AI embeddings (simpler format without statistics)
- Microsoft_Semantic_kernel_MistralAI_Embeddings_TestData -- Mock embeddings data for MistralAI connector tests
- Microsoft_Semantic_kernel_HuggingFace_Embeddings_TestData -- Mock embeddings data for HuggingFace connector tests