index.tsx 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885
  1. import * as React from 'react';
  2. import { useLocation } from 'react-router-dom';
  3. import { observer } from 'mobx-react';
  4. import './style.less';
  5. import {
  6. Button, Input, Form, Divider, Splitter, Select, InputNumber, InputNumberProps,
  7. Radio, Switch, Row, Col, Slider, Space, RadioChangeEvent,
  8. Spin, message
  9. } from 'antd';
  10. import { PlusCircleOutlined, MinusCircleOutlined } from '@ant-design/icons';
  11. import { apis } from '@/apis';
  12. import router from '@/router';
  13. import LocalStorage from '@/LocalStorage';
  14. const { TextArea } = Input;
  15. const FormItem = Form.Item;
  16. const { Option } = Select;
  17. const MAX_COUNT = 10;
  18. const Index = 1;
  19. const QuestionAnswerInfo: React.FC = () => {
  20. const [form] = Form.useForm();
  21. // top_p
  22. const [topPValue, setTopPValue] = React.useState(0.1);
  23. const TopPDecimalStep: React.FC = () => {
  24. const onChange: InputNumberProps['onChange'] = (value) => {
  25. if (Number.isNaN(value)) {
  26. return;
  27. }
  28. setTopPValue(value as number);
  29. };
  30. return (
  31. <Row>
  32. <Col span={12}>
  33. <Slider
  34. min={0}
  35. max={1}
  36. onChange={onChange}
  37. // value={typeof topPValue === 'number' ? topPValue : 0}
  38. value={topPValue}
  39. step={0.1}
  40. />
  41. </Col>
  42. <Col span={4}>
  43. <InputNumber
  44. min={0}
  45. max={1}
  46. style={{ margin: '0 16px', width: '100px' }}
  47. step={0.01}
  48. value={topPValue}
  49. onChange={onChange}
  50. />
  51. </Col>
  52. </Row>
  53. );
  54. };
  55. const [tempValue, setTempValue] = React.useState(0.01);
  56. // temperature
  57. const TempDecimalStep: React.FC = () => {
  58. const onChange: InputNumberProps['onChange'] = (value) => {
  59. if (Number.isNaN(value)) {
  60. return;
  61. }
  62. setTempValue(value as number);
  63. };
  64. return (
  65. <Row>
  66. <Col span={12}>
  67. <Slider
  68. min={0}
  69. max={1}
  70. onChange={onChange}
  71. // value={typeof tempValue === 'number' ? tempValue : 0}
  72. value={tempValue}
  73. step={0.01}
  74. />
  75. </Col>
  76. <Col span={4}>
  77. <InputNumber
  78. min={0}
  79. max={1}
  80. style={{ margin: '0 16px', width: '100px' }}
  81. step={0.01}
  82. value={tempValue}
  83. onChange={onChange}
  84. />
  85. </Col>
  86. </Row>
  87. );
  88. };
  89. type ModelList = {
  90. label: string,
  91. value: string,
  92. }[];
  93. type KnowledgeList = {
  94. label: string,
  95. value: string,
  96. }[];
  97. type AppTypeList = {
  98. label: string,
  99. value: string,
  100. }[];
  101. const [step, setStep] = React.useState(1);
  102. const [pageLoading, setPageLoading] = React.useState(false);
  103. const [modelList, setModelList] = React.useState<ModelList>([]);
  104. const [knowledgeList, setKnowledgeList] = React.useState<KnowledgeList>([]);
  105. const [isVisible, setIsVisible] = React.useState(false);
  106. const [isVisibleCus, setIsVisibleCus] = React.useState(false);
  107. const [isVisibleSlice, setIsVisibleSlice] = React.useState(false);
  108. const [isVisibleRerank, setIsVisibleRerank] = React.useState(false);
  109. const [name, setName] = React.useState('');
  110. const [appTypeList, setAppTypeList] = React.useState<AppTypeList>([]);
  111. const [updateFlag, setUpdateFlag] = React.useState<boolean>();
  112. const [createFlag, setCreateFlag] = React.useState<boolean>();
  113. const [appProjectList, setAppProjectList] = React.useState<AppTypeList>([]);
  114. const [isAppPro, setIsAppPro] = React.useState<boolean>(false);
  115. const [selectedAppProId, setSelectedAppProId] = React.useState<string | undefined>(undefined); // 新增状态变量用于绑定 Select 值
  116. const style: React.CSSProperties = {
  117. display: 'flex',
  118. flexDirection: 'column',
  119. gap: 8,
  120. width: 300,
  121. };
  122. const location = useLocation();
  123. const init = async (id: string) => {
  124. await Promise.all([
  125. api.fetchKnowlegde(),
  126. api.fetchAppType(),
  127. // api.fetchModelList(),
  128. api.fetchAppProType(),
  129. ])
  130. if (id) {
  131. await api.fetchDetail(id);
  132. }
  133. }
  134. React.useEffect(() => {
  135. const id = location?.state?.id;
  136. init(id);
  137. const uFlag = LocalStorage.getStatusFlag('deepseek:application:update');
  138. setUpdateFlag(uFlag);
  139. const cFlag = LocalStorage.getStatusFlag('deepseek:application:create');
  140. setCreateFlag(cFlag);
  141. }, []);
  142. // 定义一个状态来存储输入框数组
  143. const [inputs, setInputs] = React.useState([{ id: 1, value: '' }]);
  144. // 添加新输入框的函数
  145. const addInput = () => {
  146. const newId = inputs.length + 1; // 生成新的唯一ID
  147. setInputs([...inputs, { id: newId, value: '' }]);
  148. };
  149. const delInput = () => {
  150. const newId = inputs.length - 1; // 生成新的唯一ID
  151. setInputs(inputs.slice(0, inputs.length - 1));
  152. };
  153. // 处理输入变更的函数
  154. const handleChange = (id: number, value: string) => {
  155. setInputs(inputs.map(input => (input.id === id ? { ...input, value } : input)));
  156. };
  157. const handleAppChange = (typeId: number) => {
  158. if (typeId === 41) { // 根据实际值进行判断
  159. setIsAppPro(true);
  160. } else {
  161. setIsAppPro(false);
  162. }
  163. };
  164. // const onChange: InputNumberProps['onChange'] = (value) => {
  165. // console.log('changed', value);
  166. // };
  167. const onChangeShow = (checked: boolean) => {
  168. console.log(`switch to ${checked}`);
  169. };
  170. const onChangeModel = (checked: boolean) => {
  171. setIsVisibleRerank(!isVisibleRerank);
  172. };
  173. const onChangeCount = (value: string) => {
  174. if (value === 'fixed') {
  175. setIsVisibleSlice(!isVisibleSlice);
  176. } else {
  177. setIsVisibleSlice(false);
  178. }
  179. };
  180. // 召回方式
  181. const onChangeRecallMethod = (e: RadioChangeEvent) => {
  182. };
  183. // 获取应用详情
  184. const api = {
  185. fetchDetail: async (app_id: string) => {
  186. setPageLoading(true);
  187. try {
  188. const res = await apis.fetchTakaiApplicationDetail(app_id)
  189. console.log(res.data);
  190. const sd = res.data.questionlist.map((item: any, index: number) => {
  191. return {
  192. "id": index + 1,
  193. "value": item.question,
  194. }
  195. });
  196. const info = res.data.detail;
  197. setTopPValue(info.topP as number);
  198. setTempValue(info.temperature as number);
  199. setName(info.name);
  200. interface Item2 {
  201. index_type_id: number,
  202. knowledge_id: string
  203. }
  204. interface Item {
  205. show_recall_result: boolean,
  206. recall_method: string,
  207. rerank_status: boolean,
  208. slice_config_type: string,
  209. slice_count: number,
  210. recall_slice_splicing_method: string,
  211. param_desc: string,
  212. rerank_model_name: string,
  213. rerank_index_type_list: [Item2],
  214. recall_index_type_list: [Item2]
  215. }
  216. const data_info: Item = JSON.parse(info.knowledgeInfo);
  217. if (data_info.param_desc === 'custom') {
  218. setIsVisibleCus(!isVisibleCus); //自定义回答风格
  219. }
  220. if (data_info.rerank_status === true) {
  221. setIsVisibleRerank(!isVisibleRerank) //模型
  222. }
  223. //召回切片数量
  224. if (data_info.slice_config_type === 'fixed') {
  225. setIsVisibleSlice(!isVisibleSlice);
  226. } else {
  227. setIsVisibleSlice(false);
  228. }
  229. if(info.typeId === 42 || info.typeId === 43){
  230. setIsAppPro(true);
  231. }else{
  232. setIsAppPro(false);
  233. }
  234. form.setFieldsValue({
  235. id: info.id,
  236. name: info.name, //应用名称
  237. desc: info.desc, //应用描述
  238. prompt: info.prompt, //应用提示语
  239. top_p: info.topP as number, //topP
  240. temperature: info.temperature as number, //温度
  241. knowledge_ids: info.knowledgeIds,
  242. model: info.model,
  243. icon_color: info.icon_color,
  244. icon_type: info.icon_type,
  245. questionList: sd, //问题列表
  246. max_token: info.maxToken, //应用最大token
  247. updateDate: info.updateDate, // 更新时间
  248. appProId: info.typeId, //项目级应用类型
  249. typeId: info.typeId === 42 || info.typeId === 43 ? 41 : info.typeId, //应用类型
  250. param_desc: data_info.param_desc, //回答风格
  251. show_recall_result: data_info.show_recall_result, //是否展示召回结果
  252. recall_method: data_info.recall_method, //召回方式
  253. rerank_status: data_info.rerank_status, //开启rerank
  254. rerank_model_name: data_info.rerank_model_name, //模型名称
  255. slice_config_type: data_info.slice_config_type, // 召回切片数量
  256. slice_count: data_info.slice_count, // 切片数量
  257. recall_slice_splicing_method: data_info.recall_slice_splicing_method, // 切片内容
  258. // rerank_status = 1 rerank_index_type_list
  259. // recall_method = 'embedding' || 'mixed' recall_index_type_list
  260. //recall_index_type_list: info.recall_index_type_list, //知识库id
  261. //rerank_index_type_list: info.rerank_index_type_list, //知识库id
  262. })
  263. if (sd.length > 0) {
  264. setInputs(sd);
  265. }
  266. } catch (error) {
  267. console.error(error);
  268. } finally {
  269. setPageLoading(false);
  270. }
  271. },
  272. //获取知识库列表
  273. fetchKnowlegde: async () => {
  274. try {
  275. const res = await apis.fetchTakaiKnowledgeList();
  276. const list = res.data.map((item: any) => {
  277. return {
  278. label: item.name,
  279. value: item.knowledgeId,
  280. }
  281. });
  282. setKnowledgeList(list);
  283. } catch (error: any) {
  284. console.error(error);
  285. }
  286. },
  287. // 获取应用类型
  288. fetchAppType: async () => {
  289. try {
  290. const res = await apis.fetchTakaiAppTypeList('app_type');
  291. const list = res.data.map((item: any) => {
  292. return {
  293. label: item.dictLabel,
  294. value: item.dictCode,
  295. }
  296. });
  297. setAppTypeList(list);
  298. } catch (error: any) {
  299. console.error(error);
  300. }
  301. },
  302. // 获取模型列表
  303. fetchModelList: async () => {
  304. try {
  305. const res = await apis.fetchModelList();
  306. const list = res.data.data.map((item: any) => {
  307. return {
  308. label: item.modelName,
  309. value: item.modelCode,
  310. }
  311. });
  312. setModelList(list);
  313. } catch (error: any) {
  314. console.error(error);
  315. }
  316. },
  317. // 项目级应用下的类型
  318. fetchAppProType: async () => {
  319. try {
  320. const res = await apis.fetchTakaiAppTypeList('project_type');
  321. const list = res.data.map((item: any) => {
  322. return {
  323. label: item.dictLabel,
  324. value: item.dictCode,
  325. }
  326. });
  327. console.log(list, 'project_type');
  328. setAppProjectList(list);
  329. } catch (error: any) {
  330. console.error(error);
  331. }
  332. },
  333. }
  334. const handleRedioClick = (value: string) => {
  335. setIsVisibleCus(false);
  336. if (value === 'strict') {
  337. setTopPValue(0.5);
  338. setTempValue(0.01);
  339. } else if (value === 'moderate') {
  340. setTopPValue(0.7);
  341. setTempValue(0.50);
  342. } else if (value === 'flexib') {
  343. setTopPValue(0.9);
  344. setTempValue(0.90);
  345. }
  346. }
  347. return (
  348. <div className='questionAnswerInfo'>
  349. <Spin spinning={pageLoading}>
  350. <Form
  351. form={form}
  352. layout='vertical'
  353. initialValues={{
  354. max_token: 1024
  355. }}
  356. >
  357. <div style={{ display: step === 1 ? 'block' : 'none' }} className='questionAnswerInfo-content'>
  358. <FormItem
  359. label='问答应用名称'
  360. name='name'
  361. rules={[{ required: true, message: '问答应用名称不能为空' }]}
  362. >
  363. <Input placeholder="应用名称" style={{ width: 646, padding: 8 }} />
  364. </FormItem>
  365. <FormItem
  366. label='应用类型'
  367. name='typeId'
  368. >
  369. <Select
  370. style={{ width: '300px', height: '48px' }}
  371. placeholder='请选应用类型'
  372. onChange={handleAppChange}
  373. allowClear={true}
  374. >
  375. {
  376. appTypeList.map((item, index) => {
  377. return <Option value={item.value} key={index}>
  378. {item.label}
  379. </Option>
  380. })
  381. }
  382. </Select>
  383. </FormItem>
  384. {
  385. isAppPro &&
  386. <FormItem
  387. label='类型'
  388. name='appProId'
  389. rules={[{ required: true, message: '项目类型不能为空' }]}
  390. >
  391. <Select
  392. style={{ width: '300px', height: '48px' }}
  393. placeholder='请选择项目类型'
  394. value={selectedAppProId}
  395. onChange={(value) => setSelectedAppProId(value)}
  396. >
  397. {appProjectList.map((item, index) => (
  398. <Option value={item.value} key={index}>
  399. {item.label}
  400. </Option>
  401. ))}
  402. </Select>
  403. </FormItem>
  404. }
  405. <FormItem
  406. label='问答应用描述'
  407. name='desc'
  408. rules={[{ required: true, message: '问答应用描述不能为空' }]}
  409. >
  410. <TextArea
  411. showCount
  412. maxLength={500}
  413. placeholder="请输入描述"
  414. style={{ height: 120, resize: 'none', width: 646 }}
  415. />
  416. </FormItem>
  417. <div>
  418. <h4>添加预设问题</h4>
  419. <div>
  420. {
  421. inputs.map(input => (
  422. <div key={input.id} style={{ paddingTop: '10px' }}>
  423. <label>问题 {input.id}</label>
  424. <Input
  425. style={{ width: 300, paddingTop: 8, marginLeft: 20 }}
  426. type="text"
  427. value={input.value}
  428. onChange={e => handleChange(input.id, e.target.value)}
  429. />
  430. <PlusCircleOutlined style={{ marginLeft: 20 }} onClick={addInput} />
  431. <MinusCircleOutlined style={{ marginLeft: 20 }} onClick={delInput} />
  432. </div>
  433. ))}
  434. </div>
  435. </div>
  436. <br />
  437. <Button type='primary' onClick={() => {
  438. form.validateFields(['name', 'desc', 'appProId']).then(async (values) => {
  439. setStep(2);
  440. setInputs(inputs);
  441. }).catch((error) => {
  442. console.error(error);
  443. });
  444. }} >
  445. 下一步
  446. </Button>
  447. </div>
  448. <div style={{ display: step === 2 ? 'block' : 'none' }} className='questionAnswerInfo-content'>
  449. <div style={{ paddingBottom: '10px', display: 'flex', justifyContent: 'flex-end' }}>
  450. <div>
  451. <Button
  452. style={{ background: '#f5f5f5' }}
  453. onClick={() => {
  454. setStep(1);
  455. }}
  456. >
  457. 上一步
  458. </Button>
  459. {
  460. createFlag &&
  461. <Button
  462. type='primary'
  463. onClick={() => {
  464. form.validateFields().then(async (values) => {
  465. const data = values;
  466. console.log(values, 'values');
  467. // 问题列表
  468. const question: string[] = [];
  469. if (inputs) {
  470. inputs.map((item, index) => {
  471. question.push(item.value);
  472. });
  473. }
  474. console.log(question, 'question');
  475. interface Item {
  476. index_type_id: number,
  477. knowledge_id: string
  478. }
  479. const indexTypeList: Item[] = [];
  480. if (values.knowledge_ids && values.knowledge_ids.length > 0) {
  481. const index_type: Item = {
  482. index_type_id: 0,
  483. knowledge_id: values.knowledge_ids
  484. };
  485. indexTypeList.push(index_type);
  486. }
  487. const userInfo = LocalStorage.getUserInfo();
  488. const userId = (userInfo?.id ?? '').toString();
  489. const data_info = {
  490. param_desc: values.param_desc, //回答风格
  491. show_recall_result: values.show_recall_result, //是否展示召回结果
  492. recall_method: values.recall_method, //召回方式
  493. rerank_status: values.rerank_status, //开启rerank
  494. rerank_model_name: values.rerank_model_name, //模型名称
  495. slice_config_type: values.slice_config_type, // 召回切片数量
  496. slice_count: values.slice_count, // 切片数量
  497. recall_slice_splicing_method: values.recall_slice_splicing_method, // 切片内容
  498. rerank_index_type_list: values.rerank_status === true ? indexTypeList : [], //知识库id
  499. recall_index_type_list: values.recall_method === 'embedding' || 'mixed' ? indexTypeList : []
  500. // rerank_status = 1 rerank_index_type_list
  501. // recall_method = 'embedding' || 'embedding' recall_index_type_list
  502. };
  503. // const knowledgeIds: string[] = [];
  504. // knowledgeIds.push(values.knowledge_ids);
  505. console.log(values.appProId , 'values.appProId ');
  506. const info = {
  507. id: values.id,
  508. name: values.name, //应用名称
  509. desc: values.desc, //应用描述
  510. prompt: values.prompt, //应用提示语
  511. top_p: topPValue.toString(), //topP
  512. temperature: tempValue.toString(), //温度
  513. knowledge_ids: values.knowledge_ids,
  514. slice_count: values.slice_count,
  515. model: values.model,
  516. icon_color: values.icon_color,
  517. icon_type: values.icon_type,
  518. questionList: question,
  519. knowledge_info: JSON.stringify(data_info),
  520. max_token: values.max_token, //应用最大token
  521. typeId: values.appProId === 42 || values.appProId === 43 ? values.appProId : values.typeId, // 应用类型
  522. userId: userId, // 用户id
  523. };
  524. console.log(info, 'info data');
  525. const id = location?.state?.id;
  526. let res = null;
  527. if (id) {
  528. // 编辑应用
  529. res = await apis.modifyTakaiApplicationApi(id, info);
  530. } else {
  531. // 创建应用
  532. res = await await apis.createTakaiApplicationApi(info);
  533. }
  534. console.log(res, 'create or modify');
  535. if (res.data === 9) {
  536. message.error('没有配置审核人,请联系管理员');
  537. } else if (res.data === 1) {
  538. message.success('操作成功')
  539. } else {
  540. message.error('操作失败');
  541. }
  542. router.navigate({ pathname: '/deepseek/questionAnswer' });
  543. }).catch((error) => {
  544. console.error(error);
  545. error.errorFields && error.errorFields.map((item: any) => {
  546. console.log(item, 'item');
  547. message.error(`字段 ${item.name} ${item.errors[0]}`);
  548. });
  549. });
  550. }}
  551. >提交应用</Button>
  552. }
  553. </div>
  554. </div>
  555. <Splitter style={{ height: '100%', boxShadow: '0 0 10px rgba(0, 0, 0, 0.1)' }}>
  556. <Splitter.Panel defaultSize="40%">
  557. <div style={{ width: '100%', height: '100%' }}>
  558. <h2>Prompt编写</h2>
  559. <div style={{ paddingTop: '20px' }}>
  560. <TextArea
  561. autoSize
  562. readOnly
  563. placeholder="编写Prompt过程中可以引入2项变量:{{知识}} 代表知识库中检索到的知识内容, {{用户}}代表用户输入的内容。您可以在编写Prompt过程中将变量拼接在合适的位置。插入:{{知识}} 插入:{{用户}}"
  564. style={{ width: '100%', height: '300px' }}
  565. />
  566. </div>
  567. <Divider plain></Divider>
  568. <div >
  569. <FormItem name='prompt'
  570. initialValue={`你是一位知识检索助手,你必须并且只能从我发送的众多知识片段中寻找能够解决用户输入问题的最优答案,并且在执行任务的过程中严格执行规定的要求。
  571. 知识片段如下:
  572. {{知识}}
  573. 规定要求:
  574. - 找到答案就仅使用知识片段中的原文回答用户的提问;
  575. - 找不到答案就用自身知识并且告诉用户该信息不是来自文档;
  576. - 所引用的文本片段中所包含的示意图占位符必须进行返回,占位符格式参考:【示意图序号_编号】
  577. - 严禁输出任何知识片段中不存在的示意图占位符;
  578. - 输出的内容必须删除其中包含的任何图注、序号等信息。例如:“进入登录页面(图1.1)”需要从文字中删除图序,回复效果为:“进入登录页面”;“如图所示1.1”,回复效果为:“如图所示”;
  579. - 格式规范
  580. - 文档中会出现包含表格的情况,表格是以图片标识符的形式呈现,表格中缺失数据时候返回空单元格;
  581. - 如果需要用到表格中的数据,以代码块语法输出表格中的数据;
  582. - 避免使用代码块语法回复信息;
  583. - 回复的开头语不要输出诸如:“我想”,“我认为”,“think”等相关语义的文本。
  584. 严格执行规定要求,不要复述问题,直接开始回答。
  585. 用户输入问题:
  586. {{用户}}`}
  587. rules={[{ required: true, message: '提示词不能为空' }]}>
  588. <TextArea
  589. placeholder="提示词"
  590. rows={50}
  591. />
  592. </FormItem>
  593. </div>
  594. </div>
  595. </Splitter.Panel>
  596. <Splitter.Panel defaultSize="60%">
  597. <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', background: '#f5f5f5', width: '100%', height: '100%' }}>
  598. <div style={{ width: '50%', height: '100%' }}>
  599. <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', paddingTop: '50px', fontSize: '16px' }}>
  600. 欢迎使用 {name}
  601. </div>
  602. <div style={{
  603. display: 'flex', justifyContent: 'center', alignItems: 'center',
  604. paddingTop: '20px'
  605. }}>
  606. <FormItem
  607. label='引用知识库'
  608. name='knowledge_ids'
  609. rules={[{ required: true, message: '知识库不能为空' }]}>
  610. <Select
  611. // mode='multiple'
  612. // maxCount={MAX_COUNT}
  613. // suffixIcon={suffix}
  614. style={{ width: '300px', height: '48px' }}
  615. placeholder='请选择知识库'
  616. >
  617. {
  618. knowledgeList.map((item, index) => {
  619. return <Option value={item.value} key={index}>
  620. {item.label}
  621. </Option>
  622. })
  623. }
  624. </Select>
  625. </FormItem>
  626. </div>
  627. <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
  628. <FormItem
  629. label='调用模型'
  630. name="model"
  631. rules={[{ required: true, message: '模型不能为空' }]}>
  632. <Select
  633. placeholder='请选择模型'
  634. allowClear={true}
  635. style={{ width: '300px', height: '48px' }}
  636. >
  637. <Option value='DeepSeek-R1-Distill-Llama-70B'>DeepSeek-R1-Distill-Llama-70B</Option>
  638. <Option value='Qwen2-72B'>Qwen2-72B</Option>
  639. {/* {
  640. modelList.map((item, index) => {
  641. return <Option value={item.value} key={index}>
  642. {item.label}
  643. </Option>
  644. })
  645. } */}
  646. </Select>
  647. </FormItem>
  648. </div>
  649. <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
  650. <FormItem
  651. label='max token'
  652. name='max_token'
  653. rules={[{ required: true, message: 'max token不能为空' }]}>
  654. <InputNumber
  655. className='questionAnswerInfo-content-title'
  656. />
  657. </FormItem>
  658. </div>
  659. {
  660. !isVisible &&
  661. <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
  662. <a onClick={() => {
  663. setIsVisible(!isVisible);
  664. }} className='questionAnswerInfo-content-title'>
  665. 更多设置
  666. </a>
  667. </div>
  668. }
  669. {/* {isVisible && */}
  670. <div style={{ display: isVisible ? 'block' : 'none', paddingTop: '20px' }}>
  671. {isVisibleCus &&
  672. <Space style={{ width: '100%' }} direction="vertical">
  673. <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
  674. <FormItem
  675. label='Top-p'
  676. name='topP'
  677. style={{ width: '300px' }}
  678. >
  679. <TopPDecimalStep />
  680. </FormItem>
  681. </div>
  682. <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
  683. <FormItem
  684. label='Temperature'
  685. name='temperature'
  686. style={{ width: '300px' }}
  687. >
  688. <TempDecimalStep />
  689. </FormItem>
  690. </div>
  691. </Space >
  692. }
  693. <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
  694. <FormItem
  695. label='回答风格'
  696. name='param_desc'
  697. rules={[{ required: true, message: '回答风格不能为空' }]}>
  698. <Radio.Group buttonStyle="solid"
  699. className='questionAnswerInfo-content-title'>
  700. <Radio.Button onClick={() => {
  701. handleRedioClick('strict')
  702. }} value='strict'>严谨</Radio.Button>
  703. <Radio.Button onClick={() => {
  704. handleRedioClick('moderate')
  705. }} value='moderate'>适中</Radio.Button>
  706. <Radio.Button onClick={() => {
  707. handleRedioClick('flexib')
  708. }} value='flexib'>发散</Radio.Button>
  709. <Radio.Button value='custom'
  710. onClick={() => {
  711. setIsVisibleCus(!isVisibleCus);
  712. setTopPValue(0.1);
  713. setTempValue(0.01);
  714. }}
  715. >自定义
  716. </Radio.Button>
  717. </Radio.Group>
  718. </FormItem>
  719. </div>
  720. <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
  721. <FormItem
  722. label='展示引用知识'
  723. name='show_recall_result'
  724. className='questionAnswerInfo-content-title'>
  725. <Switch onChange={onChangeShow} />
  726. </FormItem>
  727. </div>
  728. <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
  729. <FormItem
  730. label='召回方式'
  731. name='recall_method'
  732. rules={[{ required: true, message: '召回方式不能为空' }]}>
  733. <Radio.Group
  734. style={style}
  735. onChange={onChangeRecallMethod}
  736. options={[
  737. { value: 'embedding', label: '向量化检索' },
  738. { value: 'keyword', label: '关键词检索' },
  739. { value: 'mixed', label: '混合检索' },
  740. ]}
  741. />
  742. </FormItem>
  743. </div>
  744. <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
  745. <div className='questionAnswerInfo-content-title'>重排方式</div>
  746. </div>
  747. <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
  748. <FormItem
  749. label='Rerank模型'
  750. name='rerank_status'
  751. valuePropName='checked'
  752. className='questionAnswerInfo-content-title'
  753. >
  754. <Switch onChange={onChangeModel} />
  755. </FormItem>
  756. </div>
  757. {isVisibleRerank &&
  758. <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
  759. <FormItem
  760. label='模型选择'
  761. name='rerank_model_name'
  762. >
  763. <Select
  764. style={{ width: '300px', height: '48px' }}
  765. placeholder='请选择模型'
  766. // defaultValue={'rerank'}
  767. >
  768. <Option value='rerank'>默认rerank模型</Option>
  769. </Select>
  770. </FormItem>
  771. </div>
  772. }
  773. <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
  774. <FormItem
  775. label='召回切片数量'
  776. name='slice_config_type'
  777. rules={[{ required: true, message: '召回方式不能为空' }]}>
  778. <Select
  779. style={{ width: '300px', height: '48px' }}
  780. placeholder='请选择'
  781. onChange={onChangeCount}>
  782. <Option value="fixed">手动设置</Option>
  783. <Option value="customized">自动设置</Option>
  784. </Select>
  785. </FormItem>
  786. </div>
  787. {isVisibleSlice &&
  788. <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
  789. <FormItem
  790. label='召回切片数'
  791. name='slice_count'
  792. rules={[{ required: true, message: '切片数不能为空' }]}>
  793. <InputNumber max={1024} changeOnWheel className='questionAnswerInfo-content-title' />
  794. </FormItem>
  795. </div>
  796. }
  797. <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
  798. <FormItem
  799. label='召回切片拼接方式'
  800. name='recall_slice_splicing_method'
  801. >
  802. <TextArea
  803. rows={4}
  804. className='questionAnswerInfo-content-title'
  805. placeholder="请输入内容"
  806. />
  807. </FormItem>
  808. </div>
  809. </div>
  810. {/* } */}
  811. </div>
  812. </div>
  813. </Splitter.Panel>
  814. </Splitter>
  815. </div>
  816. </Form>
  817. </Spin>
  818. </div >
  819. );
  820. };
  821. export default observer(QuestionAnswerInfo);