SpringAiEmbeddingService

data class SpringAiEmbeddingService(val name: String, val provider: String, val model: <Error class: unknown class>, val configuredDimensions: Int? = null, val pricingModel: PricingModel? = null) : EmbeddingService, AiModel<<Error class: unknown class>>

Wraps a Spring AI EmbeddingModel exposing an embedding service.

Parameters

configuredDimensions

If provided, uses this value for dimensions instead of making a live API call via EmbeddingModel.dimensions. This avoids startup failures when the embedding endpoint is not available (e.g., Azure OpenAI deployments that only expose chat completions).

Constructors

Link copied to clipboard
constructor(name: String, provider: String, model: <Error class: unknown class>, configuredDimensions: Int? = null, pricingModel: PricingModel? = null)

Properties

Link copied to clipboard

Whether this service is standing in for a model the deployment does not have a key for yet, so nothing may be embedded and — above all — no dimension may be read from it.

Link copied to clipboard
Link copied to clipboard
open override val dimensions: Int

Dimension of the embedding vectors produced by this model

Link copied to clipboard
open override val model: <Error class: unknown class>
Link copied to clipboard
open override val name: String

Name of the LLM, such as "gpt-3.5-turbo"

Link copied to clipboard
open override val pricingModel: PricingModel? = null

The pricing model for the embedding service, if known. Null for local models (Ollama, ONNX) where the cost is zero.

Link copied to clipboard
open override val provider: String

Name of the provider, such as "OpenAI"

Link copied to clipboard
open override val type: ModelType

Functions

Link copied to clipboard
open override fun embed(text: String): FloatArray

Embed a single text in vector space

open override fun embed(texts: List<String>): List<FloatArray>

Embed multiple texts in vector space Use this method for better performance when embedding multiple texts

Link copied to clipboard
open override fun infoString(verbose: Boolean?, indent: Int): String