Skip to content

Commit

Permalink
Update to use env var
Browse files Browse the repository at this point in the history
  • Loading branch information
estohlmann committed Nov 22, 2024
1 parent 1cb1b28 commit c3f4047
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lambda/repository/lambda_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ def __init__(self) -> None:
logger.error("Failed to initialize pipeline embeddings", exc_info=True)
raise

def embed_documents(self, texts: List[str], model_name: str) -> List[List[float]]:
def embed_documents(self, texts: List[str]) -> List[List[float]]:
if not texts:
raise ValidationError("No texts provided for embedding")

logger.info(f"Embedding {len(texts)} documents")
try:
url = f"{self.base_url}/embeddings"
request_data = {"input": texts, "model": model_name}
request_data = {"input": texts, "model": os.environ["EMBEDDING_MODEL"]}

response = requests.post(
url,
Expand Down Expand Up @@ -154,12 +154,12 @@ def embed_documents(self, texts: List[str], model_name: str) -> List[List[float]
logger.error(f"Failed to get embeddings: {str(e)}", exc_info=True)
raise

def embed_query(self, text: str, model_name: str) -> List[float]:
def embed_query(self, text: str) -> List[float]:
if not text or not isinstance(text, str):
raise ValidationError("Invalid query text")

logger.info("Embedding single query text")
return self.embed_documents([text], model_name)[0]
return self.embed_documents([text])[0]


def _get_embeddings_pipeline(model_name: str) -> Any:
Expand Down

0 comments on commit c3f4047

Please sign in to comment.