Feat: Allow users to select prompt word templates in agent operators. #9935 (#9936)

### What problem does this PR solve?

Feat: Allow users to select prompt word templates in agent operators.
#9935

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-09-05 15:48:57 +08:00
committed by GitHub
parent 6ff7cfe005
commit 79ca25ec7e
11 changed files with 108 additions and 18 deletions

View File

@ -0,0 +1,30 @@
import { useFetchPrompt } from '@/hooks/use-agent-request';
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
export const PromptIdentity = 'RAGFlow-Prompt';
function wrapPromptWithTag(text: string, tag: string) {
const capitalTag = tag.toUpperCase();
return `<${capitalTag}>
${text}
</${capitalTag}>`;
}
export function useBuildPromptExtraPromptOptions() {
const { data: prompts } = useFetchPrompt();
const { t } = useTranslation();
const options = useMemo(() => {
return Object.entries(prompts || {}).map(([key, value]) => ({
label: key,
value: wrapPromptWithTag(value, key),
}));
}, [prompts]);
const extraOptions = [
{ label: PromptIdentity, title: t('flow.frameworkPrompts'), options },
];
return { extraOptions };
}