Replies: 1 comment 1 reply
-
|
will chat cmd keep session? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
RFC: OpenViking CLI Support for ov chat Command
Author: OpenViking Team
Status: Implemented
Date: 2025-03-03
1. Executive Summary / 执行摘要
This document describes the integration architecture between
ovCLI (Rust),openviking-server(Python/FastAPI), andvikingbot(Python AI agent framework). The goal is to provide a unified chat interface where the bot service shares the same port and authentication mechanism as the OpenViking server.本文档描述了
ovCLI(Rust)、openviking-server(Python/FastAPI)和vikingbot(Python AI agent 框架)之间的集成架构。目标是提供一个统一的聊天界面,使 bot 服务与 OpenViking 服务器共享相同的端口和认证机制。2. Architecture Overview / 架构概览
2.1 系统整体架构 / System Architecture
部署说明 / Deployment Note: OpenViking Server 和 Vikingbot 部署在同一台机器上,通过本地端口通信。
flowchart TB subgraph Client["客户端 / Client (可远程)"] CLI["ov CLI<br/>(Rust)"] end subgraph SameMachine["同一台机器 / Same Machine"] direction TB subgraph Server["OpenViking Server<br/>(Python/FastAPI, Port 1933)"] Auth["统一认证中间件<br/>Unified Auth"] BotAPIProxy["Bot API Proxy<br/>(--with-bot)"] BotRouter["/api/v1/bot/*<br/>Router"] end subgraph Vikingbot["Vikingbot (Process 2, Port 18791)"] subgraph Channels["Channels (BaseChannel 实现)"] OC["OpenAPIChannel"] FC["FeishuChannel<br/>(Webhook)"] DC["DiscordChannel"] TC["TelegramChannel"] end MB["MessageBus"] AL["Agent Loop"] end end CLI -->|"HTTP + API Key"| Auth Auth --> BotAPIProxy BotAPIProxy -->|"Proxy to"| BotRouter BotRouter -->|"Forward to"| OC FC -->|"Webhook Events"| MB DC -->|"WebSocket"| MB TC -->|"Bot API"| MB OC -->|"send_to_bus()"| MB MB --> AL OC -.->|"implements"| BaseChannel["BaseChannel"] FC -.->|"implements"| BaseChannel DC -.->|"implements"| BaseChannel TC -.->|"implements"| BaseChannel2.2 Channel-Bus-Agent 架构详解
展示 Channel 与 MessageBus 的关系,以及各 Channel 如何作为 BaseChannel 实现:
flowchart TB subgraph Vikingbot["Vikingbot Core"] direction TB subgraph BaseChannelImpl["BaseChannel Implementations / 通道实现"] direction LR subgraph OC["OpenAPIChannel<br/>(HTTP API 通道)"] OCEndpoints["Endpoints:<br/>- /chat<br/>- /chat/stream<br/>- /health<br/>- /docs"] OCService["Service:<br/>OpenAPIChannelService"] end subgraph FC["FeishuChannel<br/>(飞书 Webhook)"] FCEndpoints["Endpoints:<br/>- /webhook/event<br/>- /webhook/card"] FCService["Service:<br/>FeishuChannelService"] end subgraph Others["Other Channels"] Discord["DiscordChannel"] Telegram["TelegramChannel"] Slack["SlackChannel"] end end subgraph Core["Core Components / 核心组件"] MB["MessageBus<br/>消息总线<br/><br/>- inbound queue<br/>- outbound queue<br/>- log store"] AL["Agent Loop<br/>代理循环<br/><br/>- ContextBuilder<br/>- LLM (LiteLLM)<br/>- Tool Executor"] end end subgraph External["External Clients / 外部客户端"] CLI["ov CLI"] FeishuApp["Feishu App<br/>飞书应用"] DiscordClient["Discord Client"] end CLI -->|"HTTP POST<br/>http://localhost:18791/chat"| OCEndpoints FeishuApp -->|"Webhook POST<br/>/webhook/event"| FCEndpoints DiscordClient -->|"WebSocket"| Discord OCEndpoints --> OCService FCEndpoints --> FCService OCService -->|"send_to_bus()<br/>message → bus"| MB FCService -->|"send_to_bus()<br/>message → bus"| MB Discord -->|"send_to_bus()"| MB Telegram -->|"send_to_bus()"| MB MB -->|"consume"| AL AL -->|"reply"| MB MB -->|"dispatch"| OCService MB -->|"dispatch"| FCService classDef channelClass fill:#e1f5fe,stroke:#01579b,stroke-width:2px classDef coreClass fill:#fff3e0,stroke:#e65100,stroke-width:2px classDef externalClass fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px class OC,FC,Discord,Telegram,Others channelClass class MB,AL coreClass class CLI,FeishuApp,DiscordClient externalClass3. Key Components / 关键组件
3.1 OpenViking Server (
openviking-server)Role: HTTP API Gateway with Bot API proxy / 带 Bot API 代理的 HTTP API 网关
Key Features / 主要特性:
--with-bot) / Bot API 代理层(通过--with-bot启用)Architecture Position / 架构位置:
3.2
ovCLI Client (ov chat)Role: Command-line chat interface / 命令行聊天界面
Key Features / 主要特性:
Architecture Position / 架构位置:
3.3 Vikingbot OpenAPIChannel
Role: AI agent framework with HTTP API / 带 HTTP API 的 AI 代理框架
Key Features / 主要特性:
Architecture Position / 架构位置:
3.4 MessageBus and Agent Loop / 消息总线与代理循环
Role: Core message routing and processing engine / 核心消息路由和处理引擎
Components / 组件:
Flow / 流程:
4. API Endpoints / API 端点
4.1 Bot API (via OpenViking Server)
/api/v1/bot/health/api/v1/bot/chat/api/v1/bot/chat/stream4.2 Response Codes
--with-botnot enabled or bot service unavailable5. Usage Examples / 使用示例
5.1 Start the services / 启动服务
说明 / Note:
--with-bot: 自动在同一机器上启动vikingbot gateway进程--with-bot: 仅启动 OpenViking Server,不会启动 Vikingbot设计意图 / Design Rationale:
OpenViking Server 统一代理 Vikingbot 的 CLI 请求,目的是:
5.2 Using
ov chatCLI / 使用ov chatCLI5.3 Direct HTTP API usage / 直接 HTTP API 使用
6. Configuration / 配置
6.1 配置共享说明 / Configuration Sharing
重要 / Important: Vikingbot 与 OpenViking Server 共享同一个
ov.conf配置文件,不再使用~/.vikingbot/config.json。Vikingbot 的配置项统一放在
ov.conf的bot字段下:{ "server": { "host": "127.0.0.1", "port": 1933, "root_api_key": "your-api-key", "with_bot": true, "bot_api_url": "http://localhost:18791" }, "bot": { "agents": { "model": "openai/gpt-4o", "max_tool_iterations": 50, "memory_window": 50 }, "gateway": { "host": "0.0.0.0", "port": 18791 }, "channels": [ {"type": "feishu", "enabled": false, "app_id": "", "app_secret": ""} ], "sandbox": { "backend": "direct", "mode": "shared" } } }配置说明 / Configuration Notes:
server.with_bot: 启用时自动在同一机器上启动 Vikingbot gatewaybot.agents: Agent 配置,包括 LLM 模型、最大工具迭代次数、记忆窗口bot.gateway: HTTP Gateway 监听地址bot.channels: 渠道配置列表,支持 openapi、feishu 等bot.sandbox: 沙箱执行配置6.2 Command-line Options
End of Document
Beta Was this translation helpful? Give feedback.
All reactions