mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-01 05:23:47 +08:00
Refact: Rename "artifact_" to "wiki_". (#17553)
This commit is contained in:
@@ -67,7 +67,7 @@ _INDEX_TYPE_TO_TASK_ID_FIELD = {
|
||||
"graph": "graphrag_task_id",
|
||||
"raptor": "raptor_task_id",
|
||||
"mindmap": "mindmap_task_id",
|
||||
"artifact": "artifact_task_id",
|
||||
"artifact": "wiki_task_id",
|
||||
"skill": "skill_task_id",
|
||||
**{t: f"{t}_task_id" for t in _STRUCTURE_INDEX_TYPES},
|
||||
}
|
||||
@@ -1525,7 +1525,7 @@ async def search_datasets(tenant_id: str, req: dict):
|
||||
# Artifact (knowledge compilation) page surface
|
||||
#
|
||||
# These three helpers power the dataset-level "Artifact" tab. They query rows
|
||||
# with ``compile_kwd="artifact_page"`` written by TaskHandler's
|
||||
# with ``compile_kwd="wiki_page"`` written by TaskHandler's
|
||||
# ``_persist_wiki_pages_to_es``. The schema fields they rely on are:
|
||||
# slug_kwd, title_kwd, page_type_kwd, content_with_weight,
|
||||
# topic_kwd, entity_names_kwd, outlinks_kwd, related_kb_pages_kwd,
|
||||
@@ -2867,11 +2867,11 @@ async def update_wiki_page(
|
||||
``outlinks_kwd`` is rebuilt from the link-transform pass.
|
||||
|
||||
Per the v1 contract, only the page row is updated. The canvas
|
||||
``artifact_page_graph`` / ``artifact_entity`` / ``artifact_relation``
|
||||
``wiki_page_graph`` / ``wiki_entity`` / ``wiki_relation``
|
||||
rows stay stale until the next full artifact compile.
|
||||
|
||||
Side effect: when the rendered post-save markdown differs from the
|
||||
prior stored content, one ``artifact_commit`` row is recorded
|
||||
prior stored content, one ``wiki_commit`` row is recorded
|
||||
(git-style audit). No-op saves are silently skipped — empty diff,
|
||||
no row.
|
||||
|
||||
@@ -3005,29 +3005,29 @@ async def update_wiki_page(
|
||||
|
||||
# All seven row types the artifact pipeline writes. Listed in dependency
|
||||
# order so partial failures of earlier deletes don't leave behind state
|
||||
# that downstream phases would silently reuse. ``artifact_page_graph``
|
||||
# that downstream phases would silently reuse. ``wiki_page_graph``
|
||||
# is the materialized canvas graph derived from the refined pages —
|
||||
# the dataset Artifact tab's graph view reads exactly this row.
|
||||
_WIKI_COMPILE_KWDS = (
|
||||
"artifact_map_extract",
|
||||
"artifact_reduce_result",
|
||||
"artifact_compilation_plan",
|
||||
"artifact_page_draft",
|
||||
"artifact_page",
|
||||
"artifact_page_topic",
|
||||
"artifact_entity",
|
||||
"artifact_relation",
|
||||
"wiki_map_extract",
|
||||
"wiki_reduce_result",
|
||||
"wiki_compilation_plan",
|
||||
"wiki_page_draft",
|
||||
"wiki_page",
|
||||
"wiki_page_topic",
|
||||
"wiki_entity",
|
||||
"wiki_relation",
|
||||
)
|
||||
|
||||
# Tunables for the incremental graph loader. See ``get_wiki_graph``.
|
||||
_WIKI_GRAPH_ENTITY_KWD = "artifact_entity"
|
||||
_WIKI_GRAPH_RELATION_KWD = "artifact_relation"
|
||||
_WIKI_GRAPH_ENTITY_KWD = "wiki_entity"
|
||||
_WIKI_GRAPH_RELATION_KWD = "wiki_relation"
|
||||
_WIKI_GRAPH_ENTITY_PAGE_SIZE = 32
|
||||
_WIKI_GRAPH_MAX_LOADING_ENTITY = 512
|
||||
|
||||
|
||||
def _wiki_entity_payload(row: dict) -> dict | None:
|
||||
"""Project one ``artifact_entity`` ES row onto the canvas entity shape.
|
||||
"""Project one ``wiki_entity`` ES row onto the canvas entity shape.
|
||||
|
||||
The row stores the canvas payload pre-built as JSON in
|
||||
``content_with_weight``; we parse it back and overlay the columns
|
||||
@@ -3085,11 +3085,11 @@ async def _wiki_search_entity_page(
|
||||
limit: int,
|
||||
keywords: str = "",
|
||||
):
|
||||
"""One page of artifact_entity rows.
|
||||
"""One page of wiki_entity rows.
|
||||
|
||||
Without ``keywords``: ordered by ``weight_int DESC`` (heaviest nodes first).
|
||||
With ``keywords``: BM25 full-text match over ``content_ltks`` (slug +
|
||||
summary), ordered by relevance. ``artifact_entity`` rows are BM25-only (no
|
||||
summary), ordered by relevance. ``wiki_entity`` rows are BM25-only (no
|
||||
embedding vector), so this is a lexical search, not a dense KNN.
|
||||
"""
|
||||
from common.doc_store.doc_store_base import OrderByExpr
|
||||
@@ -3214,23 +3214,23 @@ async def get_wiki_graph(
|
||||
|
||||
``top_n`` overrides the entity budget (default ``_WIKI_GRAPH_MAX_LOADING_ENTITY``).
|
||||
``keywords`` (overview mode only; ignored when ``node`` is given) seeds the
|
||||
graph from the best BM25 matches on ``artifact_entity`` rows instead of the
|
||||
graph from the best BM25 matches on ``wiki_entity`` rows instead of the
|
||||
heaviest-weighted ones. Only entities referenced by a relation are returned.
|
||||
|
||||
Two modes:
|
||||
|
||||
* **Overview** (``node`` is None) — paginate ``artifact_entity`` rows
|
||||
* **Overview** (``node`` is None) — paginate ``wiki_entity`` rows
|
||||
ordered by ``weight_int DESC`` in pages of
|
||||
``_WIKI_GRAPH_ENTITY_PAGE_SIZE``. For each page, append entities
|
||||
to a running set while the **cumulative** weight stays within
|
||||
``_WIKI_GRAPH_MAX_LOADING_ENTITY``. Pull ``artifact_relation``
|
||||
``_WIKI_GRAPH_MAX_LOADING_ENTITY``. Pull ``wiki_relation``
|
||||
rows whose ``from_kwd`` is in the just-added entities; pull the
|
||||
``to`` targets that we haven't seen yet (they count toward the same
|
||||
cap). Stop once the cap is hit, or the page is empty, or no entry
|
||||
from the page fit under the budget.
|
||||
|
||||
* **Click** (``node`` is a slug) — load the centre entity (always
|
||||
included), pull every ``artifact_relation`` with ``from_kwd=node``,
|
||||
included), pull every ``wiki_relation`` with ``from_kwd=node``,
|
||||
then pull the ``to`` entities. Capped at
|
||||
``_WIKI_GRAPH_MAX_LOADING_ENTITY`` for hub-node safety.
|
||||
|
||||
|
||||
@@ -862,8 +862,8 @@ class Knowledgebase(DataBaseModel):
|
||||
raptor_task_finish_at = DateTimeField(null=True)
|
||||
mindmap_task_id = CharField(max_length=32, null=True, help_text="Mindmap task ID", index=True)
|
||||
mindmap_task_finish_at = DateTimeField(null=True)
|
||||
artifact_task_id = CharField(max_length=32, null=True, help_text="Artifact compilation task ID", index=True)
|
||||
artifact_task_finish_at = DateTimeField(null=True)
|
||||
wiki_task_id = CharField(max_length=32, null=True, help_text="Artifact compilation task ID", index=True)
|
||||
wiki_task_finish_at = DateTimeField(null=True)
|
||||
skill_task_id = CharField(max_length=32, null=True, help_text="Skill generation task ID", index=True)
|
||||
skill_task_finish_at = DateTimeField(null=True)
|
||||
# KB-wide structure-graph merge tasks, one traceable task id per merged kind
|
||||
@@ -995,7 +995,7 @@ class FileCommitItem(DataBaseModel):
|
||||
# ``ArtifactCommit`` retired — artifact page history is now stored under
|
||||
# ``FileCommit`` + ``FileCommitItem`` via ``FileCommitService.record_page_edit``
|
||||
# (see the artifact-commit extension columns on those models above).
|
||||
# Pre-existing ``artifact_commit`` rows are intentionally left in place;
|
||||
# Pre-existing ``wiki_commit`` rows are intentionally left in place;
|
||||
# no code path reads them.
|
||||
|
||||
|
||||
@@ -1768,8 +1768,10 @@ def migrate_db():
|
||||
alter_db_add_column(migrator, "knowledgebase", "raptor_task_finish_at", DateTimeField(null=True))
|
||||
alter_db_add_column(migrator, "knowledgebase", "mindmap_task_id", CharField(max_length=32, null=True, help_text="Mindmap task ID", index=True))
|
||||
alter_db_add_column(migrator, "knowledgebase", "mindmap_task_finish_at", DateTimeField(null=True))
|
||||
alter_db_add_column(migrator, "knowledgebase", "artifact_task_id", CharField(max_length=32, null=True, help_text="Artifact compilation task ID", index=True))
|
||||
alter_db_add_column(migrator, "knowledgebase", "artifact_task_finish_at", DateTimeField(null=True))
|
||||
alter_db_rename_column(migrator, "knowledgebase", "artifact_task_id", "wiki_task_id")
|
||||
alter_db_rename_column(migrator, "knowledgebase", "artifact_task_finish_at", "wiki_task_finish_at")
|
||||
alter_db_add_column(migrator, "knowledgebase", "wiki_task_id", CharField(max_length=32, null=True, help_text="Artifact compilation task ID", index=True))
|
||||
alter_db_add_column(migrator, "knowledgebase", "wiki_task_finish_at", DateTimeField(null=True))
|
||||
alter_db_add_column(migrator, "knowledgebase", "skill_task_id", CharField(max_length=32, null=True, help_text="Skill generation task ID", index=True))
|
||||
alter_db_add_column(migrator, "knowledgebase", "skill_task_finish_at", DateTimeField(null=True))
|
||||
for _structure_type in ("structure_graph", "structure_mindmap", "timeline", "session_graph", "session_essence", "structure"):
|
||||
|
||||
@@ -531,7 +531,7 @@ class DocumentService(CommonService):
|
||||
# survives; one this doc solely owned is removed.
|
||||
try:
|
||||
if chunk_index_exists:
|
||||
cls.remove_artifact_products(doc, tenant_id)
|
||||
cls.remove_wiki_products(doc, tenant_id)
|
||||
except Exception as e:
|
||||
logging.warning(f"Failed to clean up artifact products for document {doc.id}: {e}")
|
||||
|
||||
@@ -582,7 +582,7 @@ class DocumentService(CommonService):
|
||||
page += 1
|
||||
|
||||
@classmethod
|
||||
def remove_artifact_products(cls, doc, tenant_id):
|
||||
def remove_wiki_products(cls, doc, tenant_id):
|
||||
"""Reference-counted cleanup of KB-scoped wiki/artifact products
|
||||
in the doc store when a document is deleted.
|
||||
|
||||
@@ -591,7 +591,7 @@ class DocumentService(CommonService):
|
||||
of the documents that contributed to it. On delete we detach
|
||||
``doc.id`` from that list and drop the row only when this document
|
||||
was its sole contributor — a product shared by other docs
|
||||
survives. ``artifact_map_extract`` resume rows are 1:1 with a
|
||||
survives. ``wiki_map_extract`` resume rows are 1:1 with a
|
||||
document and are removed directly by ``doc_id``.
|
||||
|
||||
The compile_kwd set is pulled from the wiki generator so new
|
||||
|
||||
@@ -53,12 +53,12 @@ logger = logging.getLogger(__name__)
|
||||
# Content storage for ``content_after`` is switched by a module-level
|
||||
# constant so ops can move blobs between MinIO and the doc-store index
|
||||
# without touching the schema.
|
||||
ARTIFACT_CONTENT_STORAGE = "minio" # one of {"minio", "es"}
|
||||
_ARTIFACT_COMMIT_BUCKET_PREFIX = ".artifact_commits"
|
||||
_ARTIFACT_ES_KWD = "artifact_commit_content"
|
||||
WIKI_CONTENT_STORAGE = "minio" # one of {"minio", "es"}
|
||||
_WIKI_COMMIT_BUCKET_PREFIX = ".wiki_commits"
|
||||
_WIKI_ES_KWD = "wiki_commit_content"
|
||||
|
||||
|
||||
def _artifact_file_id(kb_id: str, slug: str) -> str:
|
||||
def _wiki_file_id(kb_id: str, slug: str) -> str:
|
||||
"""Deterministic 32-char id for the artifact-page 'file' identity.
|
||||
|
||||
Not a real File row — just an index key that groups all commits for
|
||||
@@ -83,7 +83,7 @@ def _unified_diff(before: str, after: str, slug: str) -> str:
|
||||
|
||||
|
||||
def _store_content_after(kb_id: str, content: str) -> tuple[str, str]:
|
||||
"""Persist ``content`` per :data:`ARTIFACT_CONTENT_STORAGE`. Returns
|
||||
"""Persist ``content`` per :data:`WIKI_CONTENT_STORAGE`. Returns
|
||||
``(storage_kind, location)`` for the row's persistence columns.
|
||||
|
||||
Content-addressed by SHA-256 so re-saves with identical bodies share
|
||||
@@ -92,8 +92,8 @@ def _store_content_after(kb_id: str, content: str) -> tuple[str, str]:
|
||||
content_bytes = (content or "").encode("utf-8")
|
||||
content_hash = hashlib.sha256(content_bytes).hexdigest()
|
||||
|
||||
if ARTIFACT_CONTENT_STORAGE == "minio":
|
||||
location = f"{_ARTIFACT_COMMIT_BUCKET_PREFIX}/{content_hash}"
|
||||
if WIKI_CONTENT_STORAGE == "minio":
|
||||
location = f"{_WIKI_COMMIT_BUCKET_PREFIX}/{content_hash}"
|
||||
try:
|
||||
storage = settings.STORAGE_IMPL
|
||||
if storage is not None:
|
||||
@@ -106,7 +106,7 @@ def _store_content_after(kb_id: str, content: str) -> tuple[str, str]:
|
||||
)
|
||||
return "minio", location
|
||||
|
||||
if ARTIFACT_CONTENT_STORAGE == "es":
|
||||
if WIKI_CONTENT_STORAGE == "es":
|
||||
# Store as a single doc-store row so the same connector serves
|
||||
# reads. The row is not retrievable (available_int=0).
|
||||
from rag.nlp import search as _rag_search
|
||||
@@ -116,7 +116,7 @@ def _store_content_after(kb_id: str, content: str) -> tuple[str, str]:
|
||||
"id": content_hash,
|
||||
"kb_id": kb_id,
|
||||
"doc_id": kb_id,
|
||||
"compile_kwd": _ARTIFACT_ES_KWD,
|
||||
"compile_kwd": _WIKI_ES_KWD,
|
||||
"content_with_weight": content or "",
|
||||
"available_int": 0,
|
||||
}
|
||||
@@ -133,8 +133,8 @@ def _store_content_after(kb_id: str, content: str) -> tuple[str, str]:
|
||||
# Unknown storage kind — fall through with empty location; the
|
||||
# detail path treats missing location as "content not recoverable".
|
||||
logging.warning(
|
||||
"record_page_edit: unknown ARTIFACT_CONTENT_STORAGE=%r; content not persisted",
|
||||
ARTIFACT_CONTENT_STORAGE,
|
||||
"record_page_edit: unknown WIKI_CONTENT_STORAGE=%r; content not persisted",
|
||||
WIKI_CONTENT_STORAGE,
|
||||
)
|
||||
return "", ""
|
||||
|
||||
@@ -732,7 +732,7 @@ class FileCommitService(CommonService):
|
||||
final_title = f"{(title or '').strip() or f'{title_ts} {slug}'} "
|
||||
commit_id = get_uuid()
|
||||
item_id = get_uuid()
|
||||
file_id = _artifact_file_id(kb_id, slug)
|
||||
file_id = _wiki_file_id(kb_id, slug)
|
||||
now_ts = current_timestamp()
|
||||
now_dt = datetime_format(date_time=datetime.datetime.now())
|
||||
|
||||
@@ -819,7 +819,7 @@ class FileCommitService(CommonService):
|
||||
"""
|
||||
page = max(int(page or 1), 1)
|
||||
page_size = max(min(int(page_size or 50), 200), 1)
|
||||
file_id = _artifact_file_id(kb_id, slug)
|
||||
file_id = _wiki_file_id(kb_id, slug)
|
||||
|
||||
base = (
|
||||
FileCommit.select(
|
||||
|
||||
@@ -306,8 +306,8 @@ class KnowledgebaseService(CommonService):
|
||||
cls.model.raptor_task_finish_at,
|
||||
cls.model.mindmap_task_id,
|
||||
cls.model.mindmap_task_finish_at,
|
||||
cls.model.artifact_task_id,
|
||||
cls.model.artifact_task_finish_at,
|
||||
cls.model.wiki_task_id,
|
||||
cls.model.wiki_task_finish_at,
|
||||
cls.model.skill_task_id,
|
||||
cls.model.skill_task_finish_at,
|
||||
cls.model.structure_graph_task_id,
|
||||
|
||||
@@ -40,7 +40,7 @@ _PIPELINE_TASK_TYPE_TO_FINISH_FIELD = {
|
||||
PipelineTaskType.GRAPH_RAG: "graphrag_task_finish_at",
|
||||
PipelineTaskType.RAPTOR: "raptor_task_finish_at",
|
||||
PipelineTaskType.MINDMAP: "mindmap_task_finish_at",
|
||||
PipelineTaskType.ARTIFACT: "artifact_task_finish_at",
|
||||
PipelineTaskType.ARTIFACT: "wiki_task_finish_at",
|
||||
PipelineTaskType.SKILL: "skill_task_finish_at",
|
||||
PipelineTaskType.STRUCTURE_GRAPH: "structure_graph_task_finish_at",
|
||||
PipelineTaskType.STRUCTURE_MINDMAP: "structure_mindmap_task_finish_at",
|
||||
|
||||
Reference in New Issue
Block a user