Skip to content

Commit ebf2504

Browse files
committed
✨ Add video rendering for the chat page, name searching when batching add models, and optimize the display effect of the final answer
1 parent a1bf5ca commit ebf2504

File tree

12 files changed

+362
-45
lines changed

12 files changed

+362
-45
lines changed

backend/prompts/managed_system_prompt_template.yaml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,25 @@ system_prompt: |-
7070
在思考结束后,当你认为可以回答用户问题,那么可以不生成代码,直接生成最终回答给到用户并停止循环。
7171
7272
生成最终回答时,你需要遵循以下规范:
73-
1. 使用Markdown格式格式化你的输出。
74-
2. 若使用了检索工具获取到具体信息并基于这些信息回答问题,则需在回答的对应位置添加引用标记:
75-
- 引用标记的字母和数字需要与检索工具的检索结果一一对应
76-
- 引用标记格式为'[[对应字母+数字]]',例如:'[[a1]][[b2]][[c3]]'
73+
1. **Markdown格式要求**:
74+
- 使用标准Markdown语法格式化输出,支持标题、列表、表格、代码块、链接等
75+
- 展示图片和视频使用链接方式,不需要外套代码块,格式:[链接文本](URL),图片格式:![alt文本](图片URL),视频格式:<video src="视频URL" controls></video>
76+
- 段落之间使用单个空行分隔,避免多个连续空行
77+
- 数学公式使用标准Markdown格式:行内公式用 $公式$,块级公式用 $$公式$$
78+
79+
2. **引用标记规范**(仅在使用了检索工具时):
80+
- 引用标记格式必须严格为:`[[字母+数字]]`,例如:`[[a1]]`、`[[b2]]`、`[[c3]]`
81+
- 字母部分必须是单个小写字母(a-e),数字部分必须是整数
82+
- 引用标记的字母和数字必须与检索工具的检索结果一一对应
7783
- 引用标记应紧跟在相关信息或句子之后,通常放在句末或段落末尾
78-
- 注意仅添加引用标记,不需要添加链接、参考文献等多余内容
79-
3. 若未使用检索工具,则不添加任何引用标记
84+
- 多个引用标记可以连续使用,例如:`[[a1]][[b2]]`
85+
- **重要**:仅添加引用标记,不要添加链接、参考文献列表等多余内容
86+
- 如果检索结果中没有匹配的引用,则不显示该引用标记
87+
88+
3. **格式细节要求**:
89+
- 避免在Markdown中使用HTML标签,优先使用Markdown原生语法
90+
- 代码块中的代码应保持原始格式,不要添加额外的转义字符
91+
- 若未使用检索工具,则不添加任何引用标记
8092
8193
注意最后生成的回答要语义连贯,信息清晰,可读性高。
8294

backend/prompts/managed_system_prompt_template_en.yaml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,25 @@ system_prompt: |-
7070
After thinking, when you believe you can answer the user's question, you can generate a final answer directly to the user without generating code and stop the loop.
7171
7272
When generating the final answer, you need to follow these specifications:
73-
1. Use Markdown format to format your output.
74-
2. If you have used retrieval tools to obtain specific information and answer questions based on this information, you need to add reference marks at the corresponding positions in your answer:
75-
- The letters and numbers of the reference marks need to correspond one-to-one with the retrieval results of the retrieval tools
76-
- The reference mark format is '[[corresponding letter+number]]', for example: '[[a1]][[b2]][[c3]]'
77-
- Reference marks should be placed immediately after the relevant information or sentence, usually at the end of the sentence or paragraph
78-
- Note that only reference marks need to be added, no need to add links, references, or other extraneous content
79-
3. If no retrieval tools are used, do not add any reference marks
73+
1. **Markdown Format Requirements**:
74+
- Use standard Markdown syntax to format your output, supporting headings, lists, tables, code blocks, and links.
75+
- Display images and videos using links instead of wrapping them in code blocks. Use `[link text](URL)` for links, `![alt text](image URL)` for images, and `<video src="video URL" controls></video>` for videos.
76+
- Use a single blank line between paragraphs, avoid multiple consecutive blank lines
77+
- Mathematical formulas use standard Markdown format: inline formulas use $formula$, block formulas use $$formula$$
78+
79+
2. **Reference Mark Specifications** (only when retrieval tools are used):
80+
- Reference mark format must strictly be: `[[letter+number]]`, for example: `[[a1]]`, `[[b2]]`, `[[c3]]`
81+
- The letter part must be a single lowercase letter (a-e), the number part must be an integer
82+
- The letters and numbers of reference marks must correspond one-to-one with the retrieval results of retrieval tools
83+
- Reference marks should be placed immediately after relevant information or sentences, usually at the end of sentences or paragraphs
84+
- Multiple reference marks can be used consecutively, for example: `[[a1]][[b2]]`
85+
- **Important**: Only add reference marks, do not add links, reference lists, or other extraneous content
86+
- If there is no matching reference in the retrieval results, do not display that reference mark
87+
88+
3. **Format Detail Requirements**:
89+
- Avoid using HTML tags in Markdown, prioritize native Markdown syntax
90+
- Code in code blocks should maintain original format, do not add extra escape characters
91+
- If no retrieval tools are used, do not add any reference marks
8092
8193
Note that the final generated answer should be semantically coherent, with clear information and high readability.
8294

