feat(web): app citation features add allow_download

This commit is contained in:
zhaoying
2026-04-24 15:10:32 +08:00
parent 279353e1ce
commit c556995f3a
8 changed files with 51 additions and 32 deletions

View File

@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title></title>
<title></title>
<g id="空间里层页面优化" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round">
<g id="记忆库-个人记忆-感知记忆-文本" transform="translate(-573, -158)" stroke="#171719">
<g id="导" transform="translate(573, 158)">
<g id="记忆库-个人记忆-感知记忆-文本" transform="translate(-555, -158)" stroke="#171719">
<g id="导" transform="translate(555, 158)">
<g id="编组-54" transform="translate(3, 3)">
<path d="M10,6 L10,7.5 C10,8.88071187 8.88071187,10 7.5,10 L2.5,10 C1.11928813,10 0,8.88071187 0,7.5 L0,6 L0,6" id="路径"></path>
<g id="编组-11" transform="translate(2, 0)">
<g id="编组-11" transform="translate(5, 3.4982) scale(1, -1) translate(-5, -3.4982)translate(2, 0)">
<line x1="3" y1="0.08499952" x2="3" y2="6.99635859" id="路径-24"></line>
<polyline id="路径-25" stroke-linejoin="round" points="0 3 2.98005548 6.08298138e-18 6 3"></polyline>
</g>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title></title>
<title></title>
<g id="空间里层页面优化" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round">
<g id="记忆库-个人记忆-感知记忆-文本" transform="translate(-555, -158)" stroke="#171719">
<g id="导" transform="translate(555, 158)">
<g id="记忆库-个人记忆-感知记忆-文本" transform="translate(-573, -158)" stroke="#171719">
<g id="导" transform="translate(573, 158)">
<g id="编组-54" transform="translate(3, 3)">
<path d="M10,6 L10,7.5 C10,8.88071187 8.88071187,10 7.5,10 L2.5,10 C1.11928813,10 0,8.88071187 0,7.5 L0,6 L0,6" id="路径"></path>
<g id="编组-11" transform="translate(5, 3.4982) scale(1, -1) translate(-5, -3.4982)translate(2, 0)">
<g id="编组-11" transform="translate(2, 0)">
<line x1="3" y1="0.08499952" x2="3" y2="6.99635859" id="路径-24"></line>
<polyline id="路径-25" stroke-linejoin="round" points="0 3 2.98005548 6.08298138e-18 6 3"></polyline>
</g>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -272,14 +272,22 @@ const ChatContent: FC<ChatContentProps> = ({
<Flex vertical gap={4} className="rb:mt-1! rb:pt-3! rb-border-t rb:mb-2!">
<div className="rb:font-medium">{t('memoryConversation.citations')}</div>
{item.meta_data?.citations?.map((citation, idx) => (
<div
key={idx}
className="rb:text-[#155EEF] rb:leading-5 rb:underline rb:cursor-pointer"
onClick={() => {
const params = new URLSearchParams({ documentId: citation.document_id, parentId: citation.knowledge_id });
window.open(`/#/knowledge-base/${citation.knowledge_id}/DocumentDetails?${params}`, '_blank');
}}
>{citation.file_name}</div>
<Flex align="center" gap={12}>
<div
key={idx}
className="rb:text-[#155EEF] rb:leading-5 rb:underline rb:cursor-pointer"
onClick={() => {
const params = new URLSearchParams({ documentId: citation.document_id, parentId: citation.knowledge_id });
window.open(`/#/knowledge-base/${citation.knowledge_id}/DocumentDetails?${params}`, '_blank');
}}
>{citation.file_name}</div>
{citation.download_url &&
<div className="rb:size-4 rb:cursor-pointer rb:bg-cover rb:bg-[url('@/assets/images/application/export.svg')]"
onClick={() => handleDownload({ url: citation.download_url })}
></div>
}
</Flex>
))}
</Flex>
}

View File

@@ -24,7 +24,7 @@ export interface ChatItem {
subContent?: Record<string, any>[];
error?: string;
meta_data?: {
audio_url?: string;
audio_url?: string | null;
audio_status?: string;
files?: any[];
suggested_questions?: string[];
@@ -33,6 +33,7 @@ export interface ChatItem {
file_name: string;
knowledge_id: string;
score: string;
download_url?: string;
}[];
reasoning_content?: string;
},

View File

@@ -1470,6 +1470,7 @@ export const en = {
add_questions: 'Add Option',
citation: 'Citation and Attribution',
citation_desc: 'Display the attribution of source documents and generated content',
allow_download: 'Allow downloading cited source text',
invalidVariablesTitle: "The following undefined variables are referenced in the conversation opening. Do you want to save the opening configuration?",
deep_thinking: 'Enable Deep Thinking',

View File

@@ -800,6 +800,7 @@ export const zh = {
add_questions: '添加选项',
citation: '引用和归属',
citation_desc: '显示源文档和生成内容的归属部分',
allow_download: '允许下载引用原文',
invalidVariablesTitle: "对话开场白中引用了以下未定义的变量,是否保存开场白配置?",
deep_thinking: '开启深度思考',

View File

@@ -7,7 +7,7 @@
import { useEffect, useRef, useState, forwardRef, useImperativeHandle, useMemo } from 'react';
import { useTranslation } from 'react-i18next'
import { useParams } from 'react-router-dom';
import { Row, Col, Space, Form, Input, Button, App, Spin, Flex } from 'antd'
import { Row, Col, Space, Form, Input, Button, App, Flex } from 'antd'
import Chat from './components/Chat'
import RbCard from '@/components/RbCard/Card'
@@ -357,21 +357,23 @@ const Agent = forwardRef<AgentRef, { onFeaturesLoad?: (features: FeaturesConfigF
const { statement = '' } = value?.opening_statement || {}
onFeaturesLoad?.(value)
const usedVars = [...new Set([...(statement?.matchAll(/\{\{(\w+)\}\}/g) ?? [])].map(m => m[1]))]
const variables = values?.variables
const validNames = new Set(variables.map(v => v.name))
const invalid = usedVars.filter(v => !validNames.has(v))
if (invalid.length > 0) {
const newVars = invalid.map((name, i) => ({
index: variables.length + i,
name,
display_name: name,
type: 'text',
required: true,
max_length: 48,
}))
if (value.opening_statement.enabled) {
const usedVars = [...new Set([...(statement?.matchAll(/\{\{(\w+)\}\}/g) ?? [])].map(m => m[1]))]
const variables = values?.variables
const validNames = new Set(variables.map(v => v.name))
const invalid = usedVars.filter(v => !validNames.has(v))
if (invalid.length > 0) {
const newVars = invalid.map((name, i) => ({
index: variables.length + i,
name,
display_name: name,
type: 'text',
required: true,
max_length: 48,
}))
form.setFieldValue('variables', [...variables, ...newVars])
form.setFieldValue('variables', [...variables, ...newVars])
}
}
}
const modelLogo = useMemo(() => {

View File

@@ -155,6 +155,12 @@ const FeaturesConfigModal = forwardRef<FeaturesConfigModalRef, FeaturesConfigMod
name={['citation', "enabled"]}
desc={t('application.citation_desc')}
/>
<SwitchFormItem
title={t(`application.allow_download`)}
name={['citation', "allow_download"]}
disabled={!values?.citation?.enabled}
className="rb:mt-2!"
/>
</div>
<div className="rb:relative rb:border rb:border-[#DFE4ED] rb:p-3 rb:rounded-lg rb:bg-[#f5f7fc]">