diff --git a/web/src/assets/svg/chat-app-cube.svg b/web/src/assets/svg/chat-app-cube.svg new file mode 100644 index 000000000..f43fdcf5e --- /dev/null +++ b/web/src/assets/svg/chat-app-cube.svg @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/web/src/components/similarity-slider/index.tsx b/web/src/components/similarity-slider/index.tsx new file mode 100644 index 000000000..966ed212e --- /dev/null +++ b/web/src/components/similarity-slider/index.tsx @@ -0,0 +1,29 @@ +import { Form, Slider } from 'antd'; + +type FieldType = { + similarity_threshold?: number; + vector_similarity_weight?: number; +}; + +const SimilaritySlider = () => { + return ( + <> + + label="Similarity threshold" + name={'similarity_threshold'} + initialValue={0} + > + + + + label="Vector similarity weight" + name={'vector_similarity_weight'} + initialValue={0} + > + + + + ); +}; + +export default SimilaritySlider; diff --git a/web/src/constants/knowledge.ts b/web/src/constants/knowledge.ts index 06870f31a..3cb370af4 100644 --- a/web/src/constants/knowledge.ts +++ b/web/src/constants/knowledge.ts @@ -11,3 +11,40 @@ export enum RunningStatus { DONE = '3', // need to refresh FAIL = '4', // need to refresh } + +export enum ModelVariableType { + Improvise = 'Improvise', + Precise = 'Precise', + Balance = 'Balance', +} + +export const settledModelVariableMap = { + [ModelVariableType.Improvise]: { + temperature: 0.9, + top_p: 0.9, + frequency_penalty: 0.2, + presence_penalty: 0.4, + max_tokens: 512, + }, + [ModelVariableType.Precise]: { + temperature: 0.1, + top_p: 0.3, + frequency_penalty: 0.7, + presence_penalty: 0.4, + max_tokens: 215, + }, + [ModelVariableType.Balance]: { + temperature: 0.5, + top_p: 0.5, + frequency_penalty: 0.7, + presence_penalty: 0.4, + max_tokens: 215, + }, +}; + +export enum LlmModelType { + Embedding = 'embedding', + Chat = 'chat', + Image2text = 'image2text', + Speech2text = 'speech2text', +} diff --git a/web/src/hooks/knowledgeHook.ts b/web/src/hooks/knowledgeHook.ts index c9a4b7316..ba090d976 100644 --- a/web/src/hooks/knowledgeHook.ts +++ b/web/src/hooks/knowledgeHook.ts @@ -124,3 +124,22 @@ export const useFetchKnowledgeBaseConfiguration = () => { fetchKnowledgeBaseConfiguration(); }, [fetchKnowledgeBaseConfiguration]); }; + +export const useFetchKnowledgeList = (): IKnowledge[] => { + const dispatch = useDispatch(); + + const knowledgeModel = useSelector((state: any) => state.knowledgeModel); + const { data = [] } = knowledgeModel; + + const fetchList = useCallback(() => { + dispatch({ + type: 'knowledgeModel/getList', + }); + }, [dispatch]); + + useEffect(() => { + fetchList(); + }, [fetchList]); + + return data; +}; diff --git a/web/src/hooks/llmHooks.ts b/web/src/hooks/llmHooks.ts new file mode 100644 index 000000000..4ff363969 --- /dev/null +++ b/web/src/hooks/llmHooks.ts @@ -0,0 +1,39 @@ +import { LlmModelType } from '@/constants/knowledge'; +import { IThirdOAIModelCollection } from '@/interfaces/database/llm'; +import { useCallback, useEffect, useMemo } from 'react'; +import { useDispatch, useSelector } from 'umi'; + +export const useFetchLlmList = (modelType: LlmModelType) => { + const dispatch = useDispatch(); + + const fetchLlmList = useCallback(() => { + dispatch({ + type: 'settingModel/llm_list', + payload: { model_type: modelType }, + }); + }, [dispatch, modelType]); + + useEffect(() => { + fetchLlmList(); + }, [fetchLlmList]); +}; + +export const useSelectLlmOptions = () => { + const llmInfo: IThirdOAIModelCollection = useSelector( + (state: any) => state.settingModel.llmInfo, + ); + + const embeddingModelOptions = useMemo(() => { + return Object.entries(llmInfo).map(([key, value]) => { + return { + label: key, + options: value.map((x) => ({ + label: x.llm_name, + value: x.llm_name, + })), + }; + }); + }, [llmInfo]); + + return embeddingModelOptions; +}; diff --git a/web/src/interfaces/database/chat.ts b/web/src/interfaces/database/chat.ts new file mode 100644 index 000000000..6aec10a5d --- /dev/null +++ b/web/src/interfaces/database/chat.ts @@ -0,0 +1,47 @@ +export interface PromptConfig { + empty_response: string; + parameters: Parameter[]; + prologue: string; + system: string; +} + +export interface Parameter { + key: string; + optional: boolean; +} + +export interface LlmSetting { + Creative: Variable; + Custom: Variable; + Evenly: Variable; + Precise: Variable; +} + +export interface Variable { + frequency_penalty: number; + max_tokens: number; + presence_penalty: number; + temperature: number; + top_p: number; +} + +export interface IDialog { + create_date: string; + create_time: number; + description: string; + icon: string; + id: string; + kb_ids: string[]; + kb_names: string[]; + language: string; + llm_id: string; + llm_setting: LlmSetting; + llm_setting_type: string; + name: string; + prompt_config: PromptConfig; + prompt_type: string; + status: string; + tenant_id: string; + update_date: string; + update_time: number; +} diff --git a/web/src/pages/add-knowledge/components/knowledge-file/rename-modal/index.tsx b/web/src/pages/add-knowledge/components/knowledge-file/rename-modal/index.tsx index 19cff26d3..13109e619 100644 --- a/web/src/pages/add-knowledge/components/knowledge-file/rename-modal/index.tsx +++ b/web/src/pages/add-knowledge/components/knowledge-file/rename-modal/index.tsx @@ -53,7 +53,7 @@ const RenameModal = () => { useEffect(() => { form.setFieldValue('name', initialName); - }, [initialName, documentId]); + }, [initialName, documentId, form]); return ( { const knowledgeBaseId = useKnowledgeBaseId(); const loading = useOneNamespaceEffectsLoading('kSModel', ['updateKb']); - const llmInfo: IThirdOAIModelCollection = useSelector( - (state: any) => state.settingModel.llmInfo, - ); const knowledgeDetails: IKnowledge = useSelector( (state: any) => state.kSModel.knowledgeDetails, ); @@ -51,17 +49,7 @@ const Configuration = () => { const parserList = useSelectParserList(); - const embeddingModelOptions = useMemo(() => { - return Object.entries(llmInfo).map(([key, value]) => { - return { - label: key, - options: value.map((x) => ({ - label: x.llm_name, - value: x.llm_name, - })), - }; - }); - }, [llmInfo]); + const embeddingModelOptions = useSelectLlmOptions(); const onFinish = async (values: any) => { console.info(values); @@ -86,13 +74,6 @@ const Configuration = () => { console.log('Failed:', errorInfo); }; - const fetchLlmList = useCallback(() => { - dispatch({ - type: 'settingModel/llm_list', - payload: { model_type: 'embedding' }, - }); - }, [dispatch]); - useEffect(() => { const avatar = knowledgeDetails.avatar; let fileList: UploadFile[] = []; @@ -115,9 +96,7 @@ const Configuration = () => { useFetchParserList(); useFetchKnowledgeBaseConfiguration(); - useEffect(() => { - fetchLlmList(); - }, [fetchLlmList]); + useFetchLlmList(LlmModelType.Embedding); return (
diff --git a/web/src/pages/add-knowledge/components/knowledge-testing/index.tsx b/web/src/pages/add-knowledge/components/knowledge-testing/index.tsx index e3dd8625f..4b449f252 100644 --- a/web/src/pages/add-knowledge/components/knowledge-testing/index.tsx +++ b/web/src/pages/add-knowledge/components/knowledge-testing/index.tsx @@ -16,14 +16,10 @@ const KnowledgeTesting = () => { const handleTesting = async () => { const values = await form.validateFields(); console.info(values); - const similarity_threshold = values.similarity_threshold / 100; - const vector_similarity_weight = values.vector_similarity_weight / 100; dispatch({ type: 'testingModel/testDocumentChunk', payload: { ...values, - similarity_threshold, - vector_similarity_weight, kb_id: knowledgeBaseId, }, }); diff --git a/web/src/pages/add-knowledge/components/knowledge-testing/testing-control/index.tsx b/web/src/pages/add-knowledge/components/knowledge-testing/testing-control/index.tsx index 376feffb7..208a33bb6 100644 --- a/web/src/pages/add-knowledge/components/knowledge-testing/testing-control/index.tsx +++ b/web/src/pages/add-knowledge/components/knowledge-testing/testing-control/index.tsx @@ -1,3 +1,5 @@ +import SimilaritySlider from '@/components/similarity-slider'; +import { DeleteOutlined, HistoryOutlined } from '@ant-design/icons'; import { Button, Card, @@ -6,22 +8,15 @@ import { Form, Input, Slider, - SliderSingleProps, Space, Tag, } from 'antd'; - -import { DeleteOutlined, HistoryOutlined } from '@ant-design/icons'; import { FormInstance } from 'antd/lib'; + import styles from './index.less'; const list = [1, 2, 3]; -const marks: SliderSingleProps['marks'] = { - 0: '0', - 100: '1', -}; - type FieldType = { similarity_threshold?: number; vector_similarity_weight?: number; @@ -29,12 +24,6 @@ type FieldType = { question: string; }; -const formatter = (value: number | undefined) => { - return typeof value === 'number' ? value / 100 : 0; -}; - -const tooltip = { formatter }; - interface IProps { form: FormInstance; handleTesting: () => Promise; @@ -59,23 +48,12 @@ const TestingControl = ({ form, handleTesting }: IProps) => { layout="vertical" form={form} initialValues={{ - similarity_threshold: 20, - vector_similarity_weight: 30, + similarity_threshold: 0.2, + vector_similarity_weight: 0.3, top_k: 1024, }} > - - label="Similarity threshold" - name={'similarity_threshold'} - > - - - - label="Vector similarity weight" - name={'vector_similarity_weight'} - > - - + label="Top k" name={'top_k'}> diff --git a/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx b/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx index 4623c6ad7..968d277b2 100644 --- a/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx +++ b/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx @@ -1,11 +1,20 @@ -import { Form, Input } from 'antd'; +import { Form, Input, Select } from 'antd'; import classNames from 'classnames'; import { ISegmentedContentProps } from './interface'; +import { useFetchKnowledgeList } from '@/hooks/knowledgeHook'; import styles from './index.less'; +const { Option } = Select; + const AssistantSetting = ({ show }: ISegmentedContentProps) => { + const knowledgeList = useFetchKnowledgeList(); + const knowledgeOptions = knowledgeList.map((x) => ({ + label: x.name, + value: x.id, + })); + return (
{ > - + - - + + + + + + +
); }; diff --git a/web/src/pages/chat/chat-configuration-modal/constants.ts b/web/src/pages/chat/chat-configuration-modal/constants.ts new file mode 100644 index 000000000..640ad6f88 --- /dev/null +++ b/web/src/pages/chat/chat-configuration-modal/constants.ts @@ -0,0 +1,7 @@ +export const variableEnabledFieldMap = { + temperatureEnabled: 'temperature', + topPEnabled: 'top_p', + presencePenaltyEnabled: 'presence_penalty', + frequencyPenaltyEnabled: 'frequency_penalty', + maxTokensEnabled: 'max_tokens', +}; diff --git a/web/src/pages/chat/chat-configuration-modal/index.less b/web/src/pages/chat/chat-configuration-modal/index.less index ab624287b..5da722d86 100644 --- a/web/src/pages/chat/chat-configuration-modal/index.less +++ b/web/src/pages/chat/chat-configuration-modal/index.less @@ -41,3 +41,10 @@ width: 0; margin: 0; } + +.sliderInputNumber { + width: 80px; +} +.variableSlider { + width: 100%; +} diff --git a/web/src/pages/chat/chat-configuration-modal/index.tsx b/web/src/pages/chat/chat-configuration-modal/index.tsx index 9c253febb..64943c953 100644 --- a/web/src/pages/chat/chat-configuration-modal/index.tsx +++ b/web/src/pages/chat/chat-configuration-modal/index.tsx @@ -2,17 +2,20 @@ import { ReactComponent as ChatConfigurationAtom } from '@/assets/svg/chat-confi import { IModalManagerChildrenProps } from '@/components/modal-manager'; import { Divider, Flex, Form, Modal, Segmented } from 'antd'; import { SegmentedValue } from 'antd/es/segmented'; -import { useState } from 'react'; +import omit from 'lodash/omit'; +import { useRef, useState } from 'react'; import AssistantSetting from './assistant-setting'; import ModelSetting from './model-setting'; import PromptEngine from './prompt-engine'; +import { useSetDialog } from '../hooks'; +import { variableEnabledFieldMap } from './constants'; import styles from './index.less'; enum ConfigurationSegmented { AssistantSetting = 'Assistant Setting', - ModelSetting = 'Model Setting', PromptEngine = 'Prompt Engine', + ModelSetting = 'Model Setting', } const segmentedMap = { @@ -45,10 +48,24 @@ const ChatConfigurationModal = ({ const [value, setValue] = useState( ConfigurationSegmented.AssistantSetting, ); + const promptEngineRef = useRef(null); + + const setDialog = useSetDialog(); const handleOk = async () => { - const x = await form.validateFields(); - console.info(x); + const values = await form.validateFields(); + const nextValues: any = omit(values, Object.keys(variableEnabledFieldMap)); + const finalValues = { + ...nextValues, + prompt_config: { + ...nextValues.prompt_config, + parameters: promptEngineRef.current, + }, + }; + console.info(promptEngineRef.current); + console.info(nextValues); + console.info(finalValues); + setDialog(finalValues); }; const handleCancel = () => { @@ -97,7 +114,14 @@ const ChatConfigurationModal = ({ colon={false} > {Object.entries(segmentedMap).map(([key, Element]) => ( - + ))} diff --git a/web/src/pages/chat/chat-configuration-modal/interface.ts b/web/src/pages/chat/chat-configuration-modal/interface.ts index af3ab9625..55b67c3b1 100644 --- a/web/src/pages/chat/chat-configuration-modal/interface.ts +++ b/web/src/pages/chat/chat-configuration-modal/interface.ts @@ -1,3 +1,14 @@ +import { FormInstance } from 'antd'; + export interface ISegmentedContentProps { show: boolean; + form: FormInstance; +} + +export interface IVariable { + temperature: number; + top_p: number; + frequency_penalty: number; + presence_penalty: number; + max_tokens: number; } diff --git a/web/src/pages/chat/chat-configuration-modal/model-setting.tsx b/web/src/pages/chat/chat-configuration-modal/model-setting.tsx index 5f76e4ad8..1c421fcd0 100644 --- a/web/src/pages/chat/chat-configuration-modal/model-setting.tsx +++ b/web/src/pages/chat/chat-configuration-modal/model-setting.tsx @@ -1,12 +1,48 @@ -import { Divider, Flex, Form, InputNumber, Select, Slider } from 'antd'; +import { + LlmModelType, + ModelVariableType, + settledModelVariableMap, +} from '@/constants/knowledge'; +import { Divider, Flex, Form, InputNumber, Select, Slider, Switch } from 'antd'; import classNames from 'classnames'; +import { useEffect } from 'react'; import { ISegmentedContentProps } from './interface'; +import { useFetchLlmList, useSelectLlmOptions } from '@/hooks/llmHooks'; +import { variableEnabledFieldMap } from './constants'; import styles from './index.less'; -const { Option } = Select; +const ModelSetting = ({ show, form }: ISegmentedContentProps) => { + const parameterOptions = Object.values(ModelVariableType).map((x) => ({ + label: x, + value: x, + })); + + const parameters: ModelVariableType = Form.useWatch('parameters', form); + + const modelOptions = useSelectLlmOptions(); + + const handleParametersChange = (value: ModelVariableType) => { + console.info(value); + }; + + useEffect(() => { + const variable = settledModelVariableMap[parameters]; + form.setFieldsValue({ llm_setting: variable }); + }, [parameters, form]); + + useEffect(() => { + const values = Object.keys(variableEnabledFieldMap).reduce< + Record + >((pre, field) => { + pre[field] = true; + return pre; + }, {}); + form.setFieldsValue(values); + }, [form]); + + useFetchLlmList(LlmModelType.Chat); -const ModelSetting = ({ show }: ISegmentedContentProps) => { return (
{ > - - - - - - -
); }; -export default PromptEngine; +export default forwardRef(PromptEngine); diff --git a/web/src/pages/chat/hooks.ts b/web/src/pages/chat/hooks.ts new file mode 100644 index 000000000..588f63a92 --- /dev/null +++ b/web/src/pages/chat/hooks.ts @@ -0,0 +1,29 @@ +import { IDialog } from '@/interfaces/database/chat'; +import { useCallback, useEffect } from 'react'; +import { useDispatch, useSelector } from 'umi'; + +export const useFetchDialogList = () => { + const dispatch = useDispatch(); + const dialogList: IDialog[] = useSelector( + (state: any) => state.chatModel.dialogList, + ); + + useEffect(() => { + dispatch({ type: 'chatModel/listDialog' }); + }, [dispatch]); + + return dialogList; +}; + +export const useSetDialog = () => { + const dispatch = useDispatch(); + + const setDialog = useCallback( + (payload: IDialog) => { + dispatch({ type: 'chatModel/setDialog', payload }); + }, + [dispatch], + ); + + return setDialog; +}; diff --git a/web/src/pages/chat/index.less b/web/src/pages/chat/index.less index e0cb8555b..4400e7eee 100644 --- a/web/src/pages/chat/index.less +++ b/web/src/pages/chat/index.less @@ -4,6 +4,17 @@ .chatAppWrapper { width: 288px; padding: 26px; + + .chatAppCard { + :global(.ant-card-body) { + padding: 10px; + } + .cubeIcon { + &:hover { + cursor: pointer; + } + } + } } .chatTitleWrapper { width: 220px; diff --git a/web/src/pages/chat/index.tsx b/web/src/pages/chat/index.tsx index 898f8c322..f33bbd338 100644 --- a/web/src/pages/chat/index.tsx +++ b/web/src/pages/chat/index.tsx @@ -1,14 +1,73 @@ -import { FormOutlined } from '@ant-design/icons'; -import { Button, Card, Divider, Flex, Space, Tag } from 'antd'; -import { useSelector } from 'umi'; +import { DeleteOutlined, EditOutlined, FormOutlined } from '@ant-design/icons'; +import { + Button, + Card, + Divider, + Dropdown, + Flex, + MenuProps, + Space, + Tag, +} from 'antd'; import ChatContainer from './chat-container'; +import { ReactComponent as ChatAppCube } from '@/assets/svg/chat-app-cube.svg'; import ModalManager from '@/components/modal-manager'; +import classNames from 'classnames'; import ChatConfigurationModal from './chat-configuration-modal'; +import { useFetchDialogList } from './hooks'; + +import { useState } from 'react'; import styles from './index.less'; const Chat = () => { - const { name } = useSelector((state: any) => state.chatModel); + const dialogList = useFetchDialogList(); + const [activated, setActivated] = useState(''); + + const handleAppCardEnter = (id: string) => () => { + setActivated(id); + }; + + const handleAppCardLeave = () => { + setActivated(''); + }; + + const items: MenuProps['items'] = [ + { + key: '1', + label: ( + + 1st menu item + + ), + }, + ]; + + const appItems: MenuProps['items'] = [ + { + key: '1', + label: ( + + + Edit + + ), + }, + { type: 'divider' }, + { + key: '2', + label: ( + + + Delete chat + + ), + }, + ]; return ( @@ -32,9 +91,33 @@ const Chat = () => { - -

Card content

-
+ + {dialogList.map((x) => ( + + + + {x.icon} +
+ {x.name} +
{x.description}
+
+
+ {activated === x.id && ( +
+ + + +
+ )} +
+
+ ))} +
@@ -49,7 +132,9 @@ const Chat = () => { Chat 25 - + + +
today
diff --git a/web/src/pages/chat/model.ts b/web/src/pages/chat/model.ts index 6efdc52e3..dd5c5d322 100644 --- a/web/src/pages/chat/model.ts +++ b/web/src/pages/chat/model.ts @@ -1,13 +1,18 @@ +import { IDialog } from '@/interfaces/database/chat'; +import chatService from '@/services/chatService'; +import { message } from 'antd'; import { DvaModel } from 'umi'; export interface ChatModelState { name: string; + dialogList: IDialog[]; } const model: DvaModel = { namespace: 'chatModel', state: { name: 'kate', + dialogList: [], }, reducers: { save(state, action) { @@ -16,16 +21,41 @@ const model: DvaModel = { ...action.payload, }; }, - }, - subscriptions: { - setup({ dispatch, history }) { - return history.listen((query) => { - console.log(query); - }); + setDialogList(state, { payload }) { + return { + ...state, + dialogList: payload, + }; }, }, + effects: { - *query({ payload }, { call, put }) {}, + *getDialog({ payload }, { call, put }) { + const { data } = yield call(chatService.getDialog, payload); + }, + *setDialog({ payload }, { call, put }) { + const { data } = yield call(chatService.setDialog, payload); + if (data.retcode === 0) { + yield put({ type: 'listDialog' }); + message.success('Created successfully !'); + } + }, + *listDialog({ payload }, { call, put }) { + const { data } = yield call(chatService.listDialog, payload); + yield put({ type: 'setDialogList', payload: data.data }); + }, + *listConversation({ payload }, { call, put }) { + const { data } = yield call(chatService.listConversation, payload); + }, + *getConversation({ payload }, { call, put }) { + const { data } = yield call(chatService.getConversation, payload); + }, + *setConversation({ payload }, { call, put }) { + const { data } = yield call(chatService.setConversation, payload); + }, + *completeConversation({ payload }, { call, put }) { + const { data } = yield call(chatService.completeConversation, payload); + }, }, }; diff --git a/web/src/pages/knowledge/index.tsx b/web/src/pages/knowledge/index.tsx index 97a8f4235..02921b603 100644 --- a/web/src/pages/knowledge/index.tsx +++ b/web/src/pages/knowledge/index.tsx @@ -2,33 +2,14 @@ import { ReactComponent as FilterIcon } from '@/assets/filter.svg'; import ModalManager from '@/components/modal-manager'; import { PlusOutlined } from '@ant-design/icons'; import { Button, Flex, Space } from 'antd'; -import { useCallback, useEffect } from 'react'; -import { useDispatch, useNavigate, useSelector } from 'umi'; import KnowledgeCard from './knowledge-card'; import KnowledgeCreatingModal from './knowledge-creating-modal'; +import { useFetchKnowledgeList } from '@/hooks/knowledgeHook'; import styles from './index.less'; const Knowledge = () => { - const dispatch = useDispatch(); - const knowledgeModel = useSelector((state: any) => state.knowledgeModel); - const navigate = useNavigate(); - const { data = [] } = knowledgeModel; - - const fetchList = useCallback(() => { - dispatch({ - type: 'knowledgeModel/getList', - payload: {}, - }); - }, []); - - // const handleAddKnowledge = () => { - // navigate(`/knowledge/${KnowledgeRouteKey.Configuration}`); - // }; - - useEffect(() => { - fetchList(); - }, [fetchList]); + const data = useFetchKnowledgeList(); return (
diff --git a/web/src/pages/setting/List.tsx b/web/src/pages/setting/List.tsx index 35c8191db..b86a380df 100644 --- a/web/src/pages/setting/List.tsx +++ b/web/src/pages/setting/List.tsx @@ -37,7 +37,7 @@ const SettingList = () => { type: 'settingModel/my_llm', payload: {}, }); - }, []); + }, [dispatch]); return (
(methods, request); + +export default chatService; diff --git a/web/src/utils/api.ts b/web/src/utils/api.ts index d0afb1847..f813071cf 100644 --- a/web/src/utils/api.ts +++ b/web/src/utils/api.ts @@ -42,4 +42,14 @@ export default { document_create: `${api_host}/document/create`, document_run: `${api_host}/document/run`, document_change_parser: `${api_host}/document/change_parser`, + + setDialog: `${api_host}/dialog/set`, + getDialog: `${api_host}/dialog/get`, + listDialog: `${api_host}/dialog/list`, + + setConversation: `${api_host}/conversation/set`, + getConversation: `${api_host}/conversation/get`, + listConversation: `${api_host}/conversation/list`, + removeConversation: `${api_host}/conversation/rm`, + completeConversation: `${api_host}/conversation/completion`, }; diff --git a/web/src/utils/index.ts b/web/src/utils/index.ts index 2eec00f3d..f27890471 100644 --- a/web/src/utils/index.ts +++ b/web/src/utils/index.ts @@ -5,22 +5,23 @@ */ // import numeral from 'numeral'; -import JSEncrypt from 'jsencrypt'; import { Base64 } from 'js-base64'; +import JSEncrypt from 'jsencrypt'; export const getWidth = () => { return { width: window.innerWidth }; }; export const rsaPsw = (password: string) => { - const pub = "-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArq9XTUSeYr2+N1h3Afl/z8Dse/2yD0ZGrKwx+EEEcdsBLca9Ynmx3nIB5obmLlSfmskLpBo0UACBmB5rEjBp2Q2f3AG3Hjd4B+gNCG6BDaawuDlgANIhGnaTLrIqWrrcm4EMzJOnAOI1fgzJRsOOUEfaS318Eq9OVO3apEyCCt0lOQK6PuksduOjVxtltDav+guVAA068NrPYmRNabVKRNLJpL8w4D44sfth5RvZ3q9t+6RTArpEtc5sh5ChzvqPOzKGMXW83C95TxmXqpbK6olN4RevSfVjEAgCydH6HN6OhtOQEcnrU97r9H0iZOWwbw3pVrZiUkuRD1R56Wzs2wIDAQAB-----END PUBLIC KEY-----" - const encryptor = new JSEncrypt() + const pub = + '-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArq9XTUSeYr2+N1h3Afl/z8Dse/2yD0ZGrKwx+EEEcdsBLca9Ynmx3nIB5obmLlSfmskLpBo0UACBmB5rEjBp2Q2f3AG3Hjd4B+gNCG6BDaawuDlgANIhGnaTLrIqWrrcm4EMzJOnAOI1fgzJRsOOUEfaS318Eq9OVO3apEyCCt0lOQK6PuksduOjVxtltDav+guVAA068NrPYmRNabVKRNLJpL8w4D44sfth5RvZ3q9t+6RTArpEtc5sh5ChzvqPOzKGMXW83C95TxmXqpbK6olN4RevSfVjEAgCydH6HN6OhtOQEcnrU97r9H0iZOWwbw3pVrZiUkuRD1R56Wzs2wIDAQAB-----END PUBLIC KEY-----'; + const encryptor = new JSEncrypt(); - encryptor.setPublicKey(pub) + encryptor.setPublicKey(pub); - return encryptor.encrypt(Base64.encode(password)) -} + return encryptor.encrypt(Base64.encode(password)); +}; export default { getWidth, - rsaPsw + rsaPsw, };