Skip to content

Commit

Permalink
community: fix dashcope embeddings embed_query func post too much req…
Browse files Browse the repository at this point in the history
… to api (#24707)

the fuc of embed_query of dashcope embeddings send a str param, and in
the embed_with_retry func will send error content to api
  • Loading branch information
monysun authored Jul 26, 2024
1 parent b65ac8d commit 5f593c1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libs/community/langchain_community/embeddings/dashscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ def _embed_with_retry(**kwargs: Any) -> Any:
result = []
i = 0
input_data = kwargs["input"]
while i < len(input_data):
kwargs["input"] = input_data[i : i + 25]
input_len = len(input_data) if isinstance(input_data, list) else 1
while i < input_len:
kwargs["input"] = (
input_data[i : i + 25] if isinstance(input_data, list) else input_data
)
resp = embeddings.client.call(**kwargs)
if resp.status_code == 200:
result += resp.output["embeddings"]
Expand Down

0 comments on commit 5f593c1

Please sign in to comment.