From 8e9df90f0c9f651c33acb64530a18adf3047ca65 Mon Sep 17 00:00:00 2001 From: orcasjh Date: Fri, 14 Aug 2026 23:19:21 +0000 Subject: [PATCH] feat: add OrcaRouter as a named OpenAI-compatible provider Add OrcaRouter.of(...) mirroring the existing DeepSeek entry point, plus an orcaRouter preset, so LiteFlow ReAct agents can route through the OrcaRouter gateway (https://api.orcarouter.ai/v1). --- README.md | 2 +- README.zh-CN.md | 2 +- docs/liteflow-react-agent-guide.md | 19 ++++++++++++++++++- .../agent/openai/OpenAICompatiblePresets.java | 3 +++ .../liteflow/agent/openai/OrcaRouter.java | 17 +++++++++++++++++ 5 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 liteflow-react-agent/liteflow-react-agent-openai/src/main/java/com/yomahub/liteflow/agent/openai/OrcaRouter.java diff --git a/README.md b/README.md index ecce08752..0a5985815 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ THEN(prepare, WHEN(analyzerAgent, riskAgent), summaryAgent, notify); None of `THEN`, `WHEN`, `IF`, `SWITCH` or `FOR` here is newly invented for AI — they are the same orchestration operators LiteFlow has used for years. **If you can orchestrate LiteFlow, you can orchestrate AI.** -The module connects to mainstream LLM platforms — OpenAI, Claude, Gemini, DeepSeek, Qwen (DashScope), Kimi, GLM and more — and provides multi-turn conversation memory, the Skills system, workspace file tools, streaming output, and so on. Switching models is basically a one-line change to `model()`. +The module connects to mainstream LLM platforms — OpenAI, Claude, Gemini, DeepSeek, Qwen (DashScope), Kimi, GLM, [OrcaRouter](https://www.orcarouter.ai) and more — and provides multi-turn conversation memory, the Skills system, workspace file tools, streaming output, and so on. Switching models is basically a one-line change to `model()`. > Note: The AI Agent module is built on agentscope-java and requires JDK 21+ at runtime. See the [official documentation](https://liteflow.cc/) for the full usage guide. diff --git a/README.zh-CN.md b/README.zh-CN.md index 70856e55b..eab145a06 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -85,7 +85,7 @@ THEN(prepare, WHEN(analyzerAgent, riskAgent), summaryAgent, notify); 这里的 `THEN`、`WHEN`、`IF`、`SWITCH`、`FOR` 没有一个是为 AI 新造的,全是 LiteFlow 用了多年的编排算子。**你会编排 LiteFlow,你就会编排 AI。** -该模块对接了主流大模型平台:OpenAI、Claude、Gemini、DeepSeek、通义千问(DashScope)、Kimi、GLM 等,并提供多轮会话记忆、Skills 技能体系、工作空间文件工具、流式输出等能力,换模型基本就是换一行 `model()` 的事。 +该模块对接了主流大模型平台:OpenAI、Claude、Gemini、DeepSeek、通义千问(DashScope)、Kimi、GLM、[OrcaRouter](https://www.orcarouter.ai) 等,并提供多轮会话记忆、Skills 技能体系、工作空间文件工具、流式输出等能力,换模型基本就是换一行 `model()` 的事。 > 提示:AI Agent 模块基于 agentscope-java,运行时需要 JDK 21+。完整使用方式请查阅[官方文档](https://liteflow.cc/)。 diff --git a/docs/liteflow-react-agent-guide.md b/docs/liteflow-react-agent-guide.md index 4d9a668a5..8785859af 100644 --- a/docs/liteflow-react-agent-guide.md +++ b/docs/liteflow-react-agent-guide.md @@ -23,7 +23,7 @@ | 模块 | 作用 | | --- | --- | | `liteflow-react-agent-core` | `ReActAgentComponent`、`ModelSpec` 基础设施、conversation / agentKey 会话管理、memory 持久化、流式事件桥接、workspace 文件工具、受管 Shell 工具 | -| `liteflow-react-agent-openai` | OpenAI 官方 API + OpenAI 兼容协议,内置 DeepSeek、Kimi、GLM、Minimax 便捷入口 | +| `liteflow-react-agent-openai` | OpenAI 官方 API + OpenAI 兼容协议,内置 DeepSeek、Kimi、GLM、Minimax、OrcaRouter 便捷入口 | | `liteflow-react-agent-anthropic` | Anthropic Claude 模型入口 | | `liteflow-react-agent-gemini` | Google Gemini 模型入口 | | `liteflow-react-agent-dashscope` | 阿里云 DashScope / Qwen 模型入口 | @@ -63,6 +63,23 @@ liteflow.agent.openai-compatible.deepseek.api-key=${DEEPSEEK_API_KEY} liteflow.agent.openai-compatible.deepseek.base-url=https://api.deepseek.com/v1 ``` +[OrcaRouter](https://www.orcarouter.ai) 是与 DeepSeek 同族的 OpenAI 兼容路由网关,用法完全一致: + +```properties +liteflow.agent.openai-compatible.orcarouter.api-key=${ORCAROUTER_API_KEY} +# OrcaRouter.of(...) 已内置默认 baseUrl;如需覆盖再配置下一行。 +liteflow.agent.openai-compatible.orcarouter.base-url=https://api.orcarouter.ai/v1 +``` + +```java +import com.yomahub.liteflow.agent.openai.OrcaRouter; + +@Override +protected ModelSpec model() { + return OrcaRouter.of("orcarouter/auto"); +} +``` + `liteflow.agent.workspace.root` 是必填项。没有配置时,首次执行 Agent 组件会抛出: ```text diff --git a/liteflow-react-agent/liteflow-react-agent-openai/src/main/java/com/yomahub/liteflow/agent/openai/OpenAICompatiblePresets.java b/liteflow-react-agent/liteflow-react-agent-openai/src/main/java/com/yomahub/liteflow/agent/openai/OpenAICompatiblePresets.java index 3154420fd..bf7c078d9 100644 --- a/liteflow-react-agent/liteflow-react-agent-openai/src/main/java/com/yomahub/liteflow/agent/openai/OpenAICompatiblePresets.java +++ b/liteflow-react-agent/liteflow-react-agent-openai/src/main/java/com/yomahub/liteflow/agent/openai/OpenAICompatiblePresets.java @@ -17,4 +17,7 @@ public final class OpenAICompatiblePresets { public static OpenAIChatModel minimax(String apiKey, String modelName) { return OpenAIModelFactory.custom(apiKey, "https://api.minimax.chat/v1", modelName); } + public static OpenAIChatModel orcaRouter(String apiKey, String modelName) { + return OpenAIModelFactory.custom(apiKey, "https://api.orcarouter.ai/v1", modelName); + } } \ No newline at end of file diff --git a/liteflow-react-agent/liteflow-react-agent-openai/src/main/java/com/yomahub/liteflow/agent/openai/OrcaRouter.java b/liteflow-react-agent/liteflow-react-agent-openai/src/main/java/com/yomahub/liteflow/agent/openai/OrcaRouter.java new file mode 100644 index 000000000..923fb23ba --- /dev/null +++ b/liteflow-react-agent/liteflow-react-agent-openai/src/main/java/com/yomahub/liteflow/agent/openai/OrcaRouter.java @@ -0,0 +1,17 @@ +package com.yomahub.liteflow.agent.openai; + +/** + * OrcaRouter 入口。OrcaRouter 是 OpenAI 兼容的 LLM 路由网关(https://www.orcarouter.ai), + * 在同一端点提供网关级、零信任的 AI Agent 安全防护。 + * credential 来源:{@code liteflow.agent.openai-compatible.orcarouter}。 + */ +public final class OrcaRouter { + private static final String CONFIG_KEY = "orcarouter"; + private static final String BASE_URL = "https://api.orcarouter.ai/v1"; + + private OrcaRouter() {} + + public static OpenAICompatibleSpec of(String modelName) { + return new OpenAICompatibleSpec(CONFIG_KEY, modelName, BASE_URL); + } +} -- Gitee