feat: add chat history and session

This commit is contained in:
2024-10-01 00:46:26 +08:00
parent 441b94a061
commit 7d4e6bd299
25 changed files with 1133 additions and 221 deletions

View File

@@ -0,0 +1,39 @@
import { query } from '@/modules';
import { Select as AntSelect, message, SelectProps } from 'antd';
import { useEffect, useState } from 'react';
export const Select = (props: SelectProps) => {
const [options, setOptions] = useState<{ value: string; id: string }[]>([]);
useEffect(() => {
fetch();
}, []);
const fetch = async () => {
const res = await query.post({
path: 'prompt',
key: 'list',
});
if (res.code !== 200) {
message.error(res.message || '获取agent列表失败');
return;
}
const data = res.data || [];
setOptions(
data.map((item: any) => {
return {
label: item.key,
value: item.id,
};
}),
);
};
return (
<AntSelect
{...props}
options={options}
// onChange={(e) => {
// const labelValue = options.find((item) => item.value === e);
// props.onChange?.(e, options);
// }}
/>
);
};