Skip to content

Commit

Permalink
Fix google embeddings
Browse files Browse the repository at this point in the history
  • Loading branch information
Daggx committed Feb 12, 2025
1 parent 3654101 commit 1a606d7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 5 additions & 5 deletions edenai_apis/apis/google/google_text_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ def text__embeddings(
self, texts: List[str], model: Optional[str] = None
) -> ResponseType[EmbeddingsDataClass]:
model = model.split("__")[1] if "__" in model else model
response = self.clients["llm_client"].embeddings(texts=texts, model=model)
response = self.clients["llm_client"].embeddings(
texts=texts, provider_model_name=f"vertex_ai/{model}", model=model
)
return response

def text__code_generation(
Expand Down Expand Up @@ -476,10 +478,8 @@ def text__search(
).original_response

# Extracts embeddings from texts & query
texts_embed = [
item["embeddings"]["values"] for item in texts_embed_response["predictions"]
]
query_embed = query_embed_response["predictions"][0]["embeddings"]["values"]
texts_embed = list(texts_embed_response["data"][0]["embedding"])
query_embed = query_embed_response["embeddings"][0]

items = []
# Calculate score for each text index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ def embedding(
self,
input=[],
model: Optional[str] = None,
provider_model_name: Optional[str] = None,
# Optional params
dimensions: Optional[int] = None,
timeout=600, # default to 10 minutes
Expand All @@ -229,6 +230,8 @@ def embedding(
if model is not None:
self.model_name = model
call_params["model"] = f"{self.provider_name}/{model}"
if provider_model_name:
call_params["model"] = provider_model_name
call_params["timeout"] = timeout
if dimensions is not None:
call_params["dimensions"] = dimensions
Expand Down

0 comments on commit 1a606d7

Please sign in to comment.