diff --git a/web/package.json b/web/package.json
index ca6470af1..ac594303c 100644
--- a/web/package.json
+++ b/web/package.json
@@ -1,6 +1,6 @@
{
"private": true,
- "author": "zhaofengchao <13723060510@163.com>",
+ "author": "bill",
"scripts": {
"build": "umi build",
"dev": "cross-env UMI_DEV_SERVER_COMPRESS=none umi dev",
diff --git a/web/src/components/similarity-slider/index.tsx b/web/src/components/similarity-slider/index.tsx
index 588b83451..e29a07991 100644
--- a/web/src/components/similarity-slider/index.tsx
+++ b/web/src/components/similarity-slider/index.tsx
@@ -3,14 +3,18 @@ import { Form, Slider } from 'antd';
type FieldType = {
similarity_threshold?: number;
- vector_similarity_weight?: number;
+ // vector_similarity_weight?: number;
};
interface IProps {
isTooltipShown?: boolean;
+ vectorSimilarityWeightName?: string;
}
-const SimilaritySlider = ({ isTooltipShown = false }: IProps) => {
+const SimilaritySlider = ({
+ isTooltipShown = false,
+ vectorSimilarityWeightName = 'vector_similarity_weight',
+}: IProps) => {
const { t } = useTranslate('knowledgeDetails');
return (
@@ -23,9 +27,9 @@ const SimilaritySlider = ({ isTooltipShown = false }: IProps) => {
>
-
+
diff --git a/web/src/constants/chat.ts b/web/src/constants/chat.ts
index 2ce95b56a..aa6e89aa9 100644
--- a/web/src/constants/chat.ts
+++ b/web/src/constants/chat.ts
@@ -2,3 +2,11 @@ export enum MessageType {
Assistant = 'assistant',
User = 'user',
}
+
+export const variableEnabledFieldMap = {
+ temperatureEnabled: 'temperature',
+ topPEnabled: 'top_p',
+ presencePenaltyEnabled: 'presence_penalty',
+ frequencyPenaltyEnabled: 'frequency_penalty',
+ maxTokensEnabled: 'max_tokens',
+};
diff --git a/web/src/hooks/flow-hooks.ts b/web/src/hooks/flow-hooks.ts
index 64007b118..9fb3cfe70 100644
--- a/web/src/hooks/flow-hooks.ts
+++ b/web/src/hooks/flow-hooks.ts
@@ -1,5 +1,9 @@
+import { DSL, IFlow } from '@/interfaces/database/flow';
+import i18n from '@/locales/config';
import flowService from '@/services/flow-service';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
+import { message } from 'antd';
+import { useParams } from 'umi';
export const useFetchFlowTemplates = () => {
const { data } = useQuery({
@@ -15,7 +19,7 @@ export const useFetchFlowTemplates = () => {
return data;
};
-export const useFetchFlowList = () => {
+export const useFetchFlowList = (): { data: IFlow[]; loading: boolean } => {
const { data, isFetching: loading } = useQuery({
queryKey: ['fetchFlowList'],
initialData: [],
@@ -29,6 +33,21 @@ export const useFetchFlowList = () => {
return { data, loading };
};
+export const useFetchFlow = (): { data: IFlow; loading: boolean } => {
+ const { id } = useParams();
+ const { data, isFetching: loading } = useQuery({
+ queryKey: ['flowDetail'],
+ initialData: {} as IFlow,
+ queryFn: async () => {
+ const { data } = await flowService.getCanvas({}, id);
+
+ return data?.data ?? {};
+ },
+ });
+
+ return { data, loading };
+};
+
export const useSetFlow = () => {
const queryClient = useQueryClient();
const {
@@ -37,9 +56,12 @@ export const useSetFlow = () => {
mutateAsync,
} = useMutation({
mutationKey: ['setFlow'],
- mutationFn: async (params: any) => {
+ mutationFn: async (params: { id?: string; title?: string; dsl?: DSL }) => {
const { data } = await flowService.setCanvas(params);
if (data.retcode === 0) {
+ message.success(
+ i18n.t(`message.${params?.id ? 'modified' : 'created'}`),
+ );
queryClient.invalidateQueries({ queryKey: ['fetchFlowList'] });
}
return data?.retcode;
diff --git a/web/src/interfaces/database/flow.ts b/web/src/interfaces/database/flow.ts
index 80d24eba6..b9d57b91d 100644
--- a/web/src/interfaces/database/flow.ts
+++ b/web/src/interfaces/database/flow.ts
@@ -1,10 +1,13 @@
+import { Edge, Node } from 'reactflow';
+
export type DSLComponents = Record;
export interface DSL {
components: DSLComponents;
- history: any[];
- path: string[];
- answer: any[];
+ history?: any[];
+ path?: string[];
+ answer?: any[];
+ graph?: IGraph;
}
export interface IOperator {
@@ -17,3 +20,28 @@ export interface IOperatorNode {
component_name: string;
params: Record;
}
+
+export interface IGraph {
+ nodes: Node[];
+ edges: Edge[];
+}
+
+export interface IFlow {
+ avatar: null;
+ canvas_type: null;
+ create_date: string;
+ create_time: number;
+ description: null;
+ dsl: {
+ answer: any[];
+ components: DSLComponents;
+ graph: IGraph;
+ history: any[];
+ path: string[];
+ };
+ id: string;
+ title: string;
+ update_date: string;
+ update_time: number;
+ user_id: string;
+}
diff --git a/web/src/pages/chat/chat-configuration-modal/index.tsx b/web/src/pages/chat/chat-configuration-modal/index.tsx
index 27effe309..d468c2bfd 100644
--- a/web/src/pages/chat/chat-configuration-modal/index.tsx
+++ b/web/src/pages/chat/chat-configuration-modal/index.tsx
@@ -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);
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 ca0f3c52b..df457e55f 100644
--- a/web/src/pages/chat/chat-configuration-modal/model-setting.tsx
+++ b/web/src/pages/chat/chat-configuration-modal/model-setting.tsx
@@ -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 = ({
diff --git a/web/src/pages/chat/constants.ts b/web/src/pages/chat/constants.ts
index 4c2c5ed83..0c93f8ddf 100644
--- a/web/src/pages/chat/constants.ts
+++ b/web/src/pages/chat/constants.ts
@@ -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',
diff --git a/web/src/pages/chat/utils.ts b/web/src/pages/chat/utils.ts
index 7518397c9..6501aeadd 100644
--- a/web/src/pages/chat/utils.ts
+++ b/web/src/pages/chat/utils.ts
@@ -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 =
- 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 !== '';
};
diff --git a/web/src/pages/flow/begin-form/index.tsx b/web/src/pages/flow/begin-form/index.tsx
index 125d31e2f..9cd8be021 100644
--- a/web/src/pages/flow/begin-form/index.tsx
+++ b/web/src/pages/flow/begin-form/index.tsx
@@ -15,9 +15,8 @@ const onFinishFailed: FormProps['onFinishFailed'] = (errorInfo) => {
console.log('Failed:', errorInfo);
};
-const BeginForm = ({ onValuesChange }: IOperatorForm) => {
+const BeginForm = ({ onValuesChange, form }: IOperatorForm) => {
const { t } = useTranslate('chat');
- const [form] = Form.useForm();
return (