Skip to content

Commit 6b3e755

Browse files
committed
add
1 parent e0c81f3 commit 6b3e755

File tree

8 files changed

+36
-46
lines changed

8 files changed

+36
-46
lines changed

backend/app/core/prompts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ def get_writer_prompt(
7777
7878
1. 当你输入图像引用时候,使用![image_name](image_name.png)
7979
2. 你不需要输出markdown的这个```markdown格式,只需要输出markdown的内容,
80-
3. Latex公式使用$$ $$包裹
80+
3. Latex公式使用$$ $$包裹
8181
4. 严格按照参考用户输入的格式模板以及**正确的编号顺序**
82-
5. 不需要询问用户
82+
5. 不需要询问用户
8383
6. 当提到图片时,请使用提供的图片列表中的文件名
8484
"""
8585

backend/app/tools/code_interpreter.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,32 +75,23 @@ async def _upload_all_files(self):
7575
logger.error(f"工作目录不存在: {self.work_dir}")
7676
raise FileNotFoundError(f"工作目录不存在: {self.work_dir}")
7777

78-
# 只上传数据集文件
7978
files = [
8079
f for f in os.listdir(self.work_dir) if f.endswith((".csv", ".xlsx"))
8180
]
8281
logger.info(f"工作目录中的文件列表: {files}")
8382

8483
for file in files:
8584
file_path = os.path.join(self.work_dir, file)
86-
logger.info(f"处理文件: {file_path}")
87-
8885
if os.path.isfile(file_path):
8986
try:
9087
with open(file_path, "rb") as f:
9188
content = f.read()
92-
# 使用 files API 上传文件
89+
# 使用官方推荐的 files.write 方法
9390
await self.sbx.files.write(f"/home/user/{file}", content)
9491
logger.info(f"成功上传文件到沙箱: {file}")
9592
except Exception as e:
9693
logger.error(f"上传文件 {file} 失败: {str(e)}")
9794
raise
98-
else:
99-
logger.info(f"跳过目录: {file_path}")
100-
101-
# 验证上传的文件
102-
uploaded_files = await self.sbx.files.list("/home/user")
103-
logger.info(f"沙箱中的文件列表: {[f.name for f in uploaded_files]}")
10495

10596
except Exception as e:
10697
logger.error(f"文件上传过程失败: {str(e)}")

frontend/src/components/Bubble.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ const renderedContent = computed(() => {
184184
/* 浅灰 */
185185
color: #0f172a;
186186
box-shadow: 0 2px 8px rgba(16, 185, 129, 0.08);
187-
border: 1px solid #38bdf8;
188187
}
189188
190189
/* WriterAgent 气泡颜色 */
@@ -193,6 +192,5 @@ const renderedContent = computed(() => {
193192
/* 浅黄 */
194193
color: #92400e;
195194
box-shadow: 0 2px 8px rgba(251, 191, 36, 0.08);
196-
border: 1px solid #facc15;
197195
}
198196
</style>

frontend/src/components/ChatArea.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const sendMessage = () => {
2323
</script>
2424

2525
<template>
26-
<div class="flex h-full flex-col p-3 bg-gray-50">
26+
<div class="flex h-full flex-col p-3">
2727
<div ref="scrollRef" class="flex-1 overflow-y-auto">
2828
<template v-for="message in props.messages" :key="message.id">
2929
<div class="mb-3">

frontend/src/components/WriterEditor.vue

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,27 @@ watch(() => props.messages, async (messages) => {
137137
}
138138
139139
.prose table {
140-
@apply w-full border-collapse border border-gray-800;
140+
@apply w-full border-collapse my-6 !border-2 !border-gray-400;
141+
}
142+
143+
.prose th {
144+
@apply !bg-gray-200 p-3 text-left !font-bold !text-gray-900 !border !border-gray-400;
141145
}
142146
143-
.prose th,
144147
.prose td {
145-
@apply border border-gray-800 p-1 text-center;
148+
@apply p-3 !text-gray-900 !border !border-gray-400;
146149
}
147150
148-
.prose th {
149-
@apply font-bold text-gray-900 text-center;
151+
.prose tr {
152+
@apply !border !border-gray-400;
153+
}
154+
155+
.prose tr:nth-child(even) {
156+
@apply !bg-gray-50;
157+
}
158+
159+
.prose tr:hover {
160+
@apply !bg-gray-100;
150161
}
151162
152163
.prose code {

frontend/src/pages/task/index.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { onMounted, onBeforeUnmount, ref } from 'vue'
2121
import { useTaskStore } from '@/stores/task'
2222
import { ScrollArea } from '@/components/ui/scroll-area'
2323
import { getWriterSeque } from '@/apis/commonApi';
24+
import { Button } from '@/components/ui/button';
2425
2526
const props = defineProps<{ task_id: string }>()
2627
const taskStore = useTaskStore()
@@ -52,8 +53,8 @@ onBeforeUnmount(() => {
5253
<ResizablePanel :default-size="70" class="h-full min-w-0">
5354
<div class="flex h-full flex-col min-w-0">
5455
<Tabs default-value="coder" class="w-full h-full flex flex-col">
55-
<div class="border-b px-4 py-1">
56-
<TabsList class="justify-center">
56+
<div class="border-b px-4 py-1 flex justify-between">
57+
<TabsList class="">
5758
<TabsTrigger value="coder" class="text-sm">
5859
CoderAgent
5960
</TabsTrigger>
@@ -62,6 +63,9 @@ onBeforeUnmount(() => {
6263
</TabsTrigger>
6364
</TabsList>
6465
<!-- TODO: 其他选项 -->
66+
<Button @click="taskStore.downloadMessages" class="flex justify-end">
67+
下载消息
68+
</Button>
6569
</div>
6670

6771
<TabsContent value="coder" class="h-full p-1 flex-1 overflow-auto">
@@ -83,10 +87,7 @@ onBeforeUnmount(() => {
8387
</div>
8488
</ResizablePanel>
8589
</ResizablePanelGroup>
86-
<button @click="taskStore.downloadMessages"
87-
class="absolute top-2 right-2 z-10 bg-blue-500 text-white px-3 py-1 rounded">
88-
下载消息
89-
</button>
90+
9091
</div>
9192
</template>
9293

frontend/src/stores/task.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ 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/20250430-232525-876ee531.json'
66

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

1313
// 连接 WebSocket

frontend/src/utils/markdown.ts

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,14 @@ const renderer: Partial<RendererObject> = {
4040
})
4141

4242
// 处理块级公式(使用 $$ 包裹)
43-
if (text.startsWith('$$') && text.endsWith('$$')) {
44-
const tex = text.slice(2, -2).trim()
45-
return `<div class="math-block">${renderMath(tex, true)}</div>`
46-
}
43+
const blockMathPattern = /\$\$([\s\S]*?)\$\$/g
44+
text = text.replace(blockMathPattern, (_, tex) => {
45+
return `<div class="math-block">${renderMath(tex.trim(), true)}</div>`
46+
})
4747

48-
// 处理行内公式(使用 $ 包裹)
49-
text = text.replace(/\$(.*?)\$/g, (_, tex) => renderMath(tex.trim(), false))
48+
// 处理行内公式(使用 \( \) 包裹)
49+
text = text.replace(/\\\((.*?)\\\)/g, (_, tex) => renderMath(tex.trim(), false))
5050

51-
// 处理带括号的公式,确保不是已经处理过的
52-
if (!text.includes('class="katex"')) {
53-
text = text.replace(/\((.*?)\)/g, (match, tex) => {
54-
// 检查是否是数学公式(包含数学符号)
55-
if (/[+\-*/=^_{}\\]/.test(tex)) {
56-
return renderMath(tex.trim(), false)
57-
}
58-
return match // 如果不是数学公式,保持原样
59-
})
60-
}
61-
6251
// 还原图片占位符
6352
text = text.replace(/__IMAGE_PLACEHOLDER_(\d+)__/g, (_, index) => {
6453
const [, alt, src] = images[parseInt(index)]

0 commit comments

Comments
 (0)