add raptor (#899)

### What problem does this PR solve?

#882 

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
KevinHuSh
2024-05-23 14:31:16 +08:00
committed by GitHub
parent 3bbdf3b770
commit 6f99bbbb08
8 changed files with 244 additions and 44 deletions

View File

@ -57,8 +57,7 @@ class Base(ABC):
stream=True,
**gen_conf)
for resp in response:
if len(resp.choices) == 0:continue
if not resp.choices[0].delta.content:continue
if not resp.choices or not resp.choices[0].delta.content:continue
ans += resp.choices[0].delta.content
total_tokens += 1
if resp.choices[0].finish_reason == "length":
@ -379,7 +378,7 @@ class VolcEngineChat(Base):
ans += resp.choices[0].message.content
yield ans
if resp.choices[0].finish_reason == "stop":
return resp.usage.total_tokens
yield resp.usage.total_tokens
except Exception as e:
yield ans + "\n**ERROR**: " + str(e)