v1.2修复优化
This commit is contained in:
@@ -97,28 +97,37 @@ const ChatManager = {
|
||||
|
||||
// 清除文件
|
||||
UploadManager.clearFiles();
|
||||
// 获取当前配置
|
||||
const provider = document.getElementById('providerSelect')?.value || 'newapi';
|
||||
const model = document.getElementById('modelSelect')?.value || 'gpt-3.5-turbo';
|
||||
const thinkingMode = document.getElementById('thinkingMode')?.checked || false;
|
||||
|
||||
// 获取当前配置
|
||||
const provider = document.getElementById('providerSelect')?.value || 'newapi';
|
||||
const model = document.getElementById('modelSelect')?.value || 'gpt-3.5-turbo';
|
||||
const thinkingMode = document.getElementById('thinkingMode')?.checked || false;
|
||||
// 获取人格提示词
|
||||
let systemPrompt = '';
|
||||
const personalitySelect = document.getElementById('personalitySelect');
|
||||
if (personalitySelect && personalitySelect.value) {
|
||||
const personality = personalitiesData.find(p => p.id == personalitySelect.value);
|
||||
if (personality) {
|
||||
systemPrompt = personality.prompt || '';
|
||||
}
|
||||
}
|
||||
|
||||
// SSE 流式请求
|
||||
this.isStreaming = true;
|
||||
this.updateSendButton();
|
||||
// SSE 流式请求
|
||||
this.isStreaming = true;
|
||||
this.updateSendButton();
|
||||
|
||||
try {
|
||||
await this.streamChat(provider, model, thinkingMode);
|
||||
} catch (err) {
|
||||
this.addErrorMessage(err.message);
|
||||
} finally {
|
||||
this.isStreaming = false;
|
||||
this.updateSendButton();
|
||||
}
|
||||
},
|
||||
try {
|
||||
await this.streamChat(provider, model, thinkingMode, systemPrompt);
|
||||
} catch (err) {
|
||||
this.addErrorMessage(err.message);
|
||||
} finally {
|
||||
this.isStreaming = false;
|
||||
this.updateSendButton();
|
||||
}
|
||||
},
|
||||
|
||||
async streamChat(provider, model, thinkingMode) {
|
||||
const token = Storage.getToken();
|
||||
async streamChat(provider, model, thinkingMode, systemPrompt) {
|
||||
const token = Storage.getToken();
|
||||
|
||||
// 构建消息历史(只取 role 和 content)
|
||||
const messages = this.messages.map(m => ({
|
||||
@@ -138,7 +147,8 @@ const ChatManager = {
|
||||
'Authorization': 'Bearer ' + token
|
||||
},
|
||||
body: JSON.stringify({
|
||||
provider, model, messages, stream: true, thinkingMode
|
||||
provider, model, messages, stream: true, thinkingMode,
|
||||
systemPrompt: systemPrompt || ''
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
@@ -158,8 +158,10 @@ const InstallWizard = {
|
||||
});
|
||||
});
|
||||
|
||||
if (providers.length === 0 || !providers[0].name || !providers[0].apiKey) {
|
||||
alert('请至少配置一个完整的供应商');
|
||||
// 供应商配置可选,跳过不完整的条目
|
||||
const validProviders = providers.filter(p => p.name && p.apiKey);
|
||||
if (validProviders.length === 0 && providers.length > 0) {
|
||||
alert('供应商信息不完整,请填写名称和 API Key,或删除该条目');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -180,7 +182,7 @@ const InstallWizard = {
|
||||
jwtSecret: document.getElementById('jwtSecret').value || undefined,
|
||||
jwtExpiry: parseInt(document.getElementById('jwtExpiry').value) || 86400
|
||||
},
|
||||
providers: providers
|
||||
providers: validProviders.length > 0 ? validProviders : []
|
||||
};
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user