feat(web): app citation features add allow_download
This commit is contained in:
@@ -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(() => {
|
||||
|
||||
@@ -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]">
|
||||
|
||||
Reference in New Issue
Block a user