Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Bug fix for volcengine (#909)

yungongzic0d71adaa2c6
diff --git a/rag/llm/chat_model.py b/rag/llm/chat_model.py
index 9bf4e96afb..705bfb6110 100644
--- a/rag/llm/chat_model.py
+++ b/rag/llm/chat_model.py
@@ -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
diff --git a/web/src/pages/user-setting/setting-model/index.tsx b/web/src/pages/user-setting/setting-model/index.tsx
index 69a770108e..071d9ec2ad 100644
--- a/web/src/pages/user-setting/setting-model/index.tsx
+++ b/web/src/pages/user-setting/setting-model/index.tsx
@@ -102,7 +102,7 @@ const ModelCard = ({ item, clickApiKey }: IModelCardProps) => {
<Col span={12} className={styles.factoryOperationWrapper}>
<Space size={'middle'}>
<Button onClick={handleApiKeyClick}>
- {isLocalLlmFactory(item.name) ? t('addTheModel') : 'API-Key'}
+ {isLocalLlmFactory(item.name) || item.name === 'VolcEngine' ? t('addTheModel') : 'API-Key'}
<SettingOutlined />
</Button>
<Button onClick={handleShowMoreClick}>
@@ -181,11 +181,13 @@ const UserSettingModel = () => {
(llmFactory: string) => {
if (isLocalLlmFactory(llmFactory)) {
showLlmAddingModal(llmFactory);
+ } else if (llmFactory === 'VolcEngine') {
+ showVolcAddingModal('VolcEngine');
} else {
showApiKeyModal({ llm_factory: llmFactory });
}
},
- [showApiKeyModal, showLlmAddingModal],
+ [showApiKeyModal, showLlmAddingModal, showVolcAddingModal],
);
const handleAddModel = (llmFactory: string) => () => {