mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-17 13:17:20 +08:00
143 lines
74 KiB
JSON
143 lines
74 KiB
JSON
|
|
{
|
|||
|
|
"globals": {
|
|||
|
|
"sys.conversation_turns": 0,
|
|||
|
|
"sys.date": "",
|
|||
|
|
"sys.files": [],
|
|||
|
|
"sys.history": [],
|
|||
|
|
"sys.query": "",
|
|||
|
|
"sys.user_id": ""
|
|||
|
|
},
|
|||
|
|
"graph": {
|
|||
|
|
"edges": [
|
|||
|
|
{
|
|||
|
|
"data": {
|
|||
|
|
"isHovered": false
|
|||
|
|
},
|
|||
|
|
"id": "xy-edge__beginstart-CodeExec:VioletMemesJoinend",
|
|||
|
|
"source": "begin",
|
|||
|
|
"sourceHandle": "start",
|
|||
|
|
"target": "CodeExec:VioletMemesJoin",
|
|||
|
|
"targetHandle": "end"
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
"data": {
|
|||
|
|
"isHovered": false
|
|||
|
|
},
|
|||
|
|
"id": "xy-edge__CodeExec:VioletMemesJoinstart-Message:WackyWeeksTravelend",
|
|||
|
|
"source": "CodeExec:VioletMemesJoin",
|
|||
|
|
"sourceHandle": "start",
|
|||
|
|
"target": "Message:WackyWeeksTravel",
|
|||
|
|
"targetHandle": "end"
|
|||
|
|
}
|
|||
|
|
],
|
|||
|
|
"nodes": [
|
|||
|
|
{
|
|||
|
|
"data": {
|
|||
|
|
"form": {
|
|||
|
|
"inputs": {
|
|||
|
|
"tz": {
|
|||
|
|
"key": "tz",
|
|||
|
|
"name": "tz",
|
|||
|
|
"optional": false,
|
|||
|
|
"options": [],
|
|||
|
|
"type": "file",
|
|||
|
|
"value": [
|
|||
|
|
{
|
|||
|
|
"created_at": 1779691169.3897872,
|
|||
|
|
"created_by": "861828e42cc111f1b540c1d623001acf",
|
|||
|
|
"extension": "dxf",
|
|||
|
|
"id": "7b1c92f4580411f1b35d9d889eb78c1a",
|
|||
|
|
"mime_type": "application/octet-stream",
|
|||
|
|
"name": "DIE-5.dxf",
|
|||
|
|
"preview_url": null,
|
|||
|
|
"size": 365963
|
|||
|
|
}
|
|||
|
|
]
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
"mode": "conversational",
|
|||
|
|
"outputs": {},
|
|||
|
|
"prologue": "Hi! I'm your assistant. What can I do for you?"
|
|||
|
|
},
|
|||
|
|
"label": "Begin",
|
|||
|
|
"name": "begin"
|
|||
|
|
},
|
|||
|
|
"dragging": false,
|
|||
|
|
"id": "begin",
|
|||
|
|
"measured": {
|
|||
|
|
"height": 109,
|
|||
|
|
"width": 200
|
|||
|
|
},
|
|||
|
|
"position": {
|
|||
|
|
"x": -30,
|
|||
|
|
"y": 56
|
|||
|
|
},
|
|||
|
|
"selected": false,
|
|||
|
|
"sourcePosition": "left",
|
|||
|
|
"targetPosition": "right",
|
|||
|
|
"type": "beginNode"
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
"data": {
|
|||
|
|
"form": {
|
|||
|
|
"arguments": {
|
|||
|
|
"tz": "begin@tz"
|
|||
|
|
},
|
|||
|
|
"lang": "python",
|
|||
|
|
"outputs": {
|
|||
|
|
"result": {
|
|||
|
|
"type": "String",
|
|||
|
|
"value": null
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
"script": "import os\nimport re\nimport math\nimport json\nimport base64\nimport hashlib\nimport io\nimport tempfile\nimport subprocess\nimport sys\nimport xml.etree.ElementTree as ET\nfrom typing import Any, Optional\n\n\n# ============================================================\n# 0. 依赖处理\n# ============================================================\n\ntry:\n import ezdxf\nexcept ModuleNotFoundError:\n subprocess.check_call(\n [sys.executable, \"-m\", \"pip\", \"install\", \"ezdxf\", \"--quiet\"]\n )\n import ezdxf\n\n\n# ============================================================\n# 1. 全局配置\n# ============================================================\n\nCAD_SYMBOL_MAP = {\n \"%%c\": \"⌀\",\n \"%%C\": \"⌀\",\n \"%%p\": \"±\",\n \"%%P\": \"±\",\n \"%%d\": \"°\",\n \"%%D\": \"°\",\n \"φ\": \"⌀\",\n \"Φ\": \"⌀\",\n \"Ø\": \"⌀\",\n \"ø\": \"⌀\",\n}\n\nFEATURE_RULES = {\n \"A\": {\n \"type\": \"thread_hole\",\n \"label\": \"A 螺纹孔/定位孔\",\n },\n \"E\": {\n \"type\": \"wire_cut\",\n \"label\": \"E 线割孔/割孔\",\n },\n \"F\": {\n \"type\": \"insert_fixing_hole\",\n \"label\": \"F 镶件固定孔\",\n },\n \"G\": {\n \"type\": \"wire_cut\",\n \"label\": \"G 冲切刀口/线割\",\n },\n \"J\": {\n \"type\": \"counterbore\",\n \"label\": \"J 贯穿沉孔\",\n },\n \"L1\": {\n \"type\": \"slot_or_wire_cut\",\n \"label\": \"L1 槽/线切割\",\n },\n \"S\": {\n \"type\": \"screw_hole\",\n \"label\": \"S 螺丝孔/特殊孔\",\n },\n \"T\": {\n \"type\": \"thread_hole\",\n \"label\": \"T 攻牙孔\",\n },\n \"X\": {\n \"type\": \"special_process\",\n \"label\": \"X 特殊加工\",\n },\n}\n\nEXPECTED_FEATURE_CODES = set(FEATURE_RULES.keys())\n\nIGNORE_FEATURE_LAYERS = {\n \"图框线\",\n \"图框\",\n \"标题栏\",\n \"TITLE\",\n \"BORDER\",\n \"FRAME\",\n \"DIM\",\n \"DIMENSION\",\n \"CENTER\",\n \"公差\",\n}\n\nTECH_KEYWORDS = [\n \"加工说明\",\n \"技术要求\",\n \"割\",\n \"线割\",\n \"孔\",\n \"沉头\",\n \"沉孔\",\n \"贯穿\",\n \"攻\",\n \"攻牙\",\n \"镶件\",\n \"固定孔\",\n \"深\",\n \"M12\",\n \"M10\",\n \"M8\",\n \"M6\",\n \"M5\",\n \"M4\",\n \"刀口\",\n \"国产\",\n \"SKD61\",\n \"热处理\",\n \"硬度\",\n \"倒角\",\n \"去毛刺\",\n \"粗糙度\",\n \"公差\",\n \"穿孔机\",\n \"基准孔\",\n \"刃口\",\n \"零件名称\",\n]\n\n\n# ============================================================\n# 2. 基础工具函数\n# ============================================================\n\ndef safe_float(value: Any, default: Optional[float] = None) -> Optional[float]:\n try:\n return float(value)\n except Exception:\n return default\n\n\ndef round_num(value: Any, ndigits: int = 3) -> Optional[float]:\n value = safe_float(value)\n if value is None:\n return None\n return round(value, ndigits)\n\n\ndef distance(p1: dict, p2: dict) -> float:\n return math.sqrt((p1[\"x\"] - p2[\"x\"]) ** 2 + (p1[\"y\"] - p2[\"y\"]) ** 2)\n\n\ndef clean_cad_text(text: Any) -> str:\n if text is None:\n return \"\"\n\n text = str(text)\n\n for src, dst in CAD_SYMBOL_MAP.items():\n text = text.replace(src, dst)\n\n text = text.replace(\"\\\\P\", \"\\n\").replace(\"\\\\p\", \"\\n\")\n\n text = re.sub(r\"\\\\S([^;^]+)\\^([^;]+);\", r\"\\1/\\2\", text)\n text = re.sub(r\"\\\\S([^;/]+)/([^;]+);\", r\"\\1/\\2\", text)\n\n text = re.sub(r\"\\\\[AaCcFfHhLlOoQqTtWw][^;]*;\", \"\", text)\n text = text.replace(\"{\", \"\").replace(\"}\", \"\")\n text = re.sub(r\"\\\\[A-Za-z]+\", \"\", text)\n text = re.sub(r\"\\s*[::]\\s*\", \" : \", text)\n text = re.sub(r\"[ \\t\\r\\f\\v]+\", \" \", text)\n text = re.sub(r
|
|||
|
|
},
|
|||
|
|
"label": "CodeExec",
|
|||
|
|
"name": "代码_0"
|
|||
|
|
},
|
|||
|
|
"dragging": false,
|
|||
|
|
"id": "CodeExec:VioletMemesJoin",
|
|||
|
|
"measured": {
|
|||
|
|
"height": 49,
|
|||
|
|
"width": 200
|
|||
|
|
},
|
|||
|
|
"position": {
|
|||
|
|
"x": 131,
|
|||
|
|
"y": 241.75
|
|||
|
|
},
|
|||
|
|
"selected": true,
|
|||
|
|
"sourcePosition": "right",
|
|||
|
|
"targetPosition": "left",
|
|||
|
|
"type": "ragNode"
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
"data": {
|
|||
|
|
"form": {
|
|||
|
|
"content": [
|
|||
|
|
"{CodeExec:VioletMemesJoin@result}"
|
|||
|
|
],
|
|||
|
|
"output_format": "md"
|
|||
|
|
},
|
|||
|
|
"label": "Message",
|
|||
|
|
"name": "回复消息_0"
|
|||
|
|
},
|
|||
|
|
"dragging": false,
|
|||
|
|
"id": "Message:WackyWeeksTravel",
|
|||
|
|
"measured": {
|
|||
|
|
"height": 85,
|
|||
|
|
"width": 200
|
|||
|
|
},
|
|||
|
|
"position": {
|
|||
|
|
"x": 309.5,
|
|||
|
|
"y": 67.75
|
|||
|
|
},
|
|||
|
|
"selected": false,
|
|||
|
|
"sourcePosition": "right",
|
|||
|
|
"targetPosition": "left",
|
|||
|
|
"type": "messageNode"
|
|||
|
|
}
|
|||
|
|
]
|
|||
|
|
},
|
|||
|
|
"variables": []
|
|||
|
|
}
|