MCPcopy Create free account
hub / github.com/Negai-ai/AgentClaw / process

Method process

agentclaw/node/document.py:84–103  ·  view source on GitHub ↗

解析文档,支持单个路径、路径列表或文件 meta 列表

(self, **state)

Source from the content-addressed store, hash-verified

82 self._audio_service = audio_service
83
84 def process(self, **state) -> Dict[str, Any]:
85 """解析文档,支持单个路径、路径列表或文件 meta 列表"""
86 doc_input = state.get(self.input_key)
87 if not doc_input:
88 logger.warning(f"DocumentNode: 未找到文档路径 (key={self.input_key})")
89 return {self.get_output_key(): ""}
90
91 # 支持多种输入格式:
92 # str — 单个文件路径 (File 类型)
93 # list[str] — 文件路径列表
94 # list[dict] — 文件 meta 列表 (Files 类型: [{file_path, original_name, ...}])
95 if isinstance(doc_input, list):
96 file_infos = self._normalize_file_inputs(doc_input)
97 results = [self._parse_file(info["file_path"]) for info in file_infos if info.get("file_path")]
98 combined = "\n\n---\n\n".join(r for r in results if r)
99 return {self.get_output_key(): combined}
100 else:
101 file_info = self._normalize_file_input(doc_input)
102 content = self._parse_file(file_info["file_path"]) if file_info.get("file_path") else ""
103 return {self.get_output_key(): content}
104
105 async def async_execute(self, state: dict, context) -> Dict[str, Any]:
106 """解析文档;配置 ASR 时音频文件走异步转写。"""

Callers 1

processMethod · 0.45

Calls 5

_parse_fileMethod · 0.95
_normalize_file_inputMethod · 0.95
getMethod · 0.45
get_output_keyMethod · 0.45

Tested by

no test coverage detected