mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-06-30 09:05:10 +08:00
### 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)
This commit is contained in:
parent
03d1265cfd
commit
131f272e69
@ -1,8 +1,10 @@
|
|||||||
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';
|
||||||
|
|
||||||
@ -50,11 +52,18 @@ const LLMSelect = ({ id, value, onChange, disabled }: IProps) => {
|
|||||||
|
|
||||||
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
|
||||||
@ -62,19 +71,23 @@ export function NextLLMSelect({ value, onChange, disabled }: IProps) {
|
|||||||
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
|
<LlmSettingFieldItems></LlmSettingFieldItems>
|
||||||
formItemLayout={{
|
|
||||||
labelCol: { span: 10 },
|
|
||||||
wrapperCol: { span: 14 },
|
|
||||||
}}
|
|
||||||
></LlmSettingItems>
|
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
</Popover>
|
</Popover>
|
||||||
</Select>
|
</Select>
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
|
|
||||||
|
NextLLMSelect.displayName = 'LLMSelect';
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
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';
|
||||||
@ -88,6 +93,7 @@ const FormSheet = ({
|
|||||||
|
|
||||||
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">
|
||||||
|
@ -49,14 +49,14 @@ export default function Agent() {
|
|||||||
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>
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import React from 'react';
|
|
||||||
import { Operator, operatorIconMap } from './constant';
|
import { Operator, operatorIconMap } from './constant';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
@ -8,8 +7,12 @@ 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)]'}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user