mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Feat: Add agent advanced settings form #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
38 lines
931 B
TypeScript
38 lines
931 B
TypeScript
import { useFetchModelId } from '@/hooks/logic-hooks';
|
|
import { RAGFlowNodeType } from '@/interfaces/database/flow';
|
|
import { get, isEmpty } from 'lodash';
|
|
import { useMemo } from 'react';
|
|
import { AgentExceptionMethod, initialAgentValues } from '../../constant';
|
|
|
|
export function useValues(node?: RAGFlowNodeType) {
|
|
const llmId = useFetchModelId();
|
|
|
|
const defaultValues = useMemo(
|
|
() => ({
|
|
...initialAgentValues,
|
|
llm_id: llmId,
|
|
prompts: '',
|
|
}),
|
|
[llmId],
|
|
);
|
|
|
|
const values = useMemo(() => {
|
|
const formData = node?.data?.form;
|
|
|
|
if (isEmpty(formData)) {
|
|
return defaultValues;
|
|
}
|
|
|
|
return {
|
|
...formData,
|
|
prompts: get(formData, 'prompts.0.content', ''),
|
|
exception_method:
|
|
formData.exception_method === null
|
|
? AgentExceptionMethod.Null
|
|
: formData.exception_method,
|
|
};
|
|
}, [defaultValues, node?.data?.form]);
|
|
|
|
return values;
|
|
}
|