diff --git a/package.json b/package.json index 95977a4..da32d24 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@tenx-ui/utils": "^2.3.1", "@umijs/max": "^4.0.42", "@yunti/lowcode-datasource-axios-handler": "^1.0.1", - "@yuntijs/arcadia-bff-sdk": "^1.0.48", + "@yuntijs/arcadia-bff-sdk": "^1.0.50", "KubeAGIUpload": "workspace:*", "antd": "^5.12.2", "app-card": "workspace:*", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0e4b3ed..92c2bc5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -72,8 +72,8 @@ importers: specifier: ^1.0.1 version: 1.0.1 '@yuntijs/arcadia-bff-sdk': - specifier: ^1.0.48 - version: 1.0.48(@tenx-ui/materials@1.5.28)(antd@5.12.3)(react@18.2.0)(swr@2.2.4) + specifier: ^1.0.50 + version: 1.0.50(@tenx-ui/materials@1.5.28)(antd@5.12.3)(react@18.2.0)(swr@2.2.4) KubeAGIUpload: specifier: workspace:* version: link:packages/KubeAGIUpload @@ -641,12 +641,12 @@ packages: react: '>=16.0.0' react-dom: '>=16.0.0' dependencies: - '@babel/runtime': 7.23.2 + '@babel/runtime': 7.23.5 '@emotion/hash': 0.8.0 '@emotion/unitless': 0.7.5 classnames: 2.3.2 csstype: 3.1.2 - rc-util: 5.38.0(react-dom@18.2.0)(react@18.2.0) + rc-util: 5.38.1(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) stylis: 4.3.0 @@ -2644,7 +2644,6 @@ packages: engines: {node: '>=6.9.0'} dependencies: regenerator-runtime: 0.14.0 - dev: false /@babel/template@7.22.15: resolution: {integrity: sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==} @@ -3007,7 +3006,7 @@ packages: '@dnd-kit/core': ^6.0.7 react: '>=16.8.0' dependencies: - '@dnd-kit/core': 6.0.8(react-dom@17.0.2)(react@18.2.0) + '@dnd-kit/core': 6.0.8(react-dom@18.2.0)(react@18.2.0) '@dnd-kit/utilities': 3.2.1(react@18.2.0) react: 18.2.0 tslib: 2.6.2 @@ -7103,8 +7102,8 @@ packages: - debug dev: false - /@yuntijs/arcadia-bff-sdk@1.0.48(@tenx-ui/materials@1.5.28)(antd@5.12.3)(react@18.2.0)(swr@2.2.4): - resolution: {integrity: sha512-enOSvTjeznO0IIZ83EC1rYB6G94NcBg5+4kmXOPrjqCsdSWSB4okZ+lZVoi+e8eWsw9Edq/ONwfFXkPBAQFjwQ==} + /@yuntijs/arcadia-bff-sdk@1.0.50(@tenx-ui/materials@1.5.28)(antd@5.12.3)(react@18.2.0)(swr@2.2.4): + resolution: {integrity: sha512-QcZm9gedUKX9bSLhrma5/eBJ1x4b05nVCgDEDf1M3yZG0wtdSYMscHnbZdQ7OrpnfZBWOxe2bTCHdMnvdd7sMw==} peerDependencies: '@tenx-ui/materials': '>=1.5.8' antd: '>=5.4.0' @@ -7814,7 +7813,7 @@ packages: resolution: {integrity: sha1-nvbcdN65NLTbNE3Jc+6FHRSMUME=} engines: {node: '>=10', npm: '>=6'} dependencies: - '@babel/runtime': 7.23.2 + '@babel/runtime': 7.23.5 cosmiconfig: 7.1.0 resolve: 1.22.8 @@ -7957,7 +7956,7 @@ packages: '@babel/preset-env': 7.23.2(@babel/core@7.23.2) '@babel/preset-react': 7.22.15(@babel/core@7.23.2) '@babel/preset-typescript': 7.23.2(@babel/core@7.23.2) - '@babel/runtime': 7.23.2 + '@babel/runtime': 7.23.5 babel-plugin-macros: 3.1.0 babel-plugin-transform-react-remove-prop-types: 0.4.24 transitivePeerDependencies: @@ -9175,7 +9174,7 @@ packages: /dom-helpers@5.2.1: resolution: {integrity: sha1-2UAFNrK/giWtmP4FLgKUUaxA6QI=} dependencies: - '@babel/runtime': 7.23.2 + '@babel/runtime': 7.23.5 csstype: 3.1.2 dev: false @@ -13028,14 +13027,6 @@ packages: react: 18.2.0 dev: false - /lucide-react@0.299.0(react@18.2.0): - resolution: {integrity: sha512-59MiDzDzFI/efHhb4n0vGdXelMNwou7JlAFvVS4boA1G/7aYU7garPciYo73CODzkhrhz0JOgdtSTPSe5dMrlQ==} - peerDependencies: - react: ^16.5.1 || ^17.0.0 || ^18.0.0 - dependencies: - react: 18.2.0 - dev: false - /lz-string@1.5.0: resolution: {integrity: sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==} hasBin: true @@ -15902,22 +15893,6 @@ packages: react-dom: 17.0.2(react@18.2.0) dev: false - /rc-menu@9.12.2(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-NzloFH2pRUYmQ3S/YbJAvRkgCZaLvq0sRa5rgJtuIHLfPPprNHNyepeSlT64+dbVqI4qRWL44VN0lUCldCbbfg==} - peerDependencies: - react: '>=16.9.0' - react-dom: '>=16.9.0' - dependencies: - '@babel/runtime': 7.23.5 - '@rc-component/trigger': 1.18.2(react-dom@18.2.0)(react@18.2.0) - classnames: 2.3.2 - rc-motion: 2.9.0(react-dom@18.2.0)(react@18.2.0) - rc-overflow: 1.3.2(react-dom@18.2.0)(react@18.2.0) - rc-util: 5.38.1(react-dom@18.2.0)(react@18.2.0) - react: 18.2.0 - react-dom: 18.2.0(react@18.2.0) - dev: false - /rc-menu@9.12.4(react-dom@17.0.2)(react@18.2.0): resolution: {integrity: sha512-t2NcvPLV1mFJzw4F21ojOoRVofK2rWhpKPx69q2raUsiHPDP6DDevsBILEYdsIegqBeSXoWs2bf6CueBKg3BFg==} peerDependencies: @@ -16268,9 +16243,9 @@ packages: react: '>=16.9.0' react-dom: '>=16.9.0' dependencies: - '@babel/runtime': 7.23.2 + '@babel/runtime': 7.23.5 classnames: 2.3.2 - rc-util: 5.38.0(react-dom@18.2.0)(react@18.2.0) + rc-util: 5.38.1(react-dom@18.2.0)(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) resize-observer-polyfill: 1.5.1 @@ -16619,7 +16594,7 @@ packages: '@babel/runtime': 7.23.5 classnames: 2.3.2 rc-dropdown: 4.1.0(react-dom@18.2.0)(react@18.2.0) - rc-menu: 9.12.2(react-dom@18.2.0)(react@18.2.0) + rc-menu: 9.12.4(react-dom@18.2.0)(react@18.2.0) rc-motion: 2.9.0(react-dom@18.2.0)(react@18.2.0) rc-resize-observer: 1.4.0(react-dom@18.2.0)(react@18.2.0) rc-util: 5.38.1(react-dom@18.2.0)(react@18.2.0) @@ -17025,7 +17000,7 @@ packages: peerDependencies: react: '>=16.13.1' dependencies: - '@babel/runtime': 7.23.2 + '@babel/runtime': 7.23.5 react: 18.2.0 dev: false @@ -17605,7 +17580,7 @@ packages: /regenerator-transform@0.15.2: resolution: {integrity: sha512-hfMp2BoF0qOk3uc5V20ALGDS2ddjQaLrdl7xrGXvAIow7qeWRM2VA2HuCHkUKk9slq3VwEwLNK3DFBqDfPGYtg==} dependencies: - '@babel/runtime': 7.23.2 + '@babel/runtime': 7.23.5 /regexp.prototype.flags@1.5.1: resolution: {integrity: sha512-sy6TXMN+hnP/wMy+ISxg3krXx7BAtWVO4UouuCN/ziM9UEne0euamVNafDfvC83bRNr95y0V5iijeDQFUNpvrg==} diff --git a/src/components/Status/index.tsx b/src/components/Status/index.tsx index c988a5c..8606921 100644 --- a/src/components/Status/index.tsx +++ b/src/components/Status/index.tsx @@ -19,7 +19,12 @@ interface props { const Status: React.FC = props => { const { status, text } = props; // 0灰,1 绿,3 红 - const _c = { info: '#1677ff', success: '#5cb85c', error: '#f85a5a' }[status]; + const _c = { + info: '#1677ff', + success: '#5cb85c', + error: '#f85a5a', + default: 'rgba(0, 0, 0, 0.25)', + }[status]; return (
{_c && } diff --git a/src/pages/CreateDataHandle/index.jsx b/src/pages/CreateDataHandle/index.jsx index 2e18122..1b243fd 100644 --- a/src/pages/CreateDataHandle/index.jsx +++ b/src/pages/CreateDataHandle/index.jsx @@ -190,7 +190,7 @@ class $$Page extends React.Component { max_tokens: 512, prompt_template: `{text} -请将上述内容按照问答的方式,提出不超过 25 个问题,并给出每个问题的答案,每个问题必须有 Q 和对应的 A,并严格按照以下方式展示: Q1: 问题。\n A1: 答案。\n Q2: 问题 \n A2: 答案\n 注意,尽可能多的提出问题,但是 Q 不要重复,也不要出现只有 Q 没有 A 的情况。`, +请将上述内容按照问答的方式,提出不超过 25 个问题,并给出每个问题的答案,每个问题必须有 Q 和对应的 A,并严格按照以下方式展示: Q1: 问题。\n A1: 答案。\n Q2: 问题 \n A2: 答案\n 注意,尽可能多的提出问题,但是 Q 不要重复,也不要出现只有 Q 没有 A 的情况。`, }, selectedFileList: [], showLlmModel: false, @@ -779,7 +779,7 @@ class $$Page extends React.Component { }); } - setQaSplitHighConfigValue(value, event, extraParams = {}) { + setQaSplitHighConfigValue(_value, event, extraParams = {}) { const fieldName = { ...event, ...extraParams, @@ -788,22 +788,14 @@ class $$Page extends React.Component { ...event, ...extraParams, }.times; - console.log({ - ...event, - ...extraParams, - }); + const value = fieldName === 'prompt_template' ? _value.target.value : _value; const qaSplitHighConfig = { ...this.state.qaSplitHighConfig, [fieldName]: times ? value * times : value, }; - this.setState( - { - qaSplitHighConfig, - }, - () => { - console.log(this.state.qaSplitHighConfig); - } - ); + this.setState({ + qaSplitHighConfig, + }); if (fieldName === 'temperature') { this.form('temperature_form').setValues({ temperature: qaSplitHighConfig.temperature / 100, diff --git a/src/pages/DataHandleDetail/DataHandle.tsx b/src/pages/DataHandleDetail/DataHandle.tsx index 3d6a090..8499d18 100644 --- a/src/pages/DataHandleDetail/DataHandle.tsx +++ b/src/pages/DataHandleDetail/DataHandle.tsx @@ -1,18 +1,26 @@ import { DownOutlined, EyeInvisibleFilled, UpOutlined } from '@ant-design/icons'; -import { Card, Col, Row, Steps, Table } from 'antd'; +import { Button, Card, Col, Form, Modal, Progress, Row, Steps, Table } from 'antd'; import React, { useEffect, useMemo, useState } from 'react'; import styles from './datahandle.less'; const SPLIT_TYPE_NAME = '拆分处理'; +const layout = { + labelCol: { span: 5 }, + wrapperCol: { span: 19 }, +}; interface Iprops { data: Record; + getData: () => void; } const DataHandle: React.FC = props => { const config = props.data?.config; const [items, setItems] = useState([]); + const [highConfigVisible, setHighConfigVisible] = useState(false); + const [highConfig, setHighConfig] = useState({}); const [visibleMap, setVisibleMap] = useState({}); + const [showReloadBtn, setShowReloadBtn] = useState(false); const getColumns = useMemo(() => { return [ @@ -69,13 +77,25 @@ const DataHandle: React.FC = props => { ]; }, []); - const renderDesc = (data, type) => { + const openHighConfig = () => { + setHighConfigVisible(true); + }; + + const closeHighConfig = () => { + setHighConfigVisible(false); + }; + + const renderDesc = (data, type, sourceItem) => { // 顺便计算处理了多少文件 const _dataSource = []; const _data = data.map(item => { _dataSource.push(...item.preview); return ( - +
@@ -84,11 +104,31 @@ const DataHandle: React.FC = props => {
{item.zh_name}

{item.description}

+ {type === SPLIT_TYPE_NAME && ( +
+
+ 模型:{' '} + + {item.llm_config?.provider === 'worker' + ? item.llm_config?.name + : item.llm_config?.name + '/' + item.llm_config?.model} + +
+ +
+ )} ); }); + // 如果是拆分处理把高级配置存起来 + if (type === SPLIT_TYPE_NAME) { + const qa_split_data = data.find(item => item.name === 'qa_split'); + setHighConfig(qa_split_data.llm_config); + } const dataSource = []; // 拆分处理的表格只展示文件名和拆分后 if (type === SPLIT_TYPE_NAME) { @@ -107,12 +147,72 @@ const DataHandle: React.FC = props => { dataSource.push(...data); }); } - + // 如果是未处理的状态 + if (!visibleMap[type] && sourceItem.status === 'not_start') { + return ( +
+ {_data} +
+ {' '} + 对 {props?.data?.file_num} 个文件进行了{type}。 +
+
+ ); + } + // 如果是拆分处理的配置,单独处理 + if (type === SPLIT_TYPE_NAME) { + if (!visibleMap[type]) { + // 如果是QA-拆分 处理中 的任务 + if (sourceItem.status === 'doing') { + const qa_split_data = data.find(item => item.name === 'qa_split'); + const fileProgress = qa_split_data.file_progress; + // mock + // const fileProgress = [{progress:"30",id:1,file_name:'xx1'},{progress:"0",id:2,file_name:'xx2'},{progress:"80",id:3,file_name:'xx3'}]; + const progressPrecent = fileProgress.filter(item => parseInt(item.progress) === 100); + return ( + <> +
+ {_data} +
+ {' '} + 对 {fileProgress.length} 个文件进行了{type},处理进度:{progressPrecent.length}/ + {fileProgress.length} +
+ {fileProgress.map((item, index) => { + return ( +
+
+ {item.file_name} +
+ +
+ ); + })} +
+ + ); + } + return ( +
+ {_data} +
+ {' '} + 对 {props?.data?.file_num} 个文件进行了{type} + ,以下内容为处理效果抽样预览,并非全部内容 +
+ + + ); + } + } return ( !visibleMap[type] && (
{_data} -
+
{' '} 对 {props?.data?.file_num} 个文件进行了{type},以下内容为处理效果抽样预览,并非全部内容
@@ -126,18 +226,23 @@ const DataHandle: React.FC = props => { ); }; - const statuesMap = { - doing: 'process', - succeed: 'finish', + const stepStatuesMap = { + not_start: 'wait', + doing: 'info', + success: 'finish', fail: 'error', }; const statuesMapText = { + not_start: { + color: 'rgba(0,0,0,.25)', + text: '未处理', + }, doing: { color: '#1677ff', text: '处理中', }, - succeed: { + success: { color: '#5cb85c', text: '处理成功', }, @@ -158,14 +263,16 @@ const DataHandle: React.FC = props => { ), subTitle: !visibleMap[item.description] ? ( - { - setVisibleMap({ ...visibleMap, [item.description]: !visibleMap[item.description] }); - }} - > - 收起 - + <> + { + setVisibleMap({ ...visibleMap, [item.description]: !visibleMap[item.description] }); + }} + > + 收起 + + ) : ( = props => { 展开 ), - description: renderDesc(item.children, item.description), - status: statuesMap[item.status], + description: renderDesc(item.children, item.description, item), + status: stepStatuesMap[item.status], }; }); setItems(item); }, [config, visibleMap]); + return (
+ {config?.find(item => item.status === 'doing') ? ( + + ) : ( + '' + )} + +
+ {highConfig?.temperature} + {highConfig?.max_tokens} + +
+
{highConfig?.prompt_template}
+
+
+ +
); }; diff --git a/src/pages/DataHandleDetail/datahandle.less b/src/pages/DataHandleDetail/datahandle.less index e249b2a..a295960 100644 --- a/src/pages/DataHandleDetail/datahandle.less +++ b/src/pages/DataHandleDetail/datahandle.less @@ -1,5 +1,11 @@ .datahandle { font-size: 12px; + position: relative; + .reloadBtn { + position: absolute; + right: 40px; + z-index: 99; + } .stepSubtitle { cursor: pointer; } diff --git a/src/pages/DataHandleDetail/index.tsx b/src/pages/DataHandleDetail/index.tsx index 7fcec20..ea40285 100644 --- a/src/pages/DataHandleDetail/index.tsx +++ b/src/pages/DataHandleDetail/index.tsx @@ -77,7 +77,7 @@ const DataHandleDetail = props => { { key: 'data-handle', label: '数据处理', - children: , + children: , }, ]; diff --git a/src/pages/ModelAppDetail/Body/ConfigKnowledge/index.tsx b/src/pages/ModelAppDetail/Body/ConfigKnowledge/index.tsx index 57140be..db438e8 100644 --- a/src/pages/ModelAppDetail/Body/ConfigKnowledge/index.tsx +++ b/src/pages/ModelAppDetail/Body/ConfigKnowledge/index.tsx @@ -30,51 +30,51 @@ const Knowledge: React.FC = props => { }, [props.checkedIds]); return ( - {(canSelect ? items : checkedIds?.map(id => items?.find(item => item.id === id)))?.map( + {(canSelect ? items : checkedIds?.map(id => items?.find(item => item?.id === id)))?.map( item => { return ( { if (!canSelect) return; if (!multi) { - setCheckedIds([item.id]); - props.setCheckedIds && props.setCheckedIds([item.id]); + setCheckedIds([item?.id]); + props.setCheckedIds && props.setCheckedIds([item?.id]); return; } - if (checkedIds.includes(item.id)) { - setCheckedIds(checkedIds?.filter(id => id !== item.id)); + if (checkedIds.includes(item?.id)) { + setCheckedIds(checkedIds?.filter(id => id !== item?.id)); props.setCheckedIds && - props.setCheckedIds(checkedIds?.filter(id => id !== item.id)); + props.setCheckedIds(checkedIds?.filter(id => id !== item?.id)); return; } - setCheckedIds([...checkedIds, item.id]); - props.setCheckedIds && props.setCheckedIds([...checkedIds, item.id]); + setCheckedIds([...checkedIds, item?.id]); + props.setCheckedIds && props.setCheckedIds([...checkedIds, item?.id]); }} >
- + - {item.name} + {item?.name}
{canDelete && ( { - setCheckedIds && setCheckedIds(checkedIds?.filter(id => item.id !== id)); + setCheckedIds && setCheckedIds(checkedIds?.filter(id => item?.id !== id)); props.setCheckedIds && - props.setCheckedIds(checkedIds?.filter(id => item.id !== id)); + props.setCheckedIds(checkedIds?.filter(id => item?.id !== id)); }} /> )} diff --git a/src/pages/ModelAppDetail/Body/Container/index.tsx b/src/pages/ModelAppDetail/Body/Container/index.tsx index fbcaad9..088c9ba 100644 --- a/src/pages/ModelAppDetail/Body/Container/index.tsx +++ b/src/pages/ModelAppDetail/Body/Container/index.tsx @@ -26,12 +26,11 @@ interface ContainerProps { const Container: React.FC = props => { const { children, icon, title, actions, configKey, changeConfig, renderChildren } = props; - const [form] = Form.useForm(); const [modalOpen, setModalOpen] = useState(false); const [modalType, setModalType] = useState(); const [ignored, forceUpdate] = useReducer(x => x + 1, 0); const [actionData, setActionData] = useState(); - const { initConfigs, configs, setConfigs } = useModalAppDetailContext(); + const { initConfigs, configs, setConfigs, form } = useModalAppDetailContext(); useEffect(() => { form.setFieldsValue(initConfigs?.[configKey] || {}); forceUpdate(); diff --git a/src/pages/ModelAppDetail/Body/Dialogue/index.tsx b/src/pages/ModelAppDetail/Body/Dialogue/index.tsx index 1f99a0a..5bd5630 100644 --- a/src/pages/ModelAppDetail/Body/Dialogue/index.tsx +++ b/src/pages/ModelAppDetail/Body/Dialogue/index.tsx @@ -1,19 +1,22 @@ import Icon from '@/assets/img/model-app-bx.png'; import ChatComponent from '@/pages/Chat/Chat'; import { Typography } from '@tenx-ui/materials'; -import { Card, Space, Tag } from 'antd'; -import React, { useState } from 'react'; +import { Card, Space, Spin, Tag } from 'antd'; +import React, { useEffect, useState } from 'react'; import { useModalAppDetailContext } from '../../index'; import Modal from '../Modal'; -interface DialogueProps {} + +interface DialogueProps { + saveIng: boolean; +} const Dialogue: React.FC = props => { const [modalOpen, setModalOpen] = useState(false); const [modalType, setModalType] = useState('reference'); const [modalData, setModalData] = useState(); - const { data } = useModalAppDetailContext(); + const { data, loading } = useModalAppDetailContext(); return ( - <> + {/*
{ setModalOpen(true); @@ -21,7 +24,12 @@ const Dialogue: React.FC = props => { > 对话引用弹窗
*/} - + = props => { Card content - +
); }; diff --git a/src/pages/ModelAppDetail/Body/Modal/index.tsx b/src/pages/ModelAppDetail/Body/Modal/index.tsx index 0cc7f3c..8568db1 100644 --- a/src/pages/ModelAppDetail/Body/Modal/index.tsx +++ b/src/pages/ModelAppDetail/Body/Modal/index.tsx @@ -125,7 +125,6 @@ const Setting: React.FC = props => { } }); }} - destroyOnClose >
diff --git a/src/pages/ModelAppDetail/Body/index.tsx b/src/pages/ModelAppDetail/Body/index.tsx index ed2f713..3b9ca31 100644 --- a/src/pages/ModelAppDetail/Body/index.tsx +++ b/src/pages/ModelAppDetail/Body/index.tsx @@ -1,5 +1,6 @@ import { Card, notification, Typography } from '@tenx-ui/materials'; -import { Button, Col, Flex, Row } from 'antd'; +import { Button, Col, Flex, Row, Tooltip } from 'antd'; +import { isEqual } from 'lodash'; import React, { useState } from 'react'; import utils from '../../../utils/__utils'; import { useModalAppDetailContext } from '../index'; @@ -14,25 +15,35 @@ import styles from './index.less'; interface BodyProps {} const Body: React.FC = props => { - const { refresh, data, configs } = useModalAppDetailContext(); + const { + refresh, + data, + configs, + initConfigs, + loading: cardLoading, + form, + } = useModalAppDetailContext(); const [loading, setLoading] = useState(false); + const [saveIng, setSaveIng] = useState(false); + return ( - + 应用配置 - + setSaveIng(!saveIng); + } catch (error) { + setLoading(false); + notification.warnings({ + message: '保存应用配置失败', + errors: error?.response?.errors, + }); + } + }} + loading={loading} + > + 保存并预览 + +
@@ -67,7 +79,7 @@ const Body: React.FC = props => { - + diff --git a/src/pages/ModelAppDetail/Header/Edit/index.tsx b/src/pages/ModelAppDetail/Header/Edit/index.tsx index fb6c8a2..0fa7208 100644 --- a/src/pages/ModelAppDetail/Header/Edit/index.tsx +++ b/src/pages/ModelAppDetail/Header/Edit/index.tsx @@ -36,11 +36,11 @@ const Edit: React.FC = props => { forceUpdate(); }; useEffect(() => { - if (data && type === 'edit') { + if (open && data && type === 'edit') { form.setFieldsValue(data); setImageUrl(data?.icon); } - }, [data, form, type]); + }, [data, form, type, open]); const handleChange = info => { getBase64(info.file, url => { diff --git a/src/pages/ModelAppDetail/Header/index.tsx b/src/pages/ModelAppDetail/Header/index.tsx index c3bd903..858c6c5 100644 --- a/src/pages/ModelAppDetail/Header/index.tsx +++ b/src/pages/ModelAppDetail/Header/index.tsx @@ -1,16 +1,19 @@ import { Col, Divider, Dropdown, Image, Row, Space, Typography } from '@tenx-ui/materials'; +import { getUnifiedHistory } from '@tenx-ui/utils/es/UnifiedLink/index.prod'; import { Card } from 'antd'; import React, { useState } from 'react'; import { useModalAppDetailContext } from '../index'; import Delete from './Delete'; import Edit from './Edit'; import Publish from './Publish'; + interface HeaderProps {} const Header: React.FC = props => { const { refresh, data, loading } = useModalAppDetailContext(); const [modalOpen, setModalOpen] = useState(false); const [modalType, setModalType] = useState<'publish' | 'edit' | 'delete'>(); + const history = getUnifiedHistory(); const handlePublish = () => { setModalOpen(true); @@ -143,11 +146,14 @@ const Header: React.FC = props => { }, }} onClick={() => { - handlePublish(); + history.push( + `/chat?appNamespace=${data?.metadata?.namespace}&appName=${data?.metadata?.name}` + ); + // handlePublish(); }} destroyPopupOnHide={true} > - 发布 + 对话 diff --git a/src/pages/ModelAppDetail/index.tsx b/src/pages/ModelAppDetail/index.tsx index 1da12f4..381be3f 100644 --- a/src/pages/ModelAppDetail/index.tsx +++ b/src/pages/ModelAppDetail/index.tsx @@ -1,5 +1,6 @@ import { Button, Col, Page, Row, Space } from '@tenx-ui/materials'; import { matchPath, useLocation } from '@umijs/max'; +import { Form } from 'antd'; import React, { createContext, useContext, useEffect, useState } from 'react'; import utils from '../../utils/__utils'; import Body from './Body'; @@ -14,7 +15,7 @@ interface ModelAppDetailDetailProps {} const ModelAppDetailDetail: React.FC = () => { const location = useLocation(); const match = matchPath({ path: '/model-app/detail/:id' }, location.pathname); - + const [form] = Form.useForm(); const { data, loading, mutate } = utils.bff.useGetApplication({ name: match?.params?.id, namespace: utils.getAuthData().project, @@ -27,23 +28,23 @@ const ModelAppDetailDetail: React.FC = () => { const Application = data?.Application?.getApplication; const Config = { ConfigConversationStarter: { - prologue: Application?.prologue, + prologue: Application?.prologue || undefined, }, ConfigModelService: { - llm: Application?.llm, - model: Application?.model, + llm: Application?.llm || undefined, + model: Application?.model || undefined, temperature: Application?.temperature, maxLength: Application?.maxLength, conversionWindowSize: Application?.conversionWindowSize, }, ConfigKnowledge: { - knowledgebase: Application?.knowledgebase, + knowledgebase: Application?.knowledgebase || undefined, scoreThreshold: Application?.scoreThreshold, numDocuments: Application?.numDocuments, - docNullReturn: Application?.docNullReturn, + docNullReturn: Application?.docNullReturn || undefined, }, ConfigPrompt: { - userPrompt: Application?.userPrompt, + userPrompt: Application?.userPrompt || undefined, }, ConfigAudio: {}, ConfigNext: { @@ -66,6 +67,7 @@ const ModelAppDetailDetail: React.FC = () => { configs, setConfigs, initConfigs, + form, }} > diff --git a/src/pages/ModelAppList/index.jsx b/src/pages/ModelAppList/index.jsx index 7182c71..d215a7e 100644 --- a/src/pages/ModelAppList/index.jsx +++ b/src/pages/ModelAppList/index.jsx @@ -312,7 +312,6 @@ class ModelAppList$$Page extends React.Component { }); } else { const project = this.utils.getAuthData()?.project; - console.log(this.state.fileList); const params = { namespace: project, name: values.name, @@ -473,6 +472,12 @@ class ModelAppList$$Page extends React.Component { return `共 ${total} 条`; } + validate(value, item) { + if (!value?.fileList?.length) { + return '请选择文件上传'; + } + } + componentDidMount() { console.log('did mount', this.utils.bff); this.getData(); @@ -571,13 +576,28 @@ class ModelAppList$$Page extends React.Component { }.bind(this), }, }} - decoratorProps={{ 'x-decorator-props': { labelEllipsis: true, size: 'default' } }} + decoratorProps={{ + 'x-decorator-props': { asterisk: true, labelEllipsis: true, size: 'default' }, + }} fieldProps={{ name: '_icon', - required: true, + required: false, title: '上传', 'x-component': 'FormilyUpload', - 'x-validator': [], + 'x-validator': [ + { + children: '未知', + id: 'disabled', + required: false, + type: 'disabled', + validator: function () { + return this.validate.apply( + this, + Array.prototype.slice.call(arguments).concat([]) + ); + }.bind(this), + }, + ], }} > {__$$eval(() => __$$context.utils.getFullName(item))} @@ -978,13 +988,28 @@ class ModelAppList$$Page extends React.Component { }.bind(this), }, }} - decoratorProps={{ 'x-decorator-props': { labelEllipsis: true, size: 'default' } }} + decoratorProps={{ + 'x-decorator-props': { asterisk: true, labelEllipsis: true, size: 'default' }, + }} fieldProps={{ + enum: [], name: 'icon', - required: true, + required: false, title: '上传', 'x-component': 'FormilyUpload', - 'x-validator': [], + 'x-validator': [ + { + children: '未知', + id: 'disabled', + type: 'disabled', + validator: function () { + return this.validate.apply( + this, + Array.prototype.slice.call(arguments).concat([]) + ); + }.bind(this), + }, + ], }} > + {__$$eval(() => + this.getFullDescribe({ + key: 'api', + }) + )} + + ), + key: 'wdifgpbo6x', + label: 'API地址', + span: 1, + }, { children: ( - {__$$eval(() => - this.getFullDescribe({ - key: 'api', - }) - )} - - ), - key: 'wdifgpbo6x', - label: 'API地址', - span: 1, - }, { children: (