feat: fetch flow (#1068)
### What problem does this PR solve? feat: fetch flow #918 feat: save graph ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@@ -8,11 +8,8 @@ import { IDialog } from '@/interfaces/database/chat';
|
||||
import { Divider, Flex, Form, Modal, Segmented, UploadFile } from 'antd';
|
||||
import { SegmentedValue } from 'antd/es/segmented';
|
||||
import camelCase from 'lodash/camelCase';
|
||||
import omit from 'lodash/omit';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { variableEnabledFieldMap } from '../constants';
|
||||
import { IPromptConfigParameters } from '../interface';
|
||||
import { excludeUnEnabledVariables } from '../utils';
|
||||
import AssistantSetting from './assistant-setting';
|
||||
import { useFetchLlmModelOnVisible, useFetchModelId } from './hooks';
|
||||
import ModelSetting from './model-setting';
|
||||
@@ -20,6 +17,7 @@ import PromptEngine from './prompt-engine';
|
||||
|
||||
import { useTranslate } from '@/hooks/commonHooks';
|
||||
import { getBase64FromUploadFileList } from '@/utils/fileUtil';
|
||||
import { removeUselessFieldsFromValues } from '@/utils/form';
|
||||
import styles from './index.less';
|
||||
|
||||
const layout = {
|
||||
@@ -76,11 +74,10 @@ const ChatConfigurationModal = ({
|
||||
|
||||
const handleOk = async () => {
|
||||
const values = await form.validateFields();
|
||||
const nextValues: any = omit(values, [
|
||||
...Object.keys(variableEnabledFieldMap),
|
||||
'parameters',
|
||||
...excludeUnEnabledVariables(values),
|
||||
]);
|
||||
const nextValues: any = removeUselessFieldsFromValues(
|
||||
values,
|
||||
'llm_setting.',
|
||||
);
|
||||
const emptyResponse = nextValues.prompt_config?.empty_response ?? '';
|
||||
|
||||
const icon = await getBase64FromUploadFileList(values.icon);
|
||||
|
||||
@@ -7,8 +7,8 @@ import { useEffect } from 'react';
|
||||
import { ISegmentedContentProps } from '../interface';
|
||||
|
||||
import LlmSettingItems from '@/components/llm-setting-items';
|
||||
import { variableEnabledFieldMap } from '@/constants/chat';
|
||||
import { Variable } from '@/interfaces/database/chat';
|
||||
import { variableEnabledFieldMap } from '../constants';
|
||||
import styles from './index.less';
|
||||
|
||||
const ModelSetting = ({
|
||||
|
||||
@@ -1,11 +1,3 @@
|
||||
export const variableEnabledFieldMap = {
|
||||
temperatureEnabled: 'temperature',
|
||||
topPEnabled: 'top_p',
|
||||
presencePenaltyEnabled: 'presence_penalty',
|
||||
frequencyPenaltyEnabled: 'frequency_penalty',
|
||||
maxTokensEnabled: 'max_tokens',
|
||||
};
|
||||
|
||||
export enum ChatSearchParams {
|
||||
DialogId = 'dialogId',
|
||||
ConversationId = 'conversationId',
|
||||
|
||||
@@ -1,19 +1,8 @@
|
||||
import { MessageType } from '@/constants/chat';
|
||||
import { IConversation, IReference } from '@/interfaces/database/chat';
|
||||
import { EmptyConversationId, variableEnabledFieldMap } from './constants';
|
||||
import { EmptyConversationId } from './constants';
|
||||
import { IClientConversation, IMessage } from './interface';
|
||||
|
||||
export const excludeUnEnabledVariables = (values: any) => {
|
||||
const unEnabledFields: Array<keyof typeof variableEnabledFieldMap> =
|
||||
Object.keys(variableEnabledFieldMap).filter((key) => !values[key]) as Array<
|
||||
keyof typeof variableEnabledFieldMap
|
||||
>;
|
||||
|
||||
return unEnabledFields.map(
|
||||
(key) => `llm_setting.${variableEnabledFieldMap[key]}`,
|
||||
);
|
||||
};
|
||||
|
||||
export const isConversationIdExist = (conversationId: string) => {
|
||||
return conversationId !== EmptyConversationId && conversationId !== '';
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user