Generate navigation, navigation search (#18096)

### Summary
2 API

POST /api/v1/datasets/{dataset_id}/navigation

GET
/api/v1/datasets/{dataset_id}/navigation/search?q={query}&mode={mode}&top_k={topk}


2 cli

uv run --no-sync python3 admin/client/ragflow_cli.py -h 127.0.0.1 -p
9380 -t user

ragflow> GENERATE NAVIGATION OF DATASET 'frames tree';

ragflow> NAVIGATION SEARCH 'Christie introduced blockchain-based digital
passports' IN DATASET 'frames tree' MODE 'all' topk 20;

(mode: chunk, nav_cluster, nav_doc, navigation_tree, all)
This commit is contained in:
qinling0210
2026-08-11 17:48:24 +08:00
committed by GitHub
parent a399b93143
commit d49af7f218
12 changed files with 1270 additions and 93 deletions

View File

@@ -112,6 +112,8 @@ sql_command: login_user
| set_license
| set_license_config
| show_license
| generate_nav_for_dataset
| navigation_search
| check_license
| benchmark
@@ -171,6 +173,9 @@ ENVS: "ENVS"i
KEY: "KEY"i
KEYS: "KEYS"i
GENERATE: "GENERATE"i
NAVIGATION: "NAVIGATION"i
MODE: "MODE"i
TOPK: "TOPK"i
MODEL: "MODEL"i
MODELS: "MODELS"i
PROVIDER: "PROVIDER"i
@@ -194,6 +199,7 @@ SIZE: "SIZE"i
PARSER: "PARSER"i
PIPELINE: "PIPELINE"i
SEARCH: "SEARCH"i
EXPLORE: "EXPLORE"i
CURRENT: "CURRENT"i
LLM: "LLM"i
VLM: "VLM"i
@@ -373,6 +379,8 @@ create_metadata_table: CREATE METADATA TABLE ";"
drop_metadata_table: DROP METADATA TABLE ";"
insert_dataset_from_file: INSERT DATASET FROM FILE quoted_string ";"
insert_metadata_from_file: INSERT METADATA FROM FILE quoted_string ";"
generate_nav_for_dataset: GENERATE NAVIGATION OF DATASET quoted_string ";"
navigation_search: NAVIGATION SEARCH quoted_string IN DATASET quoted_string MODE quoted_string (TOPK NUMBER)? ";"
update_chunk: UPDATE CHUNK quoted_string OF DATASET quoted_string SET quoted_string ";"
identifier_list: identifier (COMMA identifier)*
@@ -788,6 +796,35 @@ class RAGFlowCLITransformer(Transformer):
file_path = items[4].children[0].strip("'\"")
return {"type": "insert_metadata_from_file", "file_path": file_path}
def generate_nav_for_dataset(self, items):
dataset_id = items[4].children[0].strip("'\"")
return {"type": "generate_nav_for_dataset", "dataset_id": dataset_id}
def navigation_search(self, items):
query = items[2].children[0].strip("'\"")
dataset_name = items[5].children[0].strip("'\"")
mode = items[7].children[0].strip("'\"")
topk = None
# If TOPK was specified, items will be longer.
if len(items) > 9:
try:
extra = items[8]
if hasattr(extra, "data"):
# group wrapper: extra.children = [TOPK, NUMBER]
topk = int(extra.children[1])
else:
# flattened: items[8] = TOPK, items[9] = NUMBER
topk = int(items[9])
except (ValueError, IndexError):
topk = None
return {
"type": "navigation_search",
"query": query,
"dataset_id": dataset_name,
"mode": mode,
"topk": topk,
}
def update_chunk(self, items):
def get_quoted_value(item):
if hasattr(item, "children") and item.children: