Преглед на файлове

fix: tongyi Error: 'NoneType' object is not subscriptable (#7705)

tags/0.7.3
crazywoola преди 1 година
родител
ревизия
da326baa5e
No account linked to committer's email address
променени са 1 файла, в които са добавени 13 реда и са изтрити 3 реда
  1. 13
    3
      api/core/model_runtime/model_providers/tongyi/text_embedding/text_embedding.py

+ 13
- 3
api/core/model_runtime/model_providers/tongyi/text_embedding/text_embedding.py Целия файл

@@ -137,9 +137,19 @@ class TongyiTextEmbeddingModel(_CommonTongyi, TextEmbeddingModel):
input=text,
text_type="document",
)
data = response.output["embeddings"][0]
embeddings.append(data["embedding"])
embedding_used_tokens += response.usage["total_tokens"]
if response.output and "embeddings" in response.output and response.output["embeddings"]:
data = response.output["embeddings"][0]
if "embedding" in data:
embeddings.append(data["embedding"])
else:
raise ValueError("Embedding data is missing in the response.")
else:
raise ValueError("Response output is missing or does not contain embeddings.")
if response.usage and "total_tokens" in response.usage:
embedding_used_tokens += response.usage["total_tokens"]
else:
raise ValueError("Response usage is missing or does not contain total tokens.")

return [list(map(float, e)) for e in embeddings], embedding_used_tokens


Loading…
Отказ
Запис