从URL加载文档内容
(self, url: str)
| 134 | return None |
| 135 | |
| 136 | async def _load_document_from_url(self, url: str) -> str | None: |
| 137 | """从URL加载文档内容""" |
| 138 | try: |
| 139 | loader = WebBaseLoader([url]) |
| 140 | documents = loader.load() |
| 141 | if documents: |
| 142 | return documents[0].page_content |
| 143 | return None |
| 144 | |
| 145 | except Exception as e: |
| 146 | logger.error(f"Failed to load document from URL {url}: {str(e)}") |
| 147 | return None |
| 148 | |
| 149 | async def _chunk_document(self, content: str) -> list[str]: |
| 150 | """将文档切分为多个块""" |
no test coverage detected