EmbeddingProvider
Text embedding provider interface for generating vector representations.
Provides a unified interface for different embedding services (OpenAI, VoyageAI, Ollama). Each implementation handles provider-specific API calls and response formats.
Text content is the primary input; multimedia content (images, audio) should be processed through the FileEmbedder façade in llm4s-rag, which handles content extraction before embedding.
== Query or document ==
request.purpose says whether the texts are documents to index (org.llm4s.llmconnect.model.InputPurpose.Document, the default) or queries to run against them (org.llm4s.llmconnect.model.InputPurpose.Query). A provider whose API embeds the two differently maps it onto the vendor's own parameter (Voyage and Cohere input_type, Jina task); a provider whose models embed both alike ignores it.
== Usage Example ==
val provider: EmbeddingProvider = OpenAIEmbeddingProvider.fromConfig(config)
val request = EmbeddingRequest(
input = Seq("Hello world", "How are you?"),
model = EmbeddingModelConfig("text-embedding-3-small", dimensions = 1536)
)
val result: Result[EmbeddingResponse] = provider.embed(request)
Attributes
- See also
-
OpenAIEmbeddingProviderfor OpenAI text-embedding models (llm4s-openai)VoyageAIEmbeddingProviderfor VoyageAI embedding models (llm4s-voyage)OllamaEmbeddingProviderfor local Ollama embedding models (llm4s-ollama) - Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any