backend/prompts/manager_system_prompt_template.yaml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,25 @@ system_prompt: |-
7272
在思考结束后,当你认为可以回答用户问题,那么可以不生成代码,直接生成最终回答给到用户并停止循环。
7373
7474
生成最终回答时,你需要遵循以下规范:
75-
1. 使用Markdown格式格式化你的输出。
76-
2. 若使用了检索工具获取到具体信息并基于这些信息回答问题,则需在回答的对应位置添加引用标记:
77-
- 引用标记的字母和数字需要与检索工具的检索结果一一对应
78-
- 引用标记格式为'[[对应字母+数字]]',例如:'[[a1]][[b2]][[c3]]'
75+
1. Markdown格式要求:
76+
- 使用标准Markdown语法格式化输出,支持标题、列表、表格、代码块、链接等
77+
- 展示图片和视频使用链接方式,不需要外套代码块,格式:[链接文本](URL),图片格式:![alt文本](图片URL),视频格式:<video src="视频URL" controls></video>
78+
- 段落之间使用单个空行分隔,避免多个连续空行
79+
- 数学公式使用标准Markdown格式:行内公式用 $公式$,块级公式用 $$公式$$
80+
81+
2. 引用标记规范(仅在使用了检索工具时):
82+
- 引用标记格式必须严格为:`[[字母+数字]]`,例如:`[[a1]]`、`[[b2]]`、`[[c3]]`
83+
- 字母部分必须是单个小写字母(a-e),数字部分必须是整数
84+
- 引用标记的字母和数字必须与检索工具的检索结果一一对应
7985
- 引用标记应紧跟在相关信息或句子之后,通常放在句末或段落末尾
80-
- 注意仅添加引用标记,不需要添加链接、参考文献等多余内容
81-
3. 若未使用检索工具,则不添加任何引用标记
86+
- 多个引用标记可以连续使用,例如:`[[a1]][[b2]]`
87+
- **重要**:仅添加引用标记,不要添加链接、参考文献列表等多余内容
88+
- 如果检索结果中没有匹配的引用,则不显示该引用标记
89+
90+
3. 格式细节要求:
91+
- 避免在Markdown中使用HTML标签,优先使用Markdown原生语法
92+
- 代码块中的代码应保持原始格式,不要添加额外的转义字符
93+
- 若未使用检索工具,则不添加任何引用标记
8294
8395
### 可用资源
8496
你只能使用以下资源,不得使用任何其他工具或助手:

backend/prompts/manager_system_prompt_template_en.yaml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,25 @@ system_prompt: |-
7272
After thinking, when you believe you can answer the user's question, you can generate a final answer directly to the user without generating code and stop the loop.
7373
7474
When generating the final answer, you need to follow these specifications:
75-
1. Use Markdown format to format your output.
76-
2. If you have used retrieval tools to obtain specific information and answer questions based on this information, you need to add reference marks at the corresponding positions in your answer:
77-
- The letters and numbers of the reference marks need to correspond one-to-one with the retrieval results of the retrieval tools
78-
- The reference mark format is '[[corresponding letter+number]]', for example: '[[a1]][[b2]][[c3]]'
79-
- Reference marks should be placed immediately after the relevant information or sentence, usually at the end of the sentence or paragraph
80-
- Note that only reference marks need to be added, no need to add links, references, or other extraneous content
81-
3. If no retrieval tools are used, do not add any reference marks
75+
1. **Markdown Format Requirements**:
76+
- Use standard Markdown syntax to format your output, supporting headings, lists, tables, code blocks, and links.
77+
- Display images and videos using links instead of wrapping them in code blocks. Use `[link text](URL)` for links, `![alt text](image URL)` for images, and `<video src="video URL" controls></video>` for videos.
78+
- Use a single blank line between paragraphs, avoid multiple consecutive blank lines
79+
- Mathematical formulas use standard Markdown format: inline formulas use $formula$, block formulas use $$formula$$
80+
81+
2. **Reference Mark Specifications** (only when retrieval tools are used):
82+
- Reference mark format must strictly be: `[[letter+number]]`, for example: `[[a1]]`, `[[b2]]`, `[[c3]]`
83+
- The letter part must be a single lowercase letter (a-e), the number part must be an integer
84+
- The letters and numbers of reference marks must correspond one-to-one with the retrieval results of retrieval tools
85+
- Reference marks should be placed immediately after relevant information or sentences, usually at the end of sentences or paragraphs
86+
- Multiple reference marks can be used consecutively, for example: `[[a1]][[b2]]`
87+
- **Important**: Only add reference marks, do not add links, reference lists, or other extraneous content
88+
- If there is no matching reference in the retrieval results, do not display that reference mark
89+
90+
3. **Format Detail Requirements**:
91+
- Avoid using HTML tags in Markdown, prioritize native Markdown syntax
92+
- Code in code blocks should maintain original format, do not add extra escape characters
93+
- If no retrieval tools are used, do not add any reference marks
8294
8395
### Available Resources
8496
You can only use the following resources, and may not use any other tools or agents:

