EmbeddingConfigSpec

org.llm4s.llmconnect.spi.EmbeddingConfigSpec
See theEmbeddingConfigSpec companion object
@Stable
final case class EmbeddingConfigSpec

What an embedding provider needs from its section, and what to use when the section omits it.

The embedding counterpart of ProviderConfigSpec, with one structural difference worth knowing. Chat config is keyed by the user's ''instance'' name (llm4s.providers.my-openai.baseUrl), so a reference.conf fragment cannot express a per-provider default - it does not know the instance name. Embedding config is keyed by the ''provider id'' (llm4s.embeddings.openai), so a module's own reference.conf can and does bind that provider's environment variables.

The division is therefore: defaults live here, environment bindings live in the module's reference.conf. Before this existed the two were duplicated - reference.conf said baseUrl = "http://localhost:11434" and EmbeddingsConfigLoader said DefaultOllamaEmbeddingBaseUrl - and nothing kept them in step.

== The API key == The key is the section's own apiKey when it sets one, and otherwise the vendor's shared key, llm4s.credentials.<id>.apiKey, which the module's reference.conf binds to the vendor's variable (llm4s.credentials.openai.apiKey = ${?OPENAI_API_KEY}). The same shared key serves the vendor's chat sections, so one variable configures both. org.llm4s.config resolves that fallback before calling the descriptor; nothing here reads configuration.

Value parameters

apiKeyEnv

the variables the module's reference.conf binds to llm4s.credentials.<id>.apiKey, highest precedence first, named in the error when the key is missing. A declaration for the message only: the binding itself is the reference.conf line, and each module's round-trip spec proves the two agree. Empty when nothing binds the shared key, and the error then names the shared path instead.

defaultApiKey

stand-in for a provider that takes a key but does not need a real one - Ollama running locally.

defaultBaseUrl

base URL used when the section omits one.

defaultModel

model used when neither EMBEDDING_MODEL nor the section names one.

modelEnv

the variable the module binds to the model, named likewise.

requiresApiKey

the provider cannot work without a key; a missing one is an error.

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def withApiKeyEnv(apiKeyEnv: Seq[String]): EmbeddingConfigSpec
def withDefaultApiKey(defaultApiKey: String): EmbeddingConfigSpec
def withDefaultApiKey(defaultApiKey: Option[String]): EmbeddingConfigSpec
def withDefaultBaseUrl(defaultBaseUrl: String): EmbeddingConfigSpec
def withDefaultBaseUrl(defaultBaseUrl: Option[String]): EmbeddingConfigSpec
def withDefaultModel(defaultModel: String): EmbeddingConfigSpec
def withDefaultModel(defaultModel: Option[String]): EmbeddingConfigSpec
def withModelEnv(modelEnv: String): EmbeddingConfigSpec
def withModelEnv(modelEnv: Option[String]): EmbeddingConfigSpec
def withRequiresApiKey(requiresApiKey: Boolean): EmbeddingConfigSpec

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product