用途
OpenViking(简称 ov)的 add-resource 命令用于将外部资源导入 OpenViking 的上下文数据库。它支持本地文件、目录、URL 以及远程仓库,导入的资源会自动进行语义分析,并组织在 viking://resources/ 命名空间下。
何时使用
- 导入项目文档、代码仓库或参考资料
- 添加网页、文章或在线资源以供后续检索
- 从外部来源构建知识库
- 当智能体遇到需要跨会话持久保存的有价值内容时
主要能力
- 支持导入本地文件、本地目录、URL 和远程仓库
- 自动对导入资源进行语义分析
- 将资源组织在 viking://resources/ 命名空间下
- 可通过参数提供导入原因和处理指令,引导处理过程
- 支持异步处理控制,可选择等待处理完成或即发即忘
使用方式
基本用法
导入本地文件或 URL:
# Import from URL
ov add-resource https://raw.githubusercontent.com/volcengine/OpenViking/main/README.md
# Import local file
ov add-resource ./docs/api-spec.md
# Import local directory
ov add-resource ./project-source
上下文与指令
添加元数据以引导处理:
# Provide reason for import
ov add-resource ./api-docs.md --reason "REST API documentation for v2 endpoints"
# Add processing instructions
ov add-resource ./large-repo --instruction "Focus on authentication and authorization patterns"
# Combine reason and instruction
ov add-resource https://example.com/guide --reason "User guide" --instruction "Extract best practices and examples"
异步处理控制
等待语义处理完成:
# Wait until processing finishes
ov add-resource ./docs --wait
# Wait with timeout (in seconds)
ov add-resource https://example.com/docs --wait --timeout 60
# Fire and forget (default)
ov add-resource ./docs
输出
返回导入资源的根 URI:
root_uri viking://resources/...
适用场景
- 智能体在交互过程中需要添加文件、URL 或外部知识
- 导入项目文档、代码仓库或参考资料
- 添加网页、文章或在线资源以供后续检索
- 从外部来源构建知识库
- 智能体遇到需要跨会话持久保存的有价值内容
限制与前提
- 需要已配置 CLI:~/.openviking/ovcli.conf
- URL 导入需要网络访问
- 本地文件或目录需要读取权限
- 关于收费、价格、平台支持范围等更多信息,资料暂未提供