Rust LLM provider abstraction with Anthropic, OpenAI, Responses API, and mock implementations plus SSE streaming.
// Source: https://github.com/RZfive/WorldBase | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
//! LLM provider 抽象与实现。
//!
//! - `AnthropicProvider`: Messages API SSE 流式(含 tool_use 块)
//! - `OpenAIProvider`: Chat Completions SSE 流式(含 tool_calls,支持 base_url
//! 覆盖以兼容 OpenAI 兼容端点)
//! - `OpenAIResponsesProvider`: Responses API SSE 流式(OpenAI 官方新协议)
//! - `MockProvider`: 脚本化回复,供测试与无 key 演示
//!
//! 协议在运行时由条目的 `apiProtocol` 归一化(`api_protocol::ApiProtocol`),
//! 自动探测见 `detect`。
//!
//! SSE 解析使用跨网络 chunk 的缓冲行解析器,修复 P0 版本按 chunk 边界
//! 截断事件的问题。
use anyhow::Result;
use futures::stream::BoxStream;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use worldbase_protocol::types::P
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key