feat: fetch conversation and delete chat dialog (#69)

* feat: set chat configuration to backend

* feat: exclude unEnabled variables

* feat: delete chat dialog

* feat: fetch conversation
This commit is contained in:
balibabu
2024-02-22 17:14:25 +08:00
committed by GitHub
parent cacd36c5e1
commit 5a0f1d2b84
22 changed files with 784 additions and 116 deletions

View File

@ -21,17 +21,16 @@ import {
useState,
} from 'react';
import { v4 as uuid } from 'uuid';
import {
VariableTableDataType as DataType,
IPromptConfigParameters,
ISegmentedContentProps,
} from '../interface';
import { EditableCell, EditableRow } from './editable-cell';
import { ISegmentedContentProps } from './interface';
import { useSelectPromptConfigParameters } from '../hooks';
import styles from './index.less';
interface DataType {
key: string;
variable: string;
optional: boolean;
}
type FieldType = {
similarity_threshold?: number;
vector_similarity_weight?: number;
@ -39,10 +38,11 @@ type FieldType = {
};
const PromptEngine = (
{ show, form }: ISegmentedContentProps,
ref: ForwardedRef<Array<Omit<DataType, 'variable'>>>,
{ show }: ISegmentedContentProps,
ref: ForwardedRef<Array<IPromptConfigParameters>>,
) => {
const [dataSource, setDataSource] = useState<DataType[]>([]);
const parameters = useSelectPromptConfigParameters();
const components = {
body: {
@ -99,12 +99,6 @@ const PromptEngine = (
[dataSource],
);
useEffect(() => {
form.setFieldValue(['prompt_config', 'parameters'], dataSource);
const x = form.getFieldValue(['prompt_config', 'parameters']);
console.info(x);
}, [dataSource, form]);
const columns: TableProps<DataType>['columns'] = [
{
title: 'key',
@ -146,6 +140,10 @@ const PromptEngine = (
},
];
useEffect(() => {
setDataSource(parameters);
}, [parameters]);
return (
<section
className={classNames({
@ -153,7 +151,7 @@ const PromptEngine = (
})}
>
<Form.Item
label="Orchestrate"
label="System"
rules={[{ required: true, message: 'Please input!' }]}
name={['prompt_config', 'system']}
initialValue={`你是一个智能助手,请总结知识库的内容来回答问题,请列举知识库中的数据详细回答。当所有知识库内容都与问题无关时,你的回答必须包括“知识库中未找到您要的答案!”这句话。回答需要考虑聊天历史。
@ -161,7 +159,7 @@ const PromptEngine = (
{knowledge}
以上是知识库。`}
>
<Input.TextArea autoSize={{ maxRows: 5, minRows: 5 }} />
<Input.TextArea autoSize={{ maxRows: 8, minRows: 5 }} />
</Form.Item>
<Divider></Divider>
<SimilaritySlider></SimilaritySlider>