embedding.py
· 663 B · Python
Raw
# Embedding setup
embedding_provider = config.get("embedding_provider", "default")
if embedding_provider == "huggingface":
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
embedding_name = config.get("embedding_name")
if not embedding_name:
raise ValueError(
"Embedding name must be specified for Hugging Face embeddings."
)
EMBED_MODEL = HuggingFaceEmbedding(model_name=embedding_name)
Settings.embed_model = EMBED_MODEL
elif embedding_provider == "default":
# Use default embedding (e.g., OpenAI)
pass
else:
raise ValueError(f"Unsupported embedding_provider: {embedding_provider}")
1 | # Embedding setup |
2 | embedding_provider = config.get("embedding_provider", "default") |
3 | if embedding_provider == "huggingface": |
4 | from llama_index.embeddings.huggingface import HuggingFaceEmbedding |
5 | |
6 | embedding_name = config.get("embedding_name") |
7 | if not embedding_name: |
8 | raise ValueError( |
9 | "Embedding name must be specified for Hugging Face embeddings." |
10 | ) |
11 | EMBED_MODEL = HuggingFaceEmbedding(model_name=embedding_name) |
12 | Settings.embed_model = EMBED_MODEL |
13 | elif embedding_provider == "default": |
14 | # Use default embedding (e.g., OpenAI) |
15 | pass |
16 | else: |
17 | raise ValueError(f"Unsupported embedding_provider: {embedding_provider}") |