RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Feat: Put some wiki templates. (#16617)
Kevin Hucf634b92b4ca
diff --git a/api/apps/restful_apis/compilation_template_api.py b/api/apps/restful_apis/compilation_template_api.pyindex ceb7c7e7de..8895bb102c 100644--- a/api/apps/restful_apis/compilation_template_api.py+++ b/api/apps/restful_apis/compilation_template_api.py@@ -52,3 +52,21 @@ def list_builtin_templates() -> Response:return get_json_result(data=templates)except Exception as exc:return server_error_response(exc)++[email protected]("/compilation_templates/wiki_presets", methods=["GET"]) # noqa: F821+@login_required+def list_wiki_presets() -> Response:+ """Wiki page-structure presets loaded from+ ``api/db/init_data/compilation_templates/wiki/*.yaml``.++ Each entry carries ``id`` (filename stem) + ``topic`` ++ ``instruction`` + ``page_example`` so the artifact-template editor+ can pre-fill its "Page-structure example" / "Global rules" fields+ from a canned skeleton. Filesystem-fresh per request; no DB seed.+ """+ try:+ presets = CompilationTemplateService.load_wiki_presets_from_files()+ return get_json_result(data=presets)+ except Exception as exc:+ return server_error_response(exc)diff --git a/api/db/init_data/compilation_templates/artifacts.yaml b/api/db/init_data/compilation_templates/wiki.yamlsimilarity index 97%rename from api/db/init_data/compilation_templates/artifacts.yamlrename to api/db/init_data/compilation_templates/wiki.yamlindex 42dc1f39e3..b0484c4b1c 100644--- a/api/db/init_data/compilation_templates/artifacts.yaml+++ b/api/db/init_data/compilation_templates/wiki.yaml@@ -6,9 +6,9 @@ config:- Each page must be a proper encyclopedic article, NOT a flat bullet list:- 1. Opening paragraph (2-4 sentences defining what this is). No heading.- 2. Sections with H2 headings, each starting with prose before sub-bullets.- - 3. Bold key terms on first use; link them with [[ ]] artifactlinks.+ - 3. Bold key terms on first use; link them with [[ ]] wikilinks.- 4. Examples or implications where the source provides them.- - 5. ## See also section at the end with artifactlinks to highly related pages(less than 12).\n+ - 5. ## See also section at the end with wikilinks to highly related pages(less than 12).\n- Page structure could be as following: (Not provided)entity:description: >-diff --git a/api/db/init_data/compilation_templates/wiki/brand.yaml b/api/db/init_data/compilation_templates/wiki/brand.yamlnew file mode 100644index 0000000000..1e5c067488--- /dev/null+++ b/api/db/init_data/compilation_templates/wiki/brand.yaml@@ -0,0 +1,47 @@+instruction: |+ - Each page must be a proper encyclopedic article, NOT a flat bullet list:+ - 1. Take prefix ">" or "-" in the "page_example" as instructions to generate the content.+ - 2. Sections with H2 headings, each starting with prose before sub-bullets.+page_example: |+ # Tone of voice++ ## Principles+ > The tonal principles that shape the way you communicate.+ ### Principle 1+ > Details+ ### Principle 2+ > Details++ ## Voice+ > Qualify what your company public's personality is and is not.++ ### We are adjective, not adjective+ > Details++ ### We are adjective, not adjective+ > Details++ ## Tone+ > Describe your general tone+ > Use the matrix below to determine which tonal principles should drive which messaging.+ | Channel | Leading tonal principle | Copy examples+ | :--- | :---: | ---: |+ |Website|Principle|Example+ |Advertising|Principle|Example+ |Social|Principle|Example++ ## Stylistic guidance+ > Easy rules and tactics everyone can apply about punctuation, lexicon, formatting...+ ### Tip 1+ > Details+ ### Tip 2+ > Details++ ## Dos & Dont's+ |We say π| We don't say π |+ | :--- | :---: |+ |Example| Example|+ |Example| Example|++topic: marketing+\ No newline at end of filediff --git a/api/db/init_data/compilation_templates/wiki/engineering.yaml b/api/db/init_data/compilation_templates/wiki/engineering.yamlnew file mode 100644index 0000000000..5dc014e555--- /dev/null+++ b/api/db/init_data/compilation_templates/wiki/engineering.yaml@@ -0,0 +1,42 @@++instruction: |+ - Each page must be a proper encyclopedic article, NOT a flat bullet list:+ - 1. Take prefix ">" or "-" in the "page_example" as instructions to generate the content.+ - 2. Sections with H2 headings, each starting with prose before sub-bullets.+page_example: |+ # Secret feature(Title)++ ## Background & research+ > Explain the context behind why we are doing this project. Data is a great source of insight.+++ ## Problem statement+ > As a who, I am trying to outcome/job. But problem/barrier because root cause which makes me feel emotion.++ ## Goals+ - List goals+ - KPIs+ - What success looks like++ ## Hypothesis+ > If we achieve/enable X, then user behavior Y changes in this way leading to positive metrics Z.++ ## Technical solution+ > Outline the solution step by step and illustrate your points with specific code structure.+ ```+ Fill code snippet+ ```++ ## Scope+ > Explain the solution is, how it works and the extent of the work involved.+ - Requirements+ - Future evolutions+ - Out of scope++ ## Designs and assets+ > Add any necessary figma project link, hi-fi mockups, SVGs, font files, images, prototypes...++ ## Open questions+ [x] E.g. is this part of the free plan?++topic: engineering\ No newline at end of filediff --git a/api/db/init_data/compilation_templates/wiki/general.yaml b/api/db/init_data/compilation_templates/wiki/general.yamlnew file mode 100644index 0000000000..bd5e8ac505--- /dev/null+++ b/api/db/init_data/compilation_templates/wiki/general.yaml@@ -0,0 +1,10 @@+topic: general+instruction: |+ - Each page must be a proper encyclopedic article, NOT a flat bullet list:+ - 1. Opening paragraph (2-4 sentences defining what this is). No heading.+ - 2. Sections with H2 headings, each starting with prose before sub-bullets.+ - 3. Bold key terms on first use; link them with [[ ]] wikilinks.+ - 4. Examples or implications where the source provides them.+ - 5. ## See also section at the end with wikilinks to highly related pages(less than 12).\n+page_example: |+ - (Not provided)\ No newline at end of filediff --git a/api/db/init_data/compilation_templates/wiki/market.yaml b/api/db/init_data/compilation_templates/wiki/market.yamlnew file mode 100644index 0000000000..01970c23c5--- /dev/null+++ b/api/db/init_data/compilation_templates/wiki/market.yaml@@ -0,0 +1,25 @@++instruction: |+ - Each page must be a proper encyclopedic article, NOT a flat bullet list:+ - 1. Take prefix ">" or "-" in the "page_example" as instructions to generate the content.+ - 2. Sections with H2 headings, each starting with prose before sub-bullets.+page_example: |+ # Competitor analysis(title)++ ## Analysis strengths/weaknesses+ > Use the table below to analyze strong and weak points of each competitor+ | Competitor Name | Weakness | strengths |+ | :--- | :---: | ---: |+ | Laptop | Electronics | something |+ | Coffee Mug | Kitchenware | something |+ | Desk Chair | Furniture | something |++ ## Positioning & use cases+ > How is the product positioning itself on the market? What use cases does it enable?++ ## Features to note+ > List and add screenshots of any noteworthy feature.++ ## Pricing++topic: marketing\ No newline at end of filediff --git a/api/db/init_data/compilation_templates/wiki/product.yaml b/api/db/init_data/compilation_templates/wiki/product.yamlnew file mode 100644index 0000000000..b1da7e5672--- /dev/null+++ b/api/db/init_data/compilation_templates/wiki/product.yaml@@ -0,0 +1,41 @@+instruction: |+ - Each page must be a proper encyclopedic article, NOT a flat bullet list:+ - 1. Take prefix ">" or "-" in the "page_example" as instructions to generate the content.+ - 2. Sections with H2 headings, each starting with prose before sub-bullets.+page_example: |+ # Onboarding flow update+ ## Background & research+ summary(example): 40% of new users aren't activating. By reviewing our onboarding flow we'll help teams better understand the value of the product and activate faster on Slite.+ ## Problem statement+ > As a new user, I am trying to get started with the product. But I don't understand the features and the product because nothing is explained to me which makes me feel like I don't know how to use the tool at all.+ ## Goals+ - Increase user activation by 10 points++ ## Hypothesis+ > If we review our onboarding to help users, then we will retain more users leading to positive activation results.++ ## Vision narrative+ We ask users about themselves in order to give them more personalized information to help them get started.+ ## Scope+ 1. Decide the questions we ask users+ 2. Personalize how we cater to each different types of users+ 3. Plan for the content+ 4. Build and ship the new flow+ ## First mock-ups+ > maybe some images here.++ ## Open questions+ [x] How will we measure this?+ [x] How do Marketing and Product work on this together?++ ## Technical factoring+ > Engineers can estimate the project to plan for code structure and specific technical choices.+ ```+ async fn quick_task() -> Result<&'static str> {+ println!("START quick_task");+ await!(delay(10)).context("delay failed")?;+ println!("END quick_task");+ Ok("quick_task result")+ ```++topic: product\ No newline at end of filediff --git a/api/db/init_data/compilation_templates/wiki/user_interview.yaml b/api/db/init_data/compilation_templates/wiki/user_interview.yamlnew file mode 100644index 0000000000..fc6bae2c7c--- /dev/null+++ b/api/db/init_data/compilation_templates/wiki/user_interview.yaml@@ -0,0 +1,27 @@+instruction: |+ - Each page must be a proper encyclopedic article, NOT a flat bullet list:+ - 1. Take prefix ">" or "-" in the "page_example" as instructions to generate the content.+ - 2. Sections with H2 headings, each starting with prose before sub-bullets.+page_example: |+ # User interview+ ## Takeaways+ - The team is still unaware about features x, y, z+ - Takeaway 2+ - Takeaway 3+ ## Goal+ > What are you trying to find out with this interview?+ ## Feedback+ ### Why did you sign up?+ > Record user's answer.++ ### Have you tried other alternatives?+ - Competitors+ - Process++ ### Question #3+ > Record user's answer.++ ## Resources+ > Upload screenshots or video recordings of your interview. Any relevant file exchanged during your conversation can be added too.++topic: product\ No newline at end of filediff --git a/api/db/services/compilation_template_service.py b/api/db/services/compilation_template_service.pyindex 525b656a15..fd969f5ce8 100644--- a/api/db/services/compilation_template_service.py+++ b/api/db/services/compilation_template_service.py@@ -229,3 +229,53 @@ class CompilationTemplateService(CommonService):except Exception as e:logging.exception("Add compilation template error for %s: %s", template_path, e)return cls._sort_builtins(templates)++ @classmethod+ def load_wiki_presets_from_files(cls) -> list[dict]:+ """Load wiki page-structure presets from+ ``api/db/init_data/compilation_templates/wiki/*.yaml``.++ Each file contributes one preset dict with ``topic`` /+ ``instruction`` / ``page_example`` fields (plus ``id`` derived+ from the filename stem so the frontend can key list items+ even when several presets share the same ``topic`` β which is+ by design; the UI groups presets by topic).++ Filesystem-fresh on every call: these are read-only reference+ data with low request volume, so no DB seed / no ES cache.+ Same failure-isolation policy as :meth:`load_builtins_from_files`+ β a single malformed file logs and is skipped; the rest still+ load. Ordered by filename for stability.+ """+ wiki_dir = os.path.join(+ get_project_base_directory(),+ "api", "db", "init_data", "compilation_templates", "wiki",+ )+ if not os.path.exists(wiki_dir):+ logging.warning("Missing wiki presets directory: %s", wiki_dir)+ return []++ presets: list[dict] = []+ yaml = YAML(typ="safe", pure=True)+ for filename in sorted(os.listdir(wiki_dir)):+ if not filename.endswith((".yaml", ".yml")):+ continue+ path = os.path.join(wiki_dir, filename)+ try:+ with open(path, "r", encoding="utf-8") as f:+ doc = yaml.load(f) or {}+ except Exception:+ logging.exception("wiki preset load failed for %s", path)+ continue+ if not isinstance(doc, dict):+ logging.warning("wiki preset skipped (not a mapping): %s", path)+ continue+ # Missing fields degrade to empty strings so the frontend+ # doesn't have to null-check every row.+ presets.append({+ "id": os.path.splitext(filename)[0],+ "topic": str(doc.get("topic") or "").strip(),+ "instruction": str(doc.get("instruction") or ""),+ "page_example": str(doc.get("page_example") or ""),+ })+ return presetsdiff --git a/api/db/services/dialog_service.py b/api/db/services/dialog_service.pyindex cce2479f26..8d7eba49f4 100644--- a/api/db/services/dialog_service.py+++ b/api/db/services/dialog_service.py@@ -681,8 +681,8 @@ async def async_chat(dialog, messages, stream=True, **kwargs):prompt_config,partial(retriever.retrieval,- embd_mdl=embd_mdl,- tenant_ids=tenant_ids,+ embd_mdl = embd_mdl,+ tenant_ids = tenant_ids,kb_ids=dialog.kb_ids,page=1,page_size=dialog.top_n,