mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-30 04:15:45 +08:00
feat: add list kbengine and parser api (#89)
This commit is contained in:
@@ -177,12 +177,22 @@ async def ingest(self, context: IngestionContext) -> IngestionResult:
|
||||
|
||||
## 跨插件调用解析器
|
||||
|
||||
KnowledgeEngine 插件可以通过 `self.plugin.invoke_parser` 方法调用其他插件提供的解析器:
|
||||
在调用其他插件提供的解析器之前,可以先通过 `self.plugin.list_parsers` 枚举当前可用的解析器:
|
||||
|
||||
```python
|
||||
parsers = await self.plugin.list_parsers(mime_type="application/pdf")
|
||||
# 返回的每项包含 plugin_id、plugin_author、plugin_name、name、description、supported_mime_types
|
||||
```
|
||||
|
||||
若返回空列表,说明宿主当前没有已连接且支持该 MIME 类型的 Parser 插件。
|
||||
|
||||
拿到 `plugin_author` 和 `plugin_name` 后,即可通过 `self.plugin.invoke_parser` 调用对应解析器:
|
||||
|
||||
```python
|
||||
parser = parsers[0]
|
||||
result = await self.plugin.invoke_parser(
|
||||
plugin_author="author_name",
|
||||
plugin_name="plugin_name",
|
||||
plugin_author=parser["plugin_author"],
|
||||
plugin_name=parser["plugin_name"],
|
||||
storage_path=context.file_object.storage_path,
|
||||
mime_type=context.file_object.metadata.mime_type,
|
||||
filename=context.file_object.metadata.filename,
|
||||
|
||||
Reference in New Issue
Block a user