OpenViking 快速开始指南

🎯 一句话总结

OpenViking 是火山引擎开源的 AI Agent 上下文数据库,让 AI 拥有跨会话记忆能力。

🚀 5 分钟快速上手

1. 注册火山引擎账号

2. 获取 API Key

3. 激活模型

4. 安装 OpenViking

pip install openviking --upgrade --force-reinstall

5. 创建配置文件

创建 ~/.openviking/ov.conf:

{
  "storage": {
    "workspace": "D:/openviking_workspace"
  },
  "log": {
    "level": "INFO",
    "output": "stdout"
  },
  "embedding": {
    "dense": {
      "backend": "volcengine",
      "api_key": "YOUR_API_KEY_HERE",
      "model": "doubao-embedding-vision-251215",
      "api_base": "https://ark.cn-beijing.volces.com/api/coding/v3",
      "dimension": 1024,
      "input": "multimodal"
    }
  },
  "vlm": {
    "backend": "volcengine",
    "api_key": "YOUR_API_KEY_HERE",
    "model": "doubao-seed-2-0-pro-260215",
    "api_base": "https://ark.cn-beijing.volces.com/api/coding/v3",
    "temperature": 0.1,
    "max_retries": 3
  }
}

6. 设置环境变量

Windows PowerShell:

$env:OPENVIKING_CONFIG_FILE = "$HOME/.openviking/ov.conf"

Linux/macOS:

export OPENVIKING_CONFIG_FILE=~/.openviking/ov.conf

💡 基本使用示例

Python SDK

import openviking as ov

# 初始化客户端
client = ov.OpenViking(path="./data")
client.initialize()

# 添加资源
add_result = client.add_resource(
    path="https://raw.githubusercontent.com/volcengine/OpenViking/refs/heads/main/README.md"
)
root_uri = add_result['root_uri']

# 查看目录结构
ls_result = client.ls(root_uri)
print(f"Directory structure:\n{ls_result}\n")

# 等待语义处理
print("Wait for semantic processing...")
client.wait_processed()

# 获取摘要和概览
abstract = client.abstract(root_uri)
overview = client.overview(root_uri)

print(f"L0 Abstract:\n{abstract}\n")
print(f"L1 Overview:\n{overview[:500]}...\n")

# 语义搜索
results = client.find("what is openviking", target_uri=root_uri)
print(f"Search results:\n{results}\n")

# 断开连接
client.disconnect()

CLI 命令

# 添加资源
openviking add-resource https://raw.githubusercontent.com/volcengine/OpenViking/refs/heads/main/README.md

# 搜索资源
openviking find "what is openviking"

# 健康检查
curl http://localhost:1933/health

🎯 核心功能

1. 分层记忆

  • L0 摘要: 快速概览,节省 Token
  • L1 概览: 核心信息,辅助决策
  • L2 详情: 完整内容,深度分析

2. 语义搜索

  • 支持自然语言查询
  • 智能匹配相关内容
  • 返回相关性评分

3. 资源管理

  • 支持多种文件格式
  • 自动分类和组织
  • 版本控制和更新

🔧 常见问题

Q: API Key 无效?

A: 确保从正确的区域获取,并以 sk- 开头

Q: 模型未激活?

A: 前往模型管理页面激活所需模型

Q: 网络连接问题?

A: 检查防火墙设置,确认 API Base URL 正确

📚 更多资源

🎉 开始使用

配置完成后,你就可以:

  1. 为 AI Agent 添加长期记忆
  2. 实现跨会话的信息持久化
  3. 构建更智能的对话系统
  4. 优化 Token 使用效率

祝使用愉快!

← 返回文章列表