community: fix dashcope embeddings embed_query func post too much req 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
This commit is contained in:
monysun 2024-07-26 20:44:07 +08:00 committed by GitHub
parent b65ac8d39c
commit 5f593c172a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -48,8 +48,11 @@ def embed_with_retry(embeddings: DashScopeEmbeddings, **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"]