소스 검색

fix MiniMax chat bug (#1733)

### What problem does this PR solve?

#1717   fix MiniMax chat bug

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

Co-authored-by: Zhedong Cen <cenzhedong2@126.com>
tags/v0.9.0
黄腾 1 년 전
부모
커밋
29f7f8b81e
No account linked to committer's email address
1개의 변경된 파일7개의 추가작업 그리고 4개의 파일을 삭제
  1. 7
    4
      rag/llm/chat_model.py

+ 7
- 4
rag/llm/chat_model.py 파일 보기

@@ -564,12 +564,15 @@ class MiniMaxChat(Base):
)
for resp in response.text.split("\n\n")[:-1]:
resp = json.loads(resp[6:])
if "delta" in resp["choices"][0]:
text = ""
if "choices" in resp and "delta" in resp["choices"][0]:
text = resp["choices"][0]["delta"]["content"]
else:
continue
ans += text
total_tokens += num_tokens_from_string(text)
total_tokens = (
total_tokens + num_tokens_from_string(text)
if "usage" not in resp
else resp["usage"]["total_tokens"]
)
yield ans

except Exception as e:

Loading…
취소
저장