Skip to content

Commit f7db538

Browse files
committed
bug fix
1 parent 2595af6 commit f7db538

File tree

8 files changed

+33
-23
lines changed

8 files changed

+33
-23
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,14 @@
4444
- [x] 添加正确文献引用
4545
- [x] 更多测试案例
4646
- [ ] docker 部署
47-
- [ ] 引入用户的交互(选择模型,@agent重写,等等)
47+
- [ ] human in loop: 引入用户的交互(选择模型,@agent重写,等等)
48+
- [ ] feedback: evaluate the result and modify
4849
- [x] codeinterpreter 接入云端 如 e2b 等供应商..
4950
- [ ] 多语言: R 语言, matlab
50-
- [ ] 绘图 napki,draw.io
51+
- [ ] 绘图 napki,draw.io,plantuml,svg, mermaid.js
5152
- [ ] 添加 benchmark
53+
- [ ] web search tool
54+
- [ ] RAG 知识库
5255

5356
## 视频demo
5457

@@ -70,15 +73,14 @@
7073
7174

7275

73-
1. 配置模型
76+
1. 配置环境变量
7477

7578
复制`/backend/.env.dev.example``/backend/.env.dev`(删除`.example` 后缀)
7679

7780
**配置环境变量**
7881

7982
推荐模型能力较强的、参数量大的模型。
8083

81-
8284
复制`/fronted/.env.example``/fronted/.env`(删除`.example` 后缀)
8385

8486

