mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-06-30 06:45:10 +08:00
### What problem does this PR solve? Feat: Add NextLLMSelect with shadcn-ui. #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
7a81fa00e9
commit
5d89a8010b
@ -1,7 +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 { Popover, Select } from 'antd';
|
import { Popover as AntPopover, Select as AntSelect } from 'antd';
|
||||||
|
import { useState } from 'react';
|
||||||
import LlmSettingItems from '../llm-setting-items';
|
import LlmSettingItems from '../llm-setting-items';
|
||||||
|
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';
|
||||||
|
import { Select, SelectTrigger, SelectValue } from '../ui/select';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
id?: string;
|
id?: string;
|
||||||
@ -25,14 +28,14 @@ const LLMSelect = ({ id, value, onChange, disabled }: IProps) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover
|
<AntPopover
|
||||||
content={content}
|
content={content}
|
||||||
trigger="click"
|
trigger="click"
|
||||||
placement="left"
|
placement="left"
|
||||||
arrow={false}
|
arrow={false}
|
||||||
destroyTooltipOnHide
|
destroyTooltipOnHide
|
||||||
>
|
>
|
||||||
<Select
|
<AntSelect
|
||||||
options={modelOptions}
|
options={modelOptions}
|
||||||
style={{ width: '100%' }}
|
style={{ width: '100%' }}
|
||||||
dropdownStyle={{ display: 'none' }}
|
dropdownStyle={{ display: 'none' }}
|
||||||
@ -41,8 +44,37 @@ const LLMSelect = ({ id, value, onChange, disabled }: IProps) => {
|
|||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
/>
|
/>
|
||||||
</Popover>
|
</AntPopover>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default LLMSelect;
|
export default LLMSelect;
|
||||||
|
|
||||||
|
export function NextLLMSelect({ value, onChange, disabled }: IProps) {
|
||||||
|
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Select value={value} onValueChange={onChange} disabled={disabled}>
|
||||||
|
<Popover open={isPopoverOpen} onOpenChange={setIsPopoverOpen}>
|
||||||
|
<PopoverTrigger asChild>
|
||||||
|
<SelectTrigger
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
setIsPopoverOpen(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SelectValue placeholder="xxx" />
|
||||||
|
</SelectTrigger>
|
||||||
|
</PopoverTrigger>
|
||||||
|
<PopoverContent side={'left'}>
|
||||||
|
<LlmSettingItems
|
||||||
|
formItemLayout={{
|
||||||
|
labelCol: { span: 10 },
|
||||||
|
wrapperCol: { span: 14 },
|
||||||
|
}}
|
||||||
|
></LlmSettingItems>
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
</Select>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@ -186,11 +186,12 @@ export type RAGFlowSelectGroupOptionType = {
|
|||||||
options: RAGFlowSelectOptionType[];
|
options: RAGFlowSelectOptionType[];
|
||||||
};
|
};
|
||||||
|
|
||||||
type RAGFlowSelectProps = Partial<ControllerRenderProps> & {
|
export type RAGFlowSelectProps = Partial<ControllerRenderProps> & {
|
||||||
FormControlComponent?: typeof FormControl;
|
FormControlComponent?: typeof FormControl;
|
||||||
options?: (RAGFlowSelectOptionType | RAGFlowSelectGroupOptionType)[];
|
options?: (RAGFlowSelectOptionType | RAGFlowSelectGroupOptionType)[];
|
||||||
allowClear?: boolean;
|
allowClear?: boolean;
|
||||||
placeholder?: React.ReactNode;
|
placeholder?: React.ReactNode;
|
||||||
|
contentProps?: React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>;
|
||||||
} & SelectPrimitive.SelectProps;
|
} & SelectPrimitive.SelectProps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -220,6 +221,7 @@ export const RAGFlowSelect = forwardRef<
|
|||||||
options = [],
|
options = [],
|
||||||
allowClear,
|
allowClear,
|
||||||
placeholder,
|
placeholder,
|
||||||
|
contentProps = {},
|
||||||
},
|
},
|
||||||
ref,
|
ref,
|
||||||
) {
|
) {
|
||||||
@ -265,7 +267,7 @@ export const RAGFlowSelect = forwardRef<
|
|||||||
<SelectValue placeholder={placeholder} />
|
<SelectValue placeholder={placeholder} />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
</FormControlWidget>
|
</FormControlWidget>
|
||||||
<SelectContent>
|
<SelectContent {...contentProps}>
|
||||||
{options.map((o, idx) => {
|
{options.map((o, idx) => {
|
||||||
if ('value' in o) {
|
if ('value' in o) {
|
||||||
return (
|
return (
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import LLMSelect from '@/components/llm-select';
|
import { NextLLMSelect } from '@/components/llm-select';
|
||||||
import { MessageHistoryWindowSizeFormField } from '@/components/message-history-window-size-item';
|
import { MessageHistoryWindowSizeFormField } from '@/components/message-history-window-size-item';
|
||||||
import { PromptEditor } from '@/components/prompt-editor';
|
import { PromptEditor } from '@/components/prompt-editor';
|
||||||
import {
|
import {
|
||||||
@ -33,7 +33,7 @@ const GenerateForm = ({ form }: INextOperatorForm) => {
|
|||||||
{t('chat.model')}
|
{t('chat.model')}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<LLMSelect {...field} />
|
<NextLLMSelect {...field} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user