frontend/app/[locale]/chat/streaming/taskWindow.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ const messageHandlers: MessageHandler[] = [
665665
content={message.content}
666666
className="task-message-content"
667667
showDiagramToggle={false}
668+
enableMultimodal={false}
668669
/>
669670
</div>
670671
),
@@ -759,6 +760,7 @@ const messageHandlers: MessageHandler[] = [
759760
content={content}
760761
className="task-message-content"
761762
showDiagramToggle={false}
763+
enableMultimodal={false}
762764
/>
763765
);
764766
} else {

frontend/app/[locale]/models/components/model/ModelAddDialog.tsx

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from 'react'
1+
import { useMemo, useState } from 'react'
22
import { useTranslation } from 'react-i18next'
33

44
import { Modal, Select, Input, Button, Switch, Tooltip, App } from "antd";
@@ -159,6 +159,7 @@ export const ModelAddDialog = ({
159159
});
160160

161161
const [modelList, setModelList] = useState<any[]>([]);
162+
const [modelSearchTerm, setModelSearchTerm] = useState("");
162163
const [selectedModelIds, setSelectedModelIds] = useState<Set<string>>(
163164
new Set()
164165
);
@@ -190,6 +191,24 @@ export const ModelAddDialog = ({
190191
}
191192
};
192193

194+
const filteredModelList = useMemo(() => {
195+
const keyword = modelSearchTerm.trim().toLowerCase()
196+
if (!keyword) {
197+
return modelList
198+
}
199+
return modelList.filter((model: any) => {
200+
const candidates = [
201+
model.id,
202+
model.model_name,
203+
model.model_tag,
204+
model.description,
205+
]
206+
return candidates.some((text) =>
207+
typeof text === "string" && text.toLowerCase().includes(keyword)
208+
)
209+
})
210+
}, [modelList, modelSearchTerm])
211+
193212
// Handle model name change, automatically update the display name
194213
const handleModelNameChange = (e: React.ChangeEvent<HTMLInputElement>) => {
195214
const name = e.target.value;
@@ -813,7 +832,20 @@ export const ModelAddDialog = ({
813832
</Button>
814833
</div>
815834
{showModelList && (
816-
<div className="mt-2 space-y-1 max-h-60 overflow-y-auto">
835+
<div className="mt-2 max-h-60 overflow-y-auto">
836+
{modelList.length > 0 && (
837+
<div className="sticky top-0 z-10 bg-gray-50 pb-2">
838+
<Input
839+
allowClear
840+
size="small"
841+
placeholder={t("model.dialog.modelList.searchPlaceholder")}
842+
value={modelSearchTerm}
843+
onChange={(event) =>
844+
setModelSearchTerm(event.target.value)
845+
}
846+
/>
847+
</div>
848+
)}
817849
{loadingModelList ? (
818850
<div className="flex flex-col items-center justify-center py-4 text-xs text-gray-500">
819851
<LoadingOutlined
@@ -827,11 +859,15 @@ export const ModelAddDialog = ({
827859
<span>{t("common.loading") || "获取中..."}</span>
828860
</div>
829861
) : modelList.length === 0 ? (
862+
<div className="text-xs text-gray-500 text-center space-y-1">
863+
<div>{t("model.dialog.message.noModels")}</div>
864+
</div>
865+
) : filteredModelList.length === 0 ? (
830866
<div className="text-xs text-gray-500 text-center">
831-
{t("model.dialog.message.noModels") || "请先获取模型"}
867+
{t("model.dialog.modelList.noResults")}
832868
</div>
833869
) : (
834-
modelList.map((model: any) => {
870+
filteredModelList.map((model: any) => {
835871
const checked = selectedModelIds.has(model.id);
836872
const toggleSelect = (value: boolean) => {
837873
setSelectedModelIds((prev) => {

0 commit comments

Comments
 (0)