Skip to content

Commit

Permalink
changing the method .dict() to .model_dump() since it is a deprecated…
Browse files Browse the repository at this point in the history
… method in Pydantic
  • Loading branch information
henriquevedoveli committed Jan 3, 2024
1 parent 63e0cae commit 9589bef
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libs/community/langchain_community/embeddings/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def _get_len_safe_embeddings(
**self._invocation_params,
)
if not isinstance(response, dict):
response = response.dict()
response = response.model_dump()
batched_embeddings.extend(r["embedding"] for r in response["data"])

results: List[List[List[float]]] = [[] for _ in range(len(texts))]
Expand All @@ -512,7 +512,7 @@ def _get_len_safe_embeddings(
**self._invocation_params,
)
if not isinstance(average_embedded, dict):
average_embedded = average_embedded.dict()
average_embedded = average_embedded.model_dump()
average = average_embedded["data"][0]["embedding"]
else:
average = np.average(_result, axis=0, weights=num_tokens_in_batch[i])
Expand Down Expand Up @@ -616,7 +616,7 @@ async def _aget_len_safe_embeddings(
)

if not isinstance(response, dict):
response = response.dict()
response = response.model_dump()
batched_embeddings.extend(r["embedding"] for r in response["data"])

results: List[List[List[float]]] = [[] for _ in range(len(texts))]
Expand Down

0 comments on commit 9589bef

Please sign in to comment.