mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Bug fix for volcengine (#909)
### What problem does this PR solve? Bug fixes for the VolcEngine - Bug fix for front-end configuration code of VolcEngine - Bug fix for tokens counting logic of VolcEngine ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --------- Co-authored-by: 海贼宅 <stu_xyx@163.com>
This commit is contained in:
@ -359,6 +359,7 @@ class VolcEngineChat(Base):
|
||||
if system:
|
||||
history.insert(0, {"role": "system", "content": system})
|
||||
ans = ""
|
||||
tk_count = 0
|
||||
try:
|
||||
req = {
|
||||
"parameters": {
|
||||
@ -376,10 +377,9 @@ class VolcEngineChat(Base):
|
||||
if not resp.choices[0].message.content:
|
||||
continue
|
||||
ans += resp.choices[0].message.content
|
||||
yield ans
|
||||
if resp.choices[0].finish_reason == "stop":
|
||||
yield resp.usage.total_tokens
|
||||
|
||||
tk_count = resp.usage.total_tokens
|
||||
yield ans
|
||||
except Exception as e:
|
||||
yield ans + "\n**ERROR**: " + str(e)
|
||||
yield 0
|
||||
yield tk_count
|
||||
|
||||
Reference in New Issue
Block a user