Переглянути джерело

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>
tags/v0.7.0
yungongzi 1 рік тому
джерело
коміт
c0d71adaa2
Аккаунт користувача з таким Email не знайдено

+ 4
- 4
rag/llm/chat_model.py Переглянути файл

if system: if system:
history.insert(0, {"role": "system", "content": system}) history.insert(0, {"role": "system", "content": system})
ans = "" ans = ""
tk_count = 0
try: try:
req = { req = {
"parameters": { "parameters": {
if not resp.choices[0].message.content: if not resp.choices[0].message.content:
continue continue
ans += resp.choices[0].message.content ans += resp.choices[0].message.content
yield ans
if resp.choices[0].finish_reason == "stop": if resp.choices[0].finish_reason == "stop":
yield resp.usage.total_tokens
tk_count = resp.usage.total_tokens
yield ans
except Exception as e: except Exception as e:
yield ans + "\n**ERROR**: " + str(e) yield ans + "\n**ERROR**: " + str(e)
yield 0
yield tk_count

+ 4
- 2
web/src/pages/user-setting/setting-model/index.tsx Переглянути файл

<Col span={12} className={styles.factoryOperationWrapper}> <Col span={12} className={styles.factoryOperationWrapper}>
<Space size={'middle'}> <Space size={'middle'}>
<Button onClick={handleApiKeyClick}> <Button onClick={handleApiKeyClick}>
{isLocalLlmFactory(item.name) ? t('addTheModel') : 'API-Key'}
{isLocalLlmFactory(item.name) || item.name === 'VolcEngine' ? t('addTheModel') : 'API-Key'}
<SettingOutlined /> <SettingOutlined />
</Button> </Button>
<Button onClick={handleShowMoreClick}> <Button onClick={handleShowMoreClick}>
(llmFactory: string) => { (llmFactory: string) => {
if (isLocalLlmFactory(llmFactory)) { if (isLocalLlmFactory(llmFactory)) {
showLlmAddingModal(llmFactory); showLlmAddingModal(llmFactory);
} else if (llmFactory === 'VolcEngine') {
showVolcAddingModal('VolcEngine');
} else { } else {
showApiKeyModal({ llm_factory: llmFactory }); showApiKeyModal({ llm_factory: llmFactory });
} }
}, },
[showApiKeyModal, showLlmAddingModal],
[showApiKeyModal, showLlmAddingModal, showVolcAddingModal],
); );


const handleAddModel = (llmFactory: string) => () => { const handleAddModel = (llmFactory: string) => () => {

Завантаження…
Відмінити
Зберегти