Implementation:Microsoft Semantic kernel MistralAI Embeddings TestData
| Knowledge Sources | |
|---|---|
| Domains | MistralAI, Embeddings, Unit_Testing, Test_Data |
| Last Updated | 2026-02-11 00:00 GMT |
Overview
Concrete mock MistralAI embeddings API response JSON file used in unit tests, provided by the Connectors.MistralAI.UnitTests project.
Description
embeddings_response.json is a test fixture file containing a mock response from the MistralAI embeddings API. At 2072 lines, this is the largest of the connector test data embedding files. The JSON structure follows the OpenAI-compatible embeddings API format that MistralAI uses:
- id -- A unique request identifier string (e.g., "994dfff08057489aa745f50f9ce07f22")
- object -- The response type, set to "list"
- data -- An array of embedding objects, each containing:
- object -- Set to "embedding" indicating the item type
- embedding -- An array of floating-point numbers representing the embedding vector
The embedding values are typical float32 numbers (e.g., -0.0249176025390625, 0.042816162109375) representing dense vector representations from MistralAI's embedding models. The OpenAI-compatible format used by MistralAI distinguishes this from Google's format (which uses embeddings[].values) and HuggingFace's format (which uses bare nested arrays).
This file is consumed by multiple test classes: MistralClientTests, MistralAIEmbeddingGeneratorTests, and MistralAITextEmbeddingGenerationServiceTests.
Usage
This file is loaded at test time through the MistralTestBase.GetTestResponseAsString() method, which reads from the ./TestData/ directory using File.ReadAllText(). It is also loaded directly in MistralClientTests via a helper that constructs a mock HTTP handler. Developers working on the MistralAI connector would use this file when writing embedding-related unit tests or when the MistralAI API response format changes.
Code Reference
Source Location
- Repository: Microsoft_Semantic_kernel
- File: dotnet/src/Connectors/Connectors.MistralAI.UnitTests/TestData/embeddings_response.json
- Lines: 1-2072
Signature
{
"id": "994dfff08057489aa745f50f9ce07f22",
"object": "list",
"data": [
{
"object": "embedding",
"embedding": [
-0.0249176025390625,
-0.00296783447265625,
0.042816162109375,
0.0162811279296875,
0.0435791015625,
0.03594970703125,
0.048065185546875,
0.01406097412109375,
-0.039581298828125,
-0.01355743408203125,
-0.054718017578125,
0.03143310546875,
-0.0259857177734375,
-0.021820068359375,
-0.0282745361328125,
0.0032672882080078125,
-0.007137298583984375,
0.04217529296875,
0.029449462890625,
0.035858154296875
]
}
]
}
Import
// Via the MistralTestBase base class:
using SemanticKernel.Connectors.MistralAI.UnitTests;
public class MistralAIEmbeddingGeneratorTests : MistralTestBase
{
[Fact]
public async Task ShouldReturnEmbeddings()
{
// Load the test response
var content = this.GetTestResponseAsString("embeddings_response.json");
// ...
}
}
// MistralTestBase implementation:
protected string GetTestResponseAsString(string fileName)
{
return File.ReadAllText($"./TestData/{fileName}");
}
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 |
|---|---|---|
| id | string | Unique request identifier for the embeddings API call |
| object | string | Response type identifier, always "list" for embedding responses |
| data | array | Array of embedding result objects |
| data[].object | string | Item type identifier, always "embedding" |
| data[].embedding | float[] | Array of floating-point embedding vector components (hundreds of dimensions) |
Usage Examples
Loading in MistralAI Embedding Tests
using System.Net.Http;
using Xunit;
public class MistralAITextEmbeddingGenerationServiceTests : MistralTestBase
{
[Fact]
public async Task ItReturnsEmbeddingsCorrectly()
{
// Arrange
var content = this.GetTestResponseAsString("embeddings_response.json");
this.DelegatingHandler = new AssertingDelegatingHandler(
"https://api.mistral.ai/v1/embeddings", content);
this.HttpClient = new HttpClient(this.DelegatingHandler);
var service = new MistralAITextEmbeddingGenerationService(
"mistral-embed", "key", httpClient: this.HttpClient);
// Act
var embeddings = await service
.GenerateEmbeddingsAsync(new List<string> { "test input" });
// Assert
Assert.NotNull(embeddings);
Assert.Single(embeddings);
}
}
Using in MistralClient Integration Tests
// In MistralClientTests.cs:
var client = this.CreateMistralClient(
"mistral-tiny",
"https://api.mistral.ai/v1/embeddings",
"embeddings_response.json"
);
Related Pages
- Environment:Microsoft_Semantic_kernel_DotNet_SDK_Environment
- Microsoft_Semantic_kernel_Google_Embeddings_TestData -- Mock Google AI embeddings data (Google-specific JSON schema)
- Microsoft_Semantic_kernel_Vertex_Embeddings_TestData -- Mock Vertex AI embeddings data (includes statistics metadata)
- Microsoft_Semantic_kernel_HuggingFace_Embeddings_TestData -- Mock HuggingFace embeddings data (bare nested array format)
- Microsoft_Semantic_kernel_HuggingFace_TextGeneration_TestData -- Mock HuggingFace text generation data (different task type)