### What problem does this PR solve? Feat: Combine Select and LlmSettingFieldItems into LLMSelect. #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)tags/v0.17.1
| import { LlmModelType } from '@/constants/knowledge'; | import { LlmModelType } from '@/constants/knowledge'; | ||||
| import { useComposeLlmOptionsByModelTypes } from '@/hooks/llm-hooks'; | import { useComposeLlmOptionsByModelTypes } from '@/hooks/llm-hooks'; | ||||
| import * as SelectPrimitive from '@radix-ui/react-select'; | |||||
| import { Popover as AntPopover, Select as AntSelect } from 'antd'; | import { Popover as AntPopover, Select as AntSelect } from 'antd'; | ||||
| import { useState } from 'react'; | |||||
| import { forwardRef, useState } from 'react'; | |||||
| import LlmSettingItems from '../llm-setting-items'; | import LlmSettingItems from '../llm-setting-items'; | ||||
| import { LlmSettingFieldItems } from '../llm-setting-items/next'; | |||||
| import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover'; | import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover'; | ||||
| import { Select, SelectTrigger, SelectValue } from '../ui/select'; | import { Select, SelectTrigger, SelectValue } from '../ui/select'; | ||||
| export default LLMSelect; | export default LLMSelect; | ||||
| export function NextLLMSelect({ value, onChange, disabled }: IProps) { | |||||
| export const NextLLMSelect = forwardRef< | |||||
| React.ElementRef<typeof SelectPrimitive.Trigger>, | |||||
| IProps | |||||
| >(({ value, disabled }, ref) => { | |||||
| const [isPopoverOpen, setIsPopoverOpen] = useState(false); | const [isPopoverOpen, setIsPopoverOpen] = useState(false); | ||||
| const modelOptions = useComposeLlmOptionsByModelTypes([ | |||||
| LlmModelType.Chat, | |||||
| LlmModelType.Image2text, | |||||
| ]); | |||||
| return ( | return ( | ||||
| <Select value={value} onValueChange={onChange} disabled={disabled}> | |||||
| <Select disabled={disabled} value={value}> | |||||
| <Popover open={isPopoverOpen} onOpenChange={setIsPopoverOpen}> | <Popover open={isPopoverOpen} onOpenChange={setIsPopoverOpen}> | ||||
| <PopoverTrigger asChild> | <PopoverTrigger asChild> | ||||
| <SelectTrigger | <SelectTrigger | ||||
| e.preventDefault(); | e.preventDefault(); | ||||
| setIsPopoverOpen(true); | setIsPopoverOpen(true); | ||||
| }} | }} | ||||
| ref={ref} | |||||
| > | > | ||||
| <SelectValue placeholder="xxx" /> | |||||
| <SelectValue> | |||||
| { | |||||
| modelOptions | |||||
| .flatMap((x) => x.options) | |||||
| .find((x) => x.value === value)?.label | |||||
| } | |||||
| </SelectValue> | |||||
| </SelectTrigger> | </SelectTrigger> | ||||
| </PopoverTrigger> | </PopoverTrigger> | ||||
| <PopoverContent side={'left'}> | <PopoverContent side={'left'}> | ||||
| <LlmSettingItems | |||||
| formItemLayout={{ | |||||
| labelCol: { span: 10 }, | |||||
| wrapperCol: { span: 14 }, | |||||
| }} | |||||
| ></LlmSettingItems> | |||||
| <LlmSettingFieldItems></LlmSettingFieldItems> | |||||
| </PopoverContent> | </PopoverContent> | ||||
| </Popover> | </Popover> | ||||
| </Select> | </Select> | ||||
| ); | ); | ||||
| } | |||||
| }); | |||||
| NextLLMSelect.displayName = 'LLMSelect'; |
| import { Input } from '@/components/ui/input'; | import { Input } from '@/components/ui/input'; | ||||
| import { Sheet, SheetContent, SheetHeader } from '@/components/ui/sheet'; | |||||
| import { | |||||
| Sheet, | |||||
| SheetContent, | |||||
| SheetHeader, | |||||
| SheetTitle, | |||||
| } from '@/components/ui/sheet'; | |||||
| import { useTranslate } from '@/hooks/common-hooks'; | import { useTranslate } from '@/hooks/common-hooks'; | ||||
| import { IModalProps } from '@/interfaces/common'; | import { IModalProps } from '@/interfaces/common'; | ||||
| import { RAGFlowNodeType } from '@/interfaces/database/flow'; | import { RAGFlowNodeType } from '@/interfaces/database/flow'; | ||||
| return ( | return ( | ||||
| <Sheet open={visible} modal={false}> | <Sheet open={visible} modal={false}> | ||||
| <SheetTitle className="hidden"></SheetTitle> | |||||
| <SheetContent className="bg-white top-20" closeIcon={false}> | <SheetContent className="bg-white top-20" closeIcon={false}> | ||||
| <SheetHeader> | <SheetHeader> | ||||
| <section className="flex-col border-b pb-2"> | <section className="flex-col border-b pb-2"> |
| hideFileUploadModal, | hideFileUploadModal, | ||||
| } = useHandleExportOrImportJsonFile(); | } = useHandleExportOrImportJsonFile(); | ||||
| useFetchDataOnMount(); | |||||
| const { flowDetail } = useFetchDataOnMount(); | |||||
| return ( | return ( | ||||
| <section> | <section> | ||||
| <PageHeader back={navigateToAgentList} title="Agent 01"> | |||||
| <PageHeader back={navigateToAgentList} title={flowDetail.title}> | |||||
| <div className="flex items-center gap-2"> | <div className="flex items-center gap-2"> | ||||
| <DropdownMenu> | <DropdownMenu> | ||||
| <DropdownMenuTrigger> | |||||
| <DropdownMenuTrigger asChild> | |||||
| <Button variant={'icon'} size={'icon'}> | <Button variant={'icon'} size={'icon'}> | ||||
| <EllipsisVertical /> | <EllipsisVertical /> | ||||
| </Button> | </Button> |
| import React from 'react'; | |||||
| import { Operator, operatorIconMap } from './constant'; | import { Operator, operatorIconMap } from './constant'; | ||||
| interface IProps { | interface IProps { | ||||
| color?: string; | color?: string; | ||||
| } | } | ||||
| const Empty = () => { | |||||
| return <div className="hidden"></div>; | |||||
| }; | |||||
| const OperatorIcon = ({ name, fontSize, width, color }: IProps) => { | const OperatorIcon = ({ name, fontSize, width, color }: IProps) => { | ||||
| const Icon = operatorIconMap[name] || React.Fragment; | |||||
| const Icon = operatorIconMap[name] || Empty; | |||||
| return ( | return ( | ||||
| <Icon | <Icon | ||||
| className={'text-2xl max-h-6 max-w-6 text-[rgb(59, 118, 244)]'} | className={'text-2xl max-h-6 max-w-6 text-[rgb(59, 118, 244)]'} |