mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-20 05:18:16 +00:00
Fix #2451: Add support for OpenRouter as an embedding provider
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -19,6 +19,7 @@ class EmbeddingConfigurator:
|
||||
"huggingface": self._configure_huggingface,
|
||||
"watson": self._configure_watson,
|
||||
"custom": self._configure_custom,
|
||||
"openrouter": self._configure_openrouter,
|
||||
}
|
||||
|
||||
def configure_embedder(
|
||||
@@ -210,6 +211,18 @@ class EmbeddingConfigurator:
|
||||
|
||||
return WatsonEmbeddingFunction()
|
||||
|
||||
@staticmethod
|
||||
def _configure_openrouter(config, model_name):
|
||||
from chromadb.utils.embedding_functions.openai_embedding_function import (
|
||||
OpenAIEmbeddingFunction,
|
||||
)
|
||||
|
||||
return OpenAIEmbeddingFunction(
|
||||
api_key=config.get("api_key") or os.getenv("OPENROUTER_API_KEY"),
|
||||
api_base=config.get("api_base", "https://openrouter.ai/api/v1"),
|
||||
model_name=model_name,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _configure_custom(config):
|
||||
custom_embedder = config.get("embedder")
|
||||
|
||||
Reference in New Issue
Block a user