Skip to content

Commit

Permalink
Use OpenAI for embeddings when openai mode is selected (#1096)
Browse files Browse the repository at this point in the history
  • Loading branch information
imartinez authored Oct 23, 2023
1 parent 769a047 commit 7854652
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions private_gpt/components/embedding/embedding_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ class EmbeddingComponent:
@inject
def __init__(self) -> None:
match settings.llm.mode:
case "mock":
# Not a random number, is the dimensionality used by
# the default embedding model
self.embedding_model = MockEmbedding(384)
case _:
case "local":
from llama_index.embeddings import HuggingFaceEmbedding

self.embedding_model = HuggingFaceEmbedding(
model_name=settings.local.embedding_hf_model_name,
cache_folder=str(models_cache_path),
)
case "openai":
from llama_index import OpenAIEmbedding

openai_settings = settings.openai.api_key
self.embedding_model = OpenAIEmbedding(api_key=openai_settings)
case "mock":
# Not a random number, is the dimensionality used by
# the default embedding model
self.embedding_model = MockEmbedding(384)

0 comments on commit 7854652

Please sign in to comment.