Skip to content

Commit

Permalink
renamed embed_query to get_embedding
Browse files Browse the repository at this point in the history
  • Loading branch information
henri123lemoine committed Aug 22, 2023
1 parent a749248 commit ddb5f8e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions align_data/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def compute_openai_embeddings(non_flagged_texts, engine, **kwargs):
data = openai.Embedding.create(input=non_flagged_texts, engine=engine, **kwargs).data
return [d["embedding"] for d in data]

from openai.embeddings_utils import get_embeddings
def get_embeddings(
texts: List[str],
embed_all: bool = False,
Expand Down Expand Up @@ -126,8 +125,8 @@ def get_embeddings(
return final_embeddings


def embed_query(query: str, engine=OPENAI_EMBEDDINGS_MODEL, **kwargs) -> List[float]:
return get_embeddings([query], engine=engine, **kwargs)[0]
def get_embedding(text: str, **kwargs) -> List[float]:
return get_embeddings(texts=[text], **kwargs)[0]


def get_recursive_type(obj):
Expand Down
4 changes: 2 additions & 2 deletions align_data/pinecone/pinecone_db_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pinecone

from align_data.common.utils import get_embeddings, embed_query
from align_data.common.utils import get_embedding
from align_data.pinecone.pinecone_models import PineconeEntry, PineconeMatch, PineconeMetadata
from align_data.settings import (
PINECONE_INDEX_NAME,
Expand Down Expand Up @@ -82,7 +82,7 @@ def query_text(
include_values: bool = False, include_metadata: bool = True, **kwargs
) -> List[PineconeMatch]:

query_vector = embed_query(query)
query_vector = get_embedding(query)
return self.query_vector(
query=query_vector, top_k=top_k,
include_values=include_values, include_metadata=include_metadata, **kwargs
Expand Down
2 changes: 1 addition & 1 deletion align_data/pinecone/pinecone_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PineconeEntry(BaseModel):
source: str
title: str
url: str
date_published: int
date_published: float
authors: List[str]
text_chunks: List[str]
embeddings: List[List[float]]
Expand Down

0 comments on commit ddb5f8e

Please sign in to comment.