Summary#
app.Embedding declares the embedding model your application uses to turn text into vectors, so that semantic search
over [Searchable] fields (queried through Memory.Search) has something to embed against. You name a provider, a
model, the secret that authenticates to that provider, and the dimensions of the vectors it returns. It is a
singleton — one embedding configuration per app.
app.Embedding = new EmbeddingConfig {
Provider = EmbeddingProvider.OpenAI,
Model = "text-embedding-3-small",
ApiKey = Secret.OpenAI,
Dimensions = 1536,
};Signature#
app.Secrets = [ new Secret("OpenAI") ]; // the handle the config below reads
app.Embedding = new EmbeddingConfig {
Provider = EmbeddingProvider.OpenAI, // which embedding provider
Model = "text-embedding-3-small", // the provider's embedding model id
ApiKey = Secret.OpenAI, // a Secret.X handle from app.Secrets
Dimensions = 1536, // the width of the produced vectors
};app.Embedding is a single value, not a list — an app configures exactly one embedding model.
Description#
An EmbeddingConfig has four members:
Provider— anEmbeddingProviderenum member naming which service produces the vectors. The example usesEmbeddingProvider.OpenAI.Model— the provider's embedding model id, as a string (for example"text-embedding-3-small"). This chooses which model the provider runs.ApiKey— aSecret.Xhandle referencing a secret declared inapp.Secrets. It authenticates calls to the provider; the value itself lives outside your source.Dimensions— the width of each produced vector (for example1536). This must match the vector size the chosen model emits, so that stored[Searchable]vectors and query vectors are comparable.
app.Embedding is a singleton: an application declares one embedding configuration, and every [Searchable] field
and every Memory.Search query uses it.
Examples#
Declare the secret, then configure OpenAI embeddings against it:
app.Secrets = [ new Secret("OpenAI") ];
app.Embedding = new EmbeddingConfig {
Provider = EmbeddingProvider.OpenAI,
Model = "text-embedding-3-small",
ApiKey = Secret.OpenAI,
Dimensions = 1536,
};See also#
- declaring secrets (app.Secrets) —
app.Secrets, where theApiKeyhandle referenced byEmbeddingis declared - [Searchable] — marking a field
[Searchable]so its text is embedded for search - using Memory (semantic search) —
Memory.Search, the query that runs against the embedded vectors