mirror of
https://github.com/labring/FastGPT.git
synced 2026-05-06 01:02:54 +08:00
3f4400a500
* feat: model config with brand-new price calculate machanism (#6616) * fix: image read and json error (Agent) (#6502) * fix: 1.image read 2.JSON parsing error * dataset cite and pause * perf: plancall second parse * add test --------- Co-authored-by: archer <545436317@qq.com> * master message * remove invalid code * wip: model config * feat: model config with brand-new price calculate machanism * merge main branch * ajust calculate way * ajust priceTiers resolve procession * perf: price config code * fix: default price * fix: test * fix: comment * fix test --------- Co-authored-by: YeYuheng <57035043+YYH211@users.noreply.github.com> Co-authored-by: archer <545436317@qq.com> * wip: fix modal UI (#6634) * wip: fix modal UI * fix: maxInputToken set * chore: add price unit for non llm models * chore: replace question mark icon with beta tag (#6672) * feat:rerank too long; fix:rerank ui(agent),embedding returns 0 (#6663) * feat:rerank too long; fix:rerank ui(agent),embedding returns 0 * rerank * fix:rerank function * perf: rerank code * fix rerank * perf: model price ui --------- Co-authored-by: archer <545436317@qq.com> * remove llmtype field * revert model init * fix: filed * fix: model select filter * perf: multiple selector render * remove invalid checker * remove invalid i18n * perf: model selector tip * perf: model selector tip * fix cr * limit pnpm version * fix: i18n * fix action * set default mintoken * update i18n * perf: usage push * fix:rerank model ui (#6677) * fix: tier match error * fix: testr --------- Co-authored-by: Ryo <whoeverimf5@gmail.com> Co-authored-by: YeYuheng <57035043+YYH211@users.noreply.github.com>
139 lines
3.0 KiB
TypeScript
139 lines
3.0 KiB
TypeScript
import React, { useMemo } from 'react';
|
|
import {
|
|
Modal,
|
|
ModalOverlay,
|
|
ModalContent,
|
|
ModalCloseButton,
|
|
type ModalContentProps,
|
|
Box,
|
|
type ImageProps,
|
|
Flex
|
|
} from '@chakra-ui/react';
|
|
import MyBox from '../../../common/MyBox';
|
|
import { useSystem } from '../../../../hooks/useSystem';
|
|
import Avatar from '../../../common/Avatar';
|
|
|
|
export interface MyModalProps extends ModalContentProps {
|
|
iconSrc?: string;
|
|
iconColor?: ImageProps['color'];
|
|
title?: any;
|
|
contentPx?: ModalContentProps['px'];
|
|
contentPy?: ModalContentProps['py'];
|
|
headerPx?: ModalContentProps['px'];
|
|
isCentered?: boolean;
|
|
isLoading?: boolean;
|
|
isOpen?: boolean;
|
|
onClose?: () => void;
|
|
closeOnOverlayClick?: boolean;
|
|
size?: 'sm' | 'md' | 'lg';
|
|
showCloseButton?: boolean;
|
|
}
|
|
|
|
const MyModal = ({
|
|
isOpen = true,
|
|
onClose,
|
|
iconSrc,
|
|
title,
|
|
children,
|
|
isCentered,
|
|
isLoading,
|
|
closeOnOverlayClick = true,
|
|
iconColor,
|
|
size = 'sm',
|
|
showCloseButton = true,
|
|
contentPx = '8',
|
|
contentPy = '8',
|
|
headerPx,
|
|
...props
|
|
}: MyModalProps) => {
|
|
const { isPc } = useSystem();
|
|
|
|
const sizeData = useMemo(() => {
|
|
const map = {
|
|
sm: {
|
|
w: '400px'
|
|
},
|
|
md: {
|
|
w: '560px'
|
|
},
|
|
lg: {
|
|
w: '800px'
|
|
}
|
|
};
|
|
return map[size];
|
|
}, [size]);
|
|
|
|
return (
|
|
<Modal
|
|
isOpen={isOpen}
|
|
onClose={() => onClose?.()}
|
|
size={size}
|
|
autoFocus={false}
|
|
isCentered={isPc ? isCentered : true}
|
|
blockScrollOnMount={false}
|
|
allowPinchZoom
|
|
scrollBehavior={'inside'}
|
|
closeOnOverlayClick={closeOnOverlayClick}
|
|
returnFocusOnClose={false}
|
|
>
|
|
<ModalOverlay zIndex={props.zIndex} />
|
|
<ModalContent
|
|
w={sizeData.w}
|
|
maxW={'90vw'}
|
|
position={'relative'}
|
|
maxH={'80vh'}
|
|
boxShadow={'3.5'}
|
|
px={contentPx}
|
|
py={contentPy}
|
|
containerProps={{
|
|
zIndex: props.zIndex
|
|
}}
|
|
{...props}
|
|
>
|
|
{onClose && <ModalCloseButton position={'absolute'} fontSize={'xs'} top={3} right={3} />}
|
|
|
|
{!!title && (
|
|
<Flex
|
|
alignItems={'center'}
|
|
fontSize={'lg'}
|
|
fontWeight={'500'}
|
|
mb={6}
|
|
py={0}
|
|
px={headerPx ?? contentPx}
|
|
gap={3}
|
|
>
|
|
{iconSrc && (
|
|
<>
|
|
<Avatar
|
|
color={iconColor}
|
|
objectFit={'contain'}
|
|
alt=""
|
|
src={iconSrc}
|
|
w={'20px'}
|
|
borderRadius={'sm'}
|
|
/>
|
|
</>
|
|
)}
|
|
<Box color="black" fontWeight={'500'}>
|
|
{title}
|
|
</Box>
|
|
<Box flex={1} />
|
|
</Flex>
|
|
)}
|
|
|
|
<MyBox
|
|
isLoading={isLoading}
|
|
overflow={props.overflow || 'overlay'}
|
|
h={'100%'}
|
|
display={'flex'}
|
|
flexDirection={'column'}
|
|
>
|
|
{children}
|
|
</MyBox>
|
|
</ModalContent>
|
|
</Modal>
|
|
);
|
|
};
|
|
|
|
export default React.memo(MyModal);
|