mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-02-04 17:45:07 +08:00
### 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:
@ -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 };
|
||||
}
|
||||
Reference in New Issue
Block a user