Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

refa: unify wiki example naming (#17910)

buua43697f9ae5896c4
diff --git a/rag/advanced_rag/knowlege_compile/wiki.py b/rag/advanced_rag/knowlege_compile/wiki.py
index e2757d9af3..f354028f01 100644
--- a/rag/advanced_rag/knowlege_compile/wiki.py
+++ b/rag/advanced_rag/knowlege_compile/wiki.py
@@ -2648,7 +2648,7 @@ WIKI_REFINE_WRITER_SYSTEM_TEMPLATE = (
)
-def _build_refine_writer_system(instruction: str | None = None, page_example: str | None = None) -> str:
+def _build_refine_writer_system(instruction: str | None = None, example: str | None = None) -> str:
"""Return the writer system prompt with separate instruction and page
example overrides. Empty values use the built-in defaults.
@@ -2657,7 +2657,7 @@ def _build_refine_writer_system(instruction: str | None = None, page_example: st
override to apply.
"""
instruction_body = (instruction or "").strip() or "Follow the page structure and writing requirements below."
- example_body = (page_example or "").strip() or WIKI_TEMPLATE_EXAMPLE
+ example_body = (example or "").strip() or WIKI_TEMPLATE_EXAMPLE
return WIKI_REFINE_WRITER_SYSTEM_TEMPLATE.format(
template_instruction=instruction_body,
template_example=example_body,
@@ -3266,14 +3266,12 @@ async def _wiki_write_page_simple(
chat_mdl,
llm_timeout: int,
instruction: Optional[str] = None,
- page_example: Optional[str] = None,
example: Optional[str] = None,
) -> str:
"""Single LLM call → markdown content.
- ``instruction`` and ``page_example`` are the separate per-template
- writer overrides. ``example`` is retained as a fallback for callers
- using the older combined configuration field.
+ ``instruction`` and ``example`` are the separate per-template writer
+ overrides.
"""
own_slug = plan_item.get("slug") or ""
available = [s for s in all_plan_slugs if s and s != own_slug]
@@ -3300,7 +3298,7 @@ async def _wiki_write_page_simple(
chat_mdl,
_build_refine_writer_system(
instruction=instruction,
- page_example=page_example or example,
+ example=example,
),
user_prompt,
temperature=0.15,
@@ -3542,7 +3540,6 @@ async def wiki_refine_from_plan(
force_rerun: bool = False,
callback: Optional[Callable] = None,
instruction: Optional[str] = None,
- page_example: Optional[str] = None,
example: Optional[str] = None,
) -> list[dict]:
"""Phase 4 (REFINE) — KB-scoped.
@@ -3738,7 +3735,6 @@ async def wiki_refine_from_plan(
chat_mdl,
llm_timeout,
instruction=instruction,
- page_example=page_example,
example=example,
)
if not content_md_raw:
diff --git a/rag/svr/task_executor_refactor/dataset_wiki_generator.py b/rag/svr/task_executor_refactor/dataset_wiki_generator.py
index 4de3c72411..3cf929c606 100644
--- a/rag/svr/task_executor_refactor/dataset_wiki_generator.py
+++ b/rag/svr/task_executor_refactor/dataset_wiki_generator.py
@@ -1289,9 +1289,9 @@ async def run_wiki(
first_parser_cfg = first_parser_cfg if isinstance(first_parser_cfg, dict) else {}
kb_chat_llm_id: Optional[str] = (first_parser_cfg.get("llm_id") or "").strip() or None
first_instruction = first_parser_cfg.get("instruction")
- first_page_example = first_parser_cfg.get("example")
+ first_example = first_parser_cfg.get("example")
kb_writer_instruction: Optional[str] = first_instruction if isinstance(first_instruction, str) and first_instruction.strip() else None
- kb_writer_page_example: Optional[str] = first_page_example if isinstance(first_page_example, str) and first_page_example.strip() else None
+ kb_writer_example: Optional[str] = first_example if isinstance(first_example, str) and first_example.strip() else None
map_llm_pool = LLMCallPool(WIKI_MAP_LLM_POOL_SIZE, max_pending=WIKI_MAP_MAX_PENDING)
n_docs = len(resolved_eligible)
map_queue: asyncio.Queue = asyncio.Queue(maxsize=WIKI_MAP_QUEUE_SIZE)
@@ -1460,7 +1460,7 @@ async def run_wiki(
max_workers=WIKI_REFINE_WORKERS,
callback=_stage_cb("[wiki REFINE]"),
instruction=kb_writer_instruction,
- page_example=kb_writer_page_example,
+ example=kb_writer_example,
)
except Exception:
logging.exception("wiki: REDUCE/PLAN/REFINE failed for kb %s", ctx.kb_id)
diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts
index 2fc072f459..38754fe3d3 100644
--- a/web/src/locales/en.ts
+++ b/web/src/locales/en.ts
@@ -1901,7 +1901,7 @@ Example: Virtual Hosted Style`,
description: 'Description',
descriptionPlaceholder: 'Enter description',
addField: 'Add field',
- example: 'Page-structure example',
+ example: 'Example',
examplePlaceholder: 'Input example',
instruction: 'Instruction',
globalRules: 'Global rules',
diff --git a/web/src/locales/ja.ts b/web/src/locales/ja.ts
index 4cbf8c715f..4e26bfc71f 100644
--- a/web/src/locales/ja.ts
+++ b/web/src/locales/ja.ts
@@ -1637,7 +1637,7 @@ export default {
description: '説明',
descriptionPlaceholder: '説明を入力してください',
addField: 'フィールドを追加',
- example: 'ページ構成の例',
+ example: '例',
examplePlaceholder: '入力例',
instruction: '指示',
globalRules: 'グローバルルール',
diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts
index dd7d21926f..e8a93a1d3f 100644
--- a/web/src/locales/zh.ts
+++ b/web/src/locales/zh.ts
@@ -1590,7 +1590,7 @@ NER:使用 spaCy NER 和基于规则的关键词提取来抽取实体和关系
description: '描述',
descriptionPlaceholder: '请输入描述',
addField: '添加字段',
- example: '页面结构示例',
+ example: '示例',
examplePlaceholder: '请输入示例',
instruction: 'Instruction',
globalRules: '全局规则',
diff --git a/web/src/pages/user-setting/compilation-templates/create-next/components/blueprints-step.tsx b/web/src/pages/user-setting/compilation-templates/create-next/components/blueprints-step.tsx
index bd4d283109..df113a8077 100644
--- a/web/src/pages/user-setting/compilation-templates/create-next/components/blueprints-step.tsx
+++ b/web/src/pages/user-setting/compilation-templates/create-next/components/blueprints-step.tsx
@@ -173,12 +173,16 @@ export function BlueprintsStep({
<Textarea rows={6} />
</RAGFlowFormItem>
- <div className="flex-1 min-h-0 flex flex-col">
+ <RAGFlowFormItem
+ name={examplePath}
+ label={t('setting.example')}
+ className="flex-1 min-h-0"
+ >
<MarkdownEditor
content={String(example ?? '')}
onChange={handleExampleChange}
/>
- </div>
+ </RAGFlowFormItem>
</div>
) : (
<BlueprintsEmptyState />
diff --git a/web/src/pages/user-setting/compilation-templates/edit-next/components/blueprint-section.tsx b/web/src/pages/user-setting/compilation-templates/edit-next/components/blueprint-section.tsx
index d2b24d8f7f..51cb55716d 100644
--- a/web/src/pages/user-setting/compilation-templates/edit-next/components/blueprint-section.tsx
+++ b/web/src/pages/user-setting/compilation-templates/edit-next/components/blueprint-section.tsx
@@ -24,14 +24,8 @@ export function BlueprintSection({
}: BlueprintSectionProps) {
const { t } = useTranslation();
const { data: presets } = useFetchWikiPresets();
- const {
- selectedValue,
- options,
- handleSelect,
- instructionPath,
- example,
- handleExampleChange,
- } = useBlueprintSelection({ form, selectedTemplateIndex, presets, builtins });
+ const { selectedValue, options, handleSelect, instructionPath, examplePath } =
+ useBlueprintSelection({ form, selectedTemplateIndex, presets, builtins });
if (presets.length === 0) {
return null;
@@ -61,12 +55,18 @@ export function BlueprintSection({
<Textarea rows={8} resize={'vertical'} />
</RAGFlowFormItem>
- <div className="flex h-[50vh] min-h-0 flex-col">
- <MarkdownEditor
- content={String(example ?? '')}
- onChange={handleExampleChange}
- />
- </div>
+ <RAGFlowFormItem
+ name={examplePath}
+ label={t('setting.example')}
+ className="flex h-[50vh] min-h-0 flex-col"
+ >
+ {(field) => (
+ <MarkdownEditor
+ content={String(field.value ?? '')}
+ onChange={field.onChange}
+ />
+ )}
+ </RAGFlowFormItem>
</div>
</div>
</Collapse>
diff --git a/web/src/pages/user-setting/compilation-templates/edit-next/hooks/use-blueprint-selection.ts b/web/src/pages/user-setting/compilation-templates/edit-next/hooks/use-blueprint-selection.ts
index 3c6cc63bf1..a11f04fbc9 100644
--- a/web/src/pages/user-setting/compilation-templates/edit-next/hooks/use-blueprint-selection.ts
+++ b/web/src/pages/user-setting/compilation-templates/edit-next/hooks/use-blueprint-selection.ts
@@ -130,19 +130,11 @@ export function useBlueprintSelection({
],
);
- const handleExampleChange = useCallback(
- (value: string) => {
- form.setValue(examplePath, value, { shouldValidate: false });
- },
- [form, examplePath],
- );
-
return {
selectedValue,
options,
handleSelect,
instructionPath,
- example,
- handleExampleChange,
+ examplePath,
};
}