mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-02-05 01:55:05 +08:00
Feat: The agent operator and message operator can only select string variables as prompt words. #10427 (#11054)
### What problem does this PR solve? Feat: The agent operator and message operator can only select string variables as prompt words. #10427 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -4,12 +4,14 @@ import { RAGFlowNodeType } from '@/interfaces/database/flow';
|
||||
import { buildNodeOutputOptions } from '@/utils/canvas-util';
|
||||
import { DefaultOptionType } from 'antd/es/select';
|
||||
import { t } from 'i18next';
|
||||
import { isEmpty, toLower } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import { useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
||||
import {
|
||||
AgentDialogueMode,
|
||||
BeginId,
|
||||
BeginQueryType,
|
||||
JsonSchemaDataType,
|
||||
Operator,
|
||||
VariableType,
|
||||
} from '../constant';
|
||||
@ -171,6 +173,29 @@ export function useBuildQueryVariableOptions(n?: RAGFlowNodeType) {
|
||||
return nextOptions;
|
||||
}
|
||||
|
||||
export function useFilterQueryVariableOptionsByTypes(
|
||||
types?: JsonSchemaDataType[],
|
||||
) {
|
||||
const nextOptions = useBuildQueryVariableOptions();
|
||||
|
||||
const filteredOptions = useMemo(() => {
|
||||
return !isEmpty(types)
|
||||
? nextOptions.map((x) => {
|
||||
return {
|
||||
...x,
|
||||
options: x.options.filter(
|
||||
(y) =>
|
||||
types?.some((x) => toLower(y.type).includes(x)) ||
|
||||
y.type === undefined, // agent structured output
|
||||
),
|
||||
};
|
||||
})
|
||||
: nextOptions;
|
||||
}, [nextOptions, types]);
|
||||
|
||||
return filteredOptions;
|
||||
}
|
||||
|
||||
export function useBuildComponentIdOptions(nodeId?: string, parentId?: string) {
|
||||
const nodes = useGraphStore((state) => state.nodes);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user