mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-04 09:39:32 +08:00
Feat: Put some wiki templates. (#16617)
### Summary Add a few of wiki templates.
This commit is contained in:
@@ -52,3 +52,21 @@ def list_builtin_templates() -> Response:
|
||||
return get_json_result(data=templates)
|
||||
except Exception as exc:
|
||||
return server_error_response(exc)
|
||||
|
||||
|
||||
@manager.route("/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)
|
||||
|
||||
@@ -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: >-
|
||||
47
api/db/init_data/compilation_templates/wiki/brand.yaml
Normal file
47
api/db/init_data/compilation_templates/wiki/brand.yaml
Normal file
@@ -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
|
||||
|
||||
42
api/db/init_data/compilation_templates/wiki/engineering.yaml
Normal file
42
api/db/init_data/compilation_templates/wiki/engineering.yaml
Normal file
@@ -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
|
||||
10
api/db/init_data/compilation_templates/wiki/general.yaml
Normal file
10
api/db/init_data/compilation_templates/wiki/general.yaml
Normal file
@@ -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)
|
||||
25
api/db/init_data/compilation_templates/wiki/market.yaml
Normal file
25
api/db/init_data/compilation_templates/wiki/market.yaml
Normal file
@@ -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
|
||||
41
api/db/init_data/compilation_templates/wiki/product.yaml
Normal file
41
api/db/init_data/compilation_templates/wiki/product.yaml
Normal file
@@ -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
|
||||
@@ -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
|
||||
@@ -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 presets
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user