mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-14 20:56:13 +08:00
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>
This commit is contained in:
parent
6012f376ca
commit
29f7f8b81e
@ -564,12 +564,15 @@ class MiniMaxChat(Base):
|
|||||||
)
|
)
|
||||||
for resp in response.text.split("\n\n")[:-1]:
|
for resp in response.text.split("\n\n")[:-1]:
|
||||||
resp = json.loads(resp[6:])
|
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"]
|
text = resp["choices"][0]["delta"]["content"]
|
||||||
else:
|
|
||||||
continue
|
|
||||||
ans += text
|
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
|
yield ans
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user