Commit
·
6db9c7b
1
Parent(s):
8db17fa
Bug fix for volcengine (#909)
Browse files### 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: 海贼宅 <[email protected]>
rag/llm/chat_model.py
CHANGED
|
@@ -359,6 +359,7 @@ class VolcEngineChat(Base):
|
|
| 359 |
if system:
|
| 360 |
history.insert(0, {"role": "system", "content": system})
|
| 361 |
ans = ""
|
|
|
|
| 362 |
try:
|
| 363 |
req = {
|
| 364 |
"parameters": {
|
|
@@ -376,10 +377,9 @@ class VolcEngineChat(Base):
|
|
| 376 |
if not resp.choices[0].message.content:
|
| 377 |
continue
|
| 378 |
ans += resp.choices[0].message.content
|
| 379 |
-
yield ans
|
| 380 |
if resp.choices[0].finish_reason == "stop":
|
| 381 |
-
|
| 382 |
-
|
| 383 |
except Exception as e:
|
| 384 |
yield ans + "\n**ERROR**: " + str(e)
|
| 385 |
-
yield
|
|
|
|
| 359 |
if system:
|
| 360 |
history.insert(0, {"role": "system", "content": system})
|
| 361 |
ans = ""
|
| 362 |
+
tk_count = 0
|
| 363 |
try:
|
| 364 |
req = {
|
| 365 |
"parameters": {
|
|
|
|
| 377 |
if not resp.choices[0].message.content:
|
| 378 |
continue
|
| 379 |
ans += resp.choices[0].message.content
|
|
|
|
| 380 |
if resp.choices[0].finish_reason == "stop":
|
| 381 |
+
tk_count = resp.usage.total_tokens
|
| 382 |
+
yield ans
|
| 383 |
except Exception as e:
|
| 384 |
yield ans + "\n**ERROR**: " + str(e)
|
| 385 |
+
yield tk_count
|
web/src/pages/user-setting/setting-model/index.tsx
CHANGED
|
@@ -102,7 +102,7 @@ const ModelCard = ({ item, clickApiKey }: IModelCardProps) => {
|
|
| 102 |
<Col span={12} className={styles.factoryOperationWrapper}>
|
| 103 |
<Space size={'middle'}>
|
| 104 |
<Button onClick={handleApiKeyClick}>
|
| 105 |
-
{isLocalLlmFactory(item.name) ? t('addTheModel') : 'API-Key'}
|
| 106 |
<SettingOutlined />
|
| 107 |
</Button>
|
| 108 |
<Button onClick={handleShowMoreClick}>
|
|
@@ -181,11 +181,13 @@ const UserSettingModel = () => {
|
|
| 181 |
(llmFactory: string) => {
|
| 182 |
if (isLocalLlmFactory(llmFactory)) {
|
| 183 |
showLlmAddingModal(llmFactory);
|
|
|
|
|
|
|
| 184 |
} else {
|
| 185 |
showApiKeyModal({ llm_factory: llmFactory });
|
| 186 |
}
|
| 187 |
},
|
| 188 |
-
[showApiKeyModal, showLlmAddingModal],
|
| 189 |
);
|
| 190 |
|
| 191 |
const handleAddModel = (llmFactory: string) => () => {
|
|
|
|
| 102 |
<Col span={12} className={styles.factoryOperationWrapper}>
|
| 103 |
<Space size={'middle'}>
|
| 104 |
<Button onClick={handleApiKeyClick}>
|
| 105 |
+
{isLocalLlmFactory(item.name) || item.name === 'VolcEngine' ? t('addTheModel') : 'API-Key'}
|
| 106 |
<SettingOutlined />
|
| 107 |
</Button>
|
| 108 |
<Button onClick={handleShowMoreClick}>
|
|
|
|
| 181 |
(llmFactory: string) => {
|
| 182 |
if (isLocalLlmFactory(llmFactory)) {
|
| 183 |
showLlmAddingModal(llmFactory);
|
| 184 |
+
} else if (llmFactory === 'VolcEngine') {
|
| 185 |
+
showVolcAddingModal('VolcEngine');
|
| 186 |
} else {
|
| 187 |
showApiKeyModal({ llm_factory: llmFactory });
|
| 188 |
}
|
| 189 |
},
|
| 190 |
+
[showApiKeyModal, showLlmAddingModal, showVolcAddingModal],
|
| 191 |
);
|
| 192 |
|
| 193 |
const handleAddModel = (llmFactory: string) => () => {
|