优化知识库结构与分类器提示词
This commit is contained in:
@@ -103,16 +103,23 @@ def get_documents(directory: Path):
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
count = 0
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if not line:
|
||||
continue
|
||||
try:
|
||||
record = json.loads(line)
|
||||
# 优先使用 record 中的 "text" 字段,若无则用整条记录的 JSON 作为文档内容
|
||||
if 'text' in record and isinstance(record['text'], str):
|
||||
documents.append({
|
||||
"text": record['text'],
|
||||
"metadata": {"source": str(file_path.name)}
|
||||
})
|
||||
count += 1
|
||||
text = record['text']
|
||||
else:
|
||||
text = json.dumps(record, ensure_ascii=False)
|
||||
documents.append({
|
||||
"text": text,
|
||||
"metadata": {"source": str(file_path.name)}
|
||||
})
|
||||
count += 1
|
||||
except json.JSONDecodeError:
|
||||
logging.warning(f"跳过无效的JSON行: {line.strip()}")
|
||||
logging.warning(f"跳过无效的JSON行: {line[:80]}{'...' if len(line) > 80 else ''}")
|
||||
if count > 0:
|
||||
logging.info(f"成功处理NDJSON文件: {file_path.name}, 提取了 {count} 个文档。")
|
||||
# 对其他所有文件类型,使用unstructured
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
{"text": "在地图上有一个名为 '跷跷板' 的地点或区域,它的leisure是'playground',其中心位置坐标大约在东南天坐标系 (x:15, y:-8.5, z:1.2)。"}
|
||||
{"text": "在地图上有一个名为 'A地' 的地点或区域,它的building是'commercial',其中心位置坐标大约在东南天坐标系 (x:10, y:-10, z:2)。"}
|
||||
{"text": "在地图上有一个名为 '学生宿舍' 的地点或区域,它的building是'dormitory',其中心位置坐标大约在东南天坐标系 (x:5, y:3, z:2)。"}
|
||||
{"text": "地点:'研究所正大门'。别名:'大门'、'入口'。东南天坐标系坐标:(x:-23.8, y:292.8, z:14)。建议悬停高度:14米。适合任务:定点侦察、拍照。"}
|
||||
{"text": "地点:'广场'。属性:开阔区域。东南天坐标系坐标:(x:-17, y:360.0, z:3.0)。"}
|
||||
{"text": "对于查找搜索类任务,比如查找某个人或者东西,我们可以让无人机执行rotate_search动作节点,让无人机以自身为原点旋转,观察四周,确保无人机主动寻找目标。"}
|
||||
{"text": "大楼外围四个点东南天坐标系坐标:A(-24.00, 241.80),B(-108.50, 241.80),C(-108.50, 289.80),D(-24.00, 292.80)。"}
|
||||
{"text": "当指令中要求紧急返航到某地时,必须使用fly_to_waypoint节点,严禁使用return_emergency节点。"}
|
||||
{"property": "location", "information": {"name": "飞行场地", "coordinates": {"x": 0, "y": 0, "z": 0}}}
|
||||
{"property": "rules", "information": {"name": "紧急返航", "description": "当指令中要求紧急返航到某地时,必须使用fly_to_waypoint节点,严禁使用return_emergency节点。"}}
|
||||
{"property": "location", "information": {"name": "大楼外围四个点东南天坐标系坐标", "coordinates": {"A": {"x": -24.00, "y": 241.80, "z": 0}, "B": {"x": -108.50, "y": 241.80, "z": 0}, "C": {"x": -108.50, "y": 289.80, "z": 0}, "D": {"x": -24.00, "y": 292.80, "z": 0}}}}
|
||||
|
||||
Reference in New Issue
Block a user