backend/app/core/llm/llm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import json
2-
from app.utils.common_utils import transform_link
2+
from app.utils.common_utils import transform_link, split_footnotes
33
from app.utils.log_util import logger
44
import time
55
from app.schemas.response import (
@@ -89,6 +89,7 @@ async def send_message(self, response, agent_name, sub_title=None):
8989
agent_msg: CoderMessage = CoderMessage(content=content)
9090
case AgentType.WRITER:
9191
# 处理 Markdown 格式的图片语法
92+
content, _ = split_footnotes(content)
9293
content = transform_link(self.task_id, content)
9394
agent_msg: WriterMessage = WriterMessage(
9495
content=content,

backend/app/core/prompts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ def get_writer_prompt(
118118
skill:熟练掌握{format_output}排版,如图片、**公式**、表格、列表等
119119
output:你需要按照要求的格式排版,只输出正确的{format_output}排版的内容
120120
121-
1. 当你输入图像引用时候,使用![image_name](image_name.png)
121+
1. 当你输入图像引用时候,使用![image_name](image_name.png),图片引用需换行,在段后。
122122
2. 你不需要输出markdown的这个```markdown格式,只需要输出markdown的内容,
123-
3. LaTex: 行内公式(Inline Formula) 和 块级公式(Block Formula)
123+
3. LaTex: 行内公式(Inline Formula)$ 和 块级公式(Block Formula)$$ 包裹
124124
4. 严格按照参考用户输入的格式模板以及**正确的编号顺序**
125125
5. 不需要询问用户
126126
6. 当提到图片时,请使用提供的图片列表中的文件名
127127
7. when you write,check if you need to use tools search_papers to cite. if you need, markdown Footnote e.g.[^1]
128-
8. List all references at the end in markdown footnote format.
128+
8. List all references at the end in markdown footnote format. Dont't use title # ,just list in the end.
129129
9. Include an empty line between each citation for better readability.
130130
10. 对于问题背景和模型介绍,需查询文献调用tools search_papers
131131
"""

backend/app/models/user_output.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import re
33
from app.utils.data_recorder import DataRecorder
44
from app.schemas.A2A import WriterResponse
5+
from app.utils.log_util import logger
56

67

78
class UserOutput:
@@ -41,6 +42,7 @@ def get_model_build_solve(self) -> str:
4142
return model_build_solve
4243

4344
def get_result_to_save(self, ques_count):
45+
logger.info(f"开始处理结果保存,问题数量: {ques_count}")
4446
# 动态顺序获取拼接res value,正确拼接顺序
4547
ques_str = [f"ques{i}" for i in range(1, ques_count + 1)]
4648
seq = [
@@ -54,6 +56,7 @@ def get_result_to_save(self, ques_count):
5456
"sensitivity_analysis",
5557
"judge",
5658
]
59+
logger.debug(f"处理序列: {seq}")
5760

5861
# 收集所有内容和脚注
5962
all_content = []
@@ -62,20 +65,26 @@ def get_result_to_save(self, ques_count):
6265
footnote_mapping = {} # 用于存储原始编号到新编号的映射
6366

6467
# 第一遍:收集所有引用并建立映射
68+
logger.info("开始第一遍处理:收集引用并建立映射")
6569
for key in seq:
6670
if key not in self.res:
71+
logger.debug(f"跳过不存在的键: {key}")
6772
continue
6873

6974
content = self.res[key]["response_content"]
7075
footnotes = self.res[key]["footnotes"]
7176

7277
if footnotes:
78+
logger.debug(f"处理 {key} 的脚注,数量: {len(footnotes)}")
7379
for num, content in footnotes: # 直接解构元组
7480
if num not in footnote_mapping:
7581
footnote_mapping[num] = str(footnote_counter)
7682
footnote_counter += 1
7783

84+
logger.info(f"脚注映射完成,共有 {len(footnote_mapping)} 个脚注")
85+
7886
# 第二遍:更新内容和脚注
87+
logger.info("开始第二遍处理:更新内容和脚注")
7988
for key in seq:
8089
if key not in self.res:
8190
continue
@@ -85,6 +94,7 @@ def get_result_to_save(self, ques_count):
8594

8695
# 更新内容中的引用编号
8796
if footnotes:
97+
logger.debug(f"更新 {key} 的内容和脚注")
8898
# 更新正文中的引用
8999
for old_num, new_num in footnote_mapping.items():
90100
content = content.replace(f"[^{old_num}]", f"[^{new_num}]")
@@ -109,6 +119,7 @@ def get_result_to_save(self, ques_count):
109119
)
110120
final_content += "\n\n" + "\n".join(sorted_footnotes)
111121

122+
logger.info(f"结果处理完成,最终内容长度: {len(final_content)}")
112123
return final_content
113124

114125
def save_result(self, ques_count):

backend/app/utils/common_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,5 @@ def split_footnotes(text: str) -> tuple[str, list[tuple[str, str]]]:
116116

117117
# 匹配脚注定义
118118
footnotes = re.findall(r"\[\^(\d+)\]:\s*(.+?)(?=\n\[\^|\n\n|\Z)", text, re.DOTALL)
119-
119+
logger.info(f"main_text:{main_text} \n footnotes:{footnotes}")
120120
return main_text, footnotes

frontend/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ dist-ssr
2828
.env.development
2929
.env.production
3030
.env.test
31+
32+
33+
test

frontend/src/pages/task/index.vue

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ onBeforeUnmount(() => {
6060
<template>
6161
<div class="fixed inset-0">
6262
<ResizablePanelGroup direction="horizontal" class="h-full rounded-lg border">
63-
<ResizablePanel :default-size="30" class="h-full">
63+
<ResizablePanel :default-size="40" class="h-full">
6464
<ChatArea :messages="taskStore.chatMessages" />
6565
</ResizablePanel>
6666
<ResizableHandle />
67-
<ResizablePanel :default-size="70" class="h-full min-w-0">
67+
<ResizablePanel :default-size="60" class="h-full min-w-0">
6868
<div class="flex h-full flex-col min-w-0">
6969
<Tabs default-value="coder" class="w-full h-full flex flex-col">
7070
<div class="border-b px-4 py-1 flex justify-between">
@@ -124,12 +124,4 @@ onBeforeUnmount(() => {
124124
</div>
125125
</template>
126126

127-
<style scoped>
128-
:deep(body),
129-
:deep(html) {
130-
overflow: hidden;
131-
height: 100%;
132-
margin: 0;
133-
padding: 0;
134-
}
135-
</style>
127+
<style scoped></style>

frontend/src/stores/task.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import { defineStore } from 'pinia'
22
import { ref, computed } from 'vue'
33
import { TaskWebSocket } from '@/utils/websocket'
44
import type { Message, CoderMessage, WriterMessage } from '@/utils/response'
5-
// import messageData from '@/test/20250430-232525-876ee531.json'
5+
// import messageData from '@/test/20250524-115938-d4c84576.json'
6+
import messageData from '@/test/20250524-133152-0f9d6be8.json'
67

78
export const useTaskStore = defineStore('task', () => {
89
// 初始化时直接加载测试数据,确保页面首次渲染时有数据
9-
// const messages = ref<Message[]>(messageData as Message[])
10-
const messages = ref<Message[]>([])
10+
const messages = ref<Message[]>(messageData as Message[])
11+
// const messages = ref<Message[]>([])
1112
let ws: TaskWebSocket | null = null
1213

1314
// 连接 WebSocket

0 commit comments

Comments
 (0)