Skip to content

Commit e0c81f3

Browse files
committed
add
1 parent 0510b5a commit e0c81f3

File tree

7 files changed

+770
-27
lines changed

7 files changed

+770
-27
lines changed

backend/app/core/prompts.py

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

8586

backend/app/tools/code_interpreter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ async def _pre_execute_code(self):
115115
)
116116
await self.execute_code(init_code)
117117

118-
def _truncate_text(self, text: str, max_length: int = 2000) -> str:
118+
def _truncate_text(self, text: str, max_length: int = 1000) -> str:
119119
"""截断文本,保留开头和结尾的重要信息"""
120120
if len(text) <= max_length:
121121
return text

frontend/src/components/WriterEditor.vue

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { onMounted, ref, watch, computed } from 'vue';
33
import { renderMarkdown } from '@/utils/markdown';
44
import type { WriterMessage } from '@/utils/response'
55
import { ScrollArea } from '@/components/ui/scroll-area'
6-
import { getWriterSeque } from '@/apis/commonApi';
76
87
interface ContentSection {
98
id: number;
@@ -14,14 +13,10 @@ interface ContentSection {
1413
1514
const props = defineProps<{
1615
messages: WriterMessage[]
16+
writerSequence: string[]
1717
}>()
1818
19-
const writerSequence = ref<string[]>([]);
2019
21-
onMounted(async () => {
22-
const res = await getWriterSeque();
23-
writerSequence.value = Array.isArray(res.data) ? res.data : [];
24-
});
2520
2621
const sections = ref<ContentSection[]>([]);
2722
let nextId = 0;
@@ -39,11 +34,11 @@ const appendContent = async (content: string, sub_title?: string) => {
3934
4035
// 根据 writerSequence 排序内容
4136
const sortedSections = computed(() => {
42-
if (!writerSequence.value.length) return sections.value;
37+
if (!props.writerSequence.length) return sections.value;
4338
4439
return [...sections.value].sort((a, b) => {
45-
const aIndex = a.sub_title ? writerSequence.value.indexOf(a.sub_title) : Infinity;
46-
const bIndex = b.sub_title ? writerSequence.value.indexOf(b.sub_title) : Infinity;
40+
const aIndex = a.sub_title ? props.writerSequence.indexOf(a.sub_title) : Infinity;
41+
const bIndex = b.sub_title ? props.writerSequence.indexOf(b.sub_title) : Infinity;
4742
4843
if (aIndex === Infinity && bIndex === Infinity) return 0;
4944
if (aIndex === Infinity) return 1;
@@ -73,7 +68,7 @@ watch(() => props.messages, async (messages) => {
7368
<div class="max-w-4xl mx-auto overflow-y-auto space-y-6">
7469
<TransitionGroup name="section" tag="div" class="space-y-6">
7570
<div v-for="section in sortedSections" :key="section.id"
76-
class="bg-white rounded-lg shadow-lg overflow-hidden transform transition-all duration-500">
71+
class="bg-white rounded-lg shadow-lg transform transition-all duration-500">
7772
<div class="p-6">
7873
<div class="prose prose-slate max-w-none" v-html="section.renderedContent"></div>
7974
</div>
@@ -142,16 +137,16 @@ watch(() => props.messages, async (messages) => {
142137
}
143138
144139
.prose table {
145-
@apply w-full border-collapse border border-gray-300 my-4;
140+
@apply w-full border-collapse border border-gray-800;
146141
}
147142
148143
.prose th,
149144
.prose td {
150-
@apply border border-gray-300 p-2;
145+
@apply border border-gray-800 p-1 text-center;
151146
}
152147
153-
.prose thead {
154-
@apply bg-gray-50;
148+
.prose th {
149+
@apply font-bold text-gray-900 text-center;
155150
}
156151
157152
.prose code {

frontend/src/pages/task/index.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,25 @@ import {
1717
import CoderEditor from '@/components/CoderEditor.vue'
1818
import WriterEditor from '@/components/WriterEditor.vue'
1919
import ChatArea from '@/components/ChatArea.vue'
20-
import { onMounted, onBeforeUnmount } from 'vue'
20+
import { onMounted, onBeforeUnmount, ref } from 'vue'
2121
import { useTaskStore } from '@/stores/task'
2222
import { ScrollArea } from '@/components/ui/scroll-area'
23+
import { getWriterSeque } from '@/apis/commonApi';
2324
2425
const props = defineProps<{ task_id: string }>()
2526
const taskStore = useTaskStore()
2627
28+
const writerSequence = ref<string[]>([]);
29+
2730
console.log('Task ID:', props.task_id)
2831
29-
onMounted(() => {
32+
onMounted(async () => {
3033
taskStore.connectWebSocket(props.task_id)
34+
const res = await getWriterSeque();
35+
writerSequence.value = Array.isArray(res.data) ? res.data : [];
3136
})
3237
38+
3339
onBeforeUnmount(() => {
3440
taskStore.closeWebSocket()
3541
})
@@ -69,7 +75,7 @@ onBeforeUnmount(() => {
6975
<TabsContent value="writer" class="flex-1 p-1 min-w-0 h-full overflow-auto">
7076
<Card class="min-w-0 rounded-lg">
7177
<CardContent class="p-2 h-full min-w-0 overflow-auto">
72-
<WriterEditor :messages="taskStore.writerMessages" />
78+
<WriterEditor :messages="taskStore.writerMessages" :writerSequence="writerSequence" />
7379
</CardContent>
7480
</Card>
7581
</TabsContent>

frontend/src/stores/task.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ 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-163507-03282e09.json'
5+
import messageData from '@/test/20250430-232525-876ee531.json'
66

77
export const useTaskStore = defineStore('task', () => {
88
// 初始化时直接加载测试数据,确保页面首次渲染时有数据

frontend/src/test/20250430-232525-876ee531.json

Lines changed: 741 additions & 0 deletions
Large diffs are not rendered by default.

frontend/src/utils/markdown.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ const renderer: Partial<RendererObject> = {
3939
return `__IMAGE_PLACEHOLDER_${imageIndex++}__`
4040
})
4141

42-
// 处理块级公式
43-
if (text.startsWith('\\[') && text.endsWith('\\]')) {
42+
// 处理块级公式(使用 $$ 包裹)
43+
if (text.startsWith('$$') && text.endsWith('$$')) {
4444
const tex = text.slice(2, -2).trim()
4545
return `<div class="math-block">${renderMath(tex, true)}</div>`
4646
}
4747

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

5151
// 处理带括号的公式,确保不是已经处理过的
5252
if (!text.includes('class="katex"')) {

0 commit comments

Comments
 (0)