mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-03 10:26:52 +00:00
Refactor: Improve How To Handle QWenEmbed (#8765)
### What problem does this PR solve? Based on https://github.com/infiniflow/ragflow/issues/8740 1. A better handle for 'NoneType' object is not subscriptable 2. Add some logs to get the internal message ### Type of change - [x] Refactoring
This commit is contained in:
parent
2a11b2c331
commit
8d027813f5
@ -209,12 +209,15 @@ class QWenEmbed(Base):
|
||||
for i in range(0, len(texts), batch_size):
|
||||
retry_max = 5
|
||||
resp = dashscope.TextEmbedding.call(model=self.model_name, input=texts[i : i + batch_size], api_key=self.key, text_type="document")
|
||||
while resp["output"] is None and retry_max > 0:
|
||||
while (resp["output"] is None or resp["output"].get("embeddings") is None) and retry_max > 0:
|
||||
time.sleep(10)
|
||||
resp = dashscope.TextEmbedding.call(model=self.model_name, input=texts[i : i + batch_size], api_key=self.key, text_type="document")
|
||||
retry_max -= 1
|
||||
if retry_max == 0 and resp["output"] is None:
|
||||
log_exception(ValueError("Retry_max reached, calling embedding model failed"))
|
||||
if retry_max == 0 and (resp["output"] is None or resp["output"].get("embeddings") is None):
|
||||
if resp.get("message"):
|
||||
log_exception(ValueError(f"Retry_max reached, calling embedding model failed: {resp['message']}"))
|
||||
else:
|
||||
log_exception(ValueError("Retry_max reached, calling embedding model failed"))
|
||||
raise
|
||||
try:
|
||||
embds = [[] for _ in range(len(resp["output"]["embeddings"]))]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user