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:
balibabu
2024-06-06 11:01:14 +08:00
committed by GitHub
parent b6980d8a16
commit 72c6784ff8
22 changed files with 241 additions and 90 deletions

View File

@ -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);

View File

@ -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 = ({

View File

@ -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',

View File

@ -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 !== '';
};