Feature:memory function complete (#11982)

### What problem does this PR solve?

memory function complete

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
chanx
2025-12-17 12:35:26 +08:00
committed by GitHub
parent 2595644dfd
commit 205a6483f5
20 changed files with 226 additions and 142 deletions

View File

@ -81,6 +81,7 @@ export interface FormFieldConfig {
schema?: ZodSchema;
shouldRender?: (formValues: any) => boolean;
labelClassName?: string;
disabled?: boolean;
}
// Component props interface
@ -328,11 +329,7 @@ export const RenderField = ({
}
return (
<RAGFlowFormItem
name={field.name}
label={field.label}
required={field.required}
horizontal={field.horizontal}
tooltip={field.tooltip}
{...field}
labelClassName={labelClassName || field.labelClassName}
>
{(fieldProps) => {
@ -354,11 +351,7 @@ export const RenderField = ({
case FormFieldType.Textarea:
return (
<RAGFlowFormItem
name={field.name}
label={field.label}
required={field.required}
horizontal={field.horizontal}
tooltip={field.tooltip}
{...field}
labelClassName={labelClassName || field.labelClassName}
>
{(fieldProps) => {
@ -375,6 +368,7 @@ export const RenderField = ({
<Textarea
{...finalFieldProps}
placeholder={field.placeholder}
disabled={field.disabled}
// className="resize-none"
/>
);
@ -385,11 +379,7 @@ export const RenderField = ({
case FormFieldType.Select:
return (
<RAGFlowFormItem
name={field.name}
label={field.label}
required={field.required}
horizontal={field.horizontal}
tooltip={field.tooltip}
{...field}
labelClassName={labelClassName || field.labelClassName}
>
{(fieldProps) => {
@ -410,6 +400,7 @@ export const RenderField = ({
triggerClassName="!shrink"
{...finalFieldProps}
options={field.options}
disabled={field.disabled}
/>
);
}}
@ -419,11 +410,7 @@ export const RenderField = ({
case FormFieldType.MultiSelect:
return (
<RAGFlowFormItem
name={field.name}
label={field.label}
required={field.required}
horizontal={field.horizontal}
tooltip={field.tooltip}
{...field}
labelClassName={labelClassName || field.labelClassName}
>
{(fieldProps) => {
@ -447,6 +434,7 @@ export const RenderField = ({
// field.onChange?.(data);
// }}
options={field.options as MultiSelectOptionType[]}
disabled={field.disabled}
/>
);
}}
@ -504,6 +492,7 @@ export const RenderField = ({
formField.onChange(checked);
field.onChange?.(checked);
}}
disabled={field.disabled}
/>
</div>
</FormControl>
@ -517,11 +506,7 @@ export const RenderField = ({
case FormFieldType.Tag:
return (
<RAGFlowFormItem
name={field.name}
label={field.label}
required={field.required}
horizontal={field.horizontal}
tooltip={field.tooltip}
{...field}
labelClassName={labelClassName || field.labelClassName}
>
{(fieldProps) => {
@ -537,7 +522,10 @@ export const RenderField = ({
return (
// <TagInput {...fieldProps} placeholder={field.placeholder} />
<div className="w-full">
<EditTag {...finalFieldProps}></EditTag>
<EditTag
{...finalFieldProps}
disabled={field.disabled}
></EditTag>
</div>
);
}}
@ -547,11 +535,7 @@ export const RenderField = ({
default:
return (
<RAGFlowFormItem
name={field.name}
label={field.label}
required={field.required}
horizontal={field.horizontal}
tooltip={field.tooltip}
{...field}
labelClassName={labelClassName || field.labelClassName}
>
{(fieldProps) => {
@ -570,6 +554,7 @@ export const RenderField = ({
{...finalFieldProps}
type={field.type}
placeholder={field.placeholder}
disabled={field.disabled}
/>
</div>
);

View File

@ -12,10 +12,11 @@ import { Input } from '../ui/input';
interface EditTagsProps {
value?: string[];
onChange?: (tags: string[]) => void;
disabled?: boolean;
}
const EditTag = React.forwardRef<HTMLDivElement, EditTagsProps>(
({ value = [], onChange }: EditTagsProps) => {
({ value = [], onChange, disabled }: EditTagsProps) => {
const [inputVisible, setInputVisible] = useState(false);
const [inputValue, setInputValue] = useState('');
const inputRef = useRef<HTMLInputElement>(null);
@ -61,13 +62,15 @@ const EditTag = React.forwardRef<HTMLDivElement, EditTagsProps>(
<div className="max-w-80 overflow-hidden text-ellipsis">
{tag}
</div>
<X
className="w-4 h-4 text-muted-foreground hover:text-primary"
onClick={(e) => {
e.preventDefault();
handleClose(tag);
}}
/>
{!disabled && (
<X
className="w-4 h-4 text-muted-foreground hover:text-primary"
onClick={(e) => {
e.preventDefault();
handleClose(tag);
}}
/>
)}
</div>
</div>
</HoverCardTrigger>
@ -91,6 +94,7 @@ const EditTag = React.forwardRef<HTMLDivElement, EditTagsProps>(
value={inputValue}
onChange={handleInputChange}
onBlur={handleInputConfirm}
disabled={disabled}
onKeyDown={(e) => {
if (e?.key === 'Enter') {
handleInputConfirm();
@ -100,11 +104,12 @@ const EditTag = React.forwardRef<HTMLDivElement, EditTagsProps>(
)}
<div className="flex gap-2 py-1">
{Array.isArray(tagChild) && tagChild.length > 0 && <>{tagChild}</>}
{!inputVisible && (
{!inputVisible && !disabled && (
<Button
variant="ghost"
className="w-fit flex items-center justify-center gap-2 bg-bg-card border-dashed border"
onClick={showInput}
disabled={disabled}
style={tagPlusStyle}
>
<PlusOutlined />

View File

@ -179,7 +179,7 @@ export const SelectWithSearch = forwardRef<
align="start"
>
<Command className="p-5">
{options && options.length > 0 && (
{options && options.length > 5 && (
<CommandInput
placeholder={t('common.search') + '...'}
className=" placeholder:text-text-disabled"
@ -193,7 +193,7 @@ export const SelectWithSearch = forwardRef<
if (group.options) {
return (
<Fragment key={idx}>
<CommandGroup heading={group.label}>
<CommandGroup heading={group.label} className="mb-1">
{group.options.map((option) => (
<CommandItem
key={option.value}
@ -221,11 +221,9 @@ export const SelectWithSearch = forwardRef<
value={group.value}
disabled={group.disabled}
onSelect={handleSelect}
className={
value === group.value
? 'bg-bg-card min-h-10'
: 'min-h-10'
}
className={cn('mb-1 min-h-10 ', {
'bg-bg-card ': value === group.value,
})}
>
<span className="leading-none">{group.label}</span>