fix: qwen3 cannot name a topic (#6722)

* fix: qwen3 cannot name a topic

* feat: Display error message when topic naming fails
This commit is contained in:
Wang Jiyuan 2025-06-02 23:18:41 +08:00 committed by GitHub
parent 9cbb5364ba
commit 15f93e53f2
13 changed files with 26 additions and 6 deletions

View File

@ -99,6 +99,8 @@ export const autoRenameTopic = async (assistant: Assistant, topicId: string) =>
const data = { ...topic, name: summaryText }
_setActiveTopic(data)
store.dispatch(updateTopic({ assistantId: assistant.id, topic: data }))
} else {
window.message?.error(i18n.t('message.error.fetchTopicName'))
}
}
} finally {

View File

@ -627,6 +627,7 @@
"error.enter.api.key": "Please enter your API key first",
"error.enter.model": "Please select a model first",
"error.enter.name": "Please enter the name of the knowledge base",
"error.fetchTopicName": "Failed to name the topic",
"error.get_embedding_dimensions": "Failed to get embedding dimensions",
"error.invalid.api.host": "Invalid API Host",
"error.invalid.api.key": "Invalid API Key",
@ -944,7 +945,6 @@
"req_error_text": "Operation failed. Please try again. Avoid using 'copyrighted' or 'sensitive' words in your prompt.",
"auto_create_paint": "Auto-create image",
"auto_create_paint_tip": "After the image is generated, a new image will be created automatically."
},
"prompts": {
"explanation": "Explain this concept to me",

View File

@ -627,6 +627,7 @@
"error.enter.api.key": "APIキーを入力してください",
"error.enter.model": "モデルを選択してください",
"error.enter.name": "ナレッジベース名を入力してください",
"error.fetchTopicName": "トピックの命名に失敗しました",
"error.get_embedding_dimensions": "埋込み次元を取得できませんでした",
"error.invalid.api.host": "無効なAPIアドレスです",
"error.invalid.api.key": "無効なAPIキーです",

View File

@ -627,6 +627,7 @@
"error.enter.api.key": "Пожалуйста, введите ваш API ключ",
"error.enter.model": "Пожалуйста, выберите модель",
"error.enter.name": "Пожалуйста, введите название базы знаний",
"error.fetchTopicName": "Не удалось назвать тему",
"error.get_embedding_dimensions": "Не удалось получить размерность встраивания",
"error.invalid.api.host": "Неверный API адрес",
"error.invalid.api.key": "Неверный API ключ",

View File

@ -627,6 +627,7 @@
"error.enter.api.key": "请输入您的 API 密钥",
"error.enter.model": "请选择一个模型",
"error.enter.name": "请输入知识库名称",
"error.fetchTopicName": "话题命名失败",
"error.get_embedding_dimensions": "获取嵌入维度失败",
"error.invalid.api.host": "无效的 API 地址",
"error.invalid.api.key": "无效的 API 密钥",
@ -941,7 +942,7 @@
"magic_prompt_option_tip": "智能优化放大提示词"
},
"text_desc_required": "请先输入图片描述",
"req_error_text" : "运行失败,请重试。提示词避免“版权词”和”敏感词”哦。",
"req_error_text": "运行失败,请重试。提示词避免“版权词”和”敏感词”哦。",
"auto_create_paint": "自动新建图片",
"auto_create_paint_tip": "在图片生成后,会自动新建图片"
},

View File

@ -627,6 +627,7 @@
"error.enter.api.key": "請先輸入您的 API 金鑰",
"error.enter.model": "請先選擇一個模型",
"error.enter.name": "請先輸入知識庫名稱",
"error.fetchTopicName": "話題命名失敗",
"error.get_embedding_dimensions": "取得嵌入維度失敗",
"error.invalid.api.host": "無效的 API 位址",
"error.invalid.api.key": "無效的 API 金鑰",
@ -941,7 +942,7 @@
},
"rendering_speed": "渲染速度",
"text_desc_required": "請先輸入圖片描述",
"req_error_text" : "运行失败,请重试。提示词避免“版权词”和”敏感词”哦。",
"req_error_text": "运行失败,请重试。提示词避免“版权词”和”敏感词”哦。",
"auto_create_paint": "自動新增圖片",
"auto_create_paint_tip": "圖片生成後,會自動新增圖片"
},

View File

@ -557,6 +557,7 @@
"error.enter.api.key": "Παρακαλώ εισάγετε το κλειδί API σας",
"error.enter.model": "Παρακαλώ επιλέξτε ένα μοντέλο",
"error.enter.name": "Παρακαλώ εισάγετε ένα όνομα για τη βάση γνώσεων",
"error.fetchTopicName": "Αποτυχία ονοματοδοσίας θέματος",
"error.get_embedding_dimensions": "Απέτυχε η πρόσληψη διαστάσεων ενσωμάτωσης",
"error.invalid.api.host": "Μη έγκυρη διεύθυνση API",
"error.invalid.api.key": "Μη έγκυρο κλειδί API",

View File

@ -558,6 +558,7 @@
"error.enter.api.key": "Ingrese su clave API",
"error.enter.model": "Seleccione un modelo",
"error.enter.name": "Ingrese el nombre de la base de conocimiento",
"error.fetchTopicName": "Error al nombrar el tema",
"error.get_embedding_dimensions": "Fallo al obtener las dimensiones de incrustación",
"error.invalid.api.host": "Dirección API inválida",
"error.invalid.api.key": "Clave API inválida",

View File

@ -557,6 +557,7 @@
"error.enter.api.key": "Veuillez entrer votre clé API",
"error.enter.model": "Veuillez sélectionner un modèle",
"error.enter.name": "Veuillez entrer le nom de la base de connaissances",
"error.fetchTopicName": "Échec de la dénomination du sujet",
"error.get_embedding_dimensions": "Impossible d'obtenir les dimensions d'encodage",
"error.invalid.api.host": "Adresse API invalide",
"error.invalid.api.key": "Clé API invalide",

View File

@ -559,6 +559,7 @@
"error.enter.api.key": "Insira sua chave API",
"error.enter.model": "Selecione um modelo",
"error.enter.name": "Insira o nome da base de conhecimento",
"error.fetchTopicName": "Falha ao nomear o tópico",
"error.get_embedding_dimensions": "Falha ao obter dimensões de incorporação",
"error.invalid.api.host": "Endereço API inválido",
"error.invalid.api.key": "Chave API inválida",

View File

@ -175,6 +175,8 @@ const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic
const summaryText = await fetchMessagesSummary({ messages, assistant })
if (summaryText) {
updateTopic({ ...topic, name: summaryText, isNameManuallyEdited: false })
} else {
window.message?.error(t('message.error.fetchTopicName'))
}
}
}

View File

@ -1022,14 +1022,20 @@ export default class OpenAIProvider extends BaseOpenAIProvider {
await this.checkIsCopilot()
// @ts-ignore key is not typed
const response = await this.sdk.chat.completions.create({
const params = {
model: model.id,
messages: [systemMessage, userMessage] as ChatCompletionMessageParam[],
stream: false,
keep_alive: this.keepAliveTime,
max_tokens: 1000
})
}
if (isSupportedThinkingTokenQwenModel(model)) {
params['enable_thinking'] = false
}
// @ts-ignore key is not typed
const response = await this.sdk.chat.completions.create(params as ChatCompletionCreateParamsNonStreaming)
// 针对思考类模型的返回,总结仅截取</think>之后的内容
let content = response.choices[0].message?.content || ''

View File

@ -229,6 +229,8 @@ export async function getMessageTitle(message: Message, length = 30): Promise<st
if (title) {
window.message.success({ content: t('chat.topics.export.title_naming_success'), key: 'message-title-naming' })
return title
} else {
window.message?.error(t('message.error.fetchTopicName'))
}
} catch (e) {
window.message.error({ content: t('chat.topics.export.title_naming_failed'), key: 'message-title-naming' })