|
|
@@ -507,10 +507,14 @@
|
|
|
|
|
|
// 准备表单数据
|
|
|
const formData = new FormData();
|
|
|
- formData.append('anime_id', document.getElementById('scriptId').value);
|
|
|
- formData.append('model', document.getElementById('model').value);
|
|
|
- formData.append('start_episode_sequence', document.getElementById('startEpisode').value);
|
|
|
- formData.append('total_episode_num', document.getElementById('totalEpisode').value);
|
|
|
+ formData.append('is_multi', 0);
|
|
|
+ formData.append('model', 'deepseek-chat');
|
|
|
+ formData.append('art_style', '日系动漫风格');
|
|
|
+ formData.append('prompt', '1+1=2');
|
|
|
+ // formData.append('anime_id', document.getElementById('scriptId').value);
|
|
|
+ // formData.append('model', document.getElementById('model').value);
|
|
|
+ // formData.append('start_episode_sequence', document.getElementById('startEpisode').value);
|
|
|
+ // formData.append('total_episode_num', document.getElementById('totalEpisode').value);
|
|
|
|
|
|
const content = document.getElementById('content').value;
|
|
|
if (content) {
|
|
|
@@ -537,7 +541,7 @@
|
|
|
|
|
|
try {
|
|
|
// 发起流式请求,传入 signal 用于中断
|
|
|
- const response = await fetch('/api/chat', {
|
|
|
+ const response = await fetch('/api/addChat', {
|
|
|
method: 'POST',
|
|
|
body: formData,
|
|
|
signal: abortController.signal // 关键:添加中断信号
|
|
|
@@ -625,13 +629,19 @@
|
|
|
if (data.type === 'reasoning') {
|
|
|
// 思维链内容
|
|
|
// 注释掉下面两行则不展示思维链内容,仅计数
|
|
|
- reasoningContent.textContent = data.full_reasoning || '';
|
|
|
+ const nextReasoning = typeof data.full_reasoning === 'string'
|
|
|
+ ? data.full_reasoning
|
|
|
+ : reasoningContent.textContent + (data.content || '');
|
|
|
+ reasoningContent.textContent = nextReasoning;
|
|
|
reasoningContent.scrollTop = reasoningContent.scrollHeight;
|
|
|
charCount += (data.content || '').length;
|
|
|
updateCharCount();
|
|
|
} else if (data.type === 'content') {
|
|
|
// 最终回答内容
|
|
|
- contentOutput.textContent = data.full_content || '';
|
|
|
+ const nextContent = typeof data.full_content === 'string'
|
|
|
+ ? data.full_content
|
|
|
+ : contentOutput.textContent + (data.content || '');
|
|
|
+ contentOutput.textContent = nextContent;
|
|
|
contentOutput.scrollTop = contentOutput.scrollHeight;
|
|
|
charCount += (data.content || '').length;
|
|
|
updateCharCount();
|
|
|
@@ -648,6 +658,15 @@
|
|
|
// 处理完成
|
|
|
function handleComplete(data) {
|
|
|
updateStatus('completed', '生成完成');
|
|
|
+ if (typeof data.full_reasoning === 'string') {
|
|
|
+ reasoningContent.textContent = data.full_reasoning;
|
|
|
+ reasoningContent.scrollTop = reasoningContent.scrollHeight;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (typeof data.full_content === 'string') {
|
|
|
+ contentOutput.textContent = data.full_content;
|
|
|
+ contentOutput.scrollTop = contentOutput.scrollHeight;
|
|
|
+ }
|
|
|
|
|
|
// 显示 Token 使用情况
|
|
|
if (data.usage) {
|