From fc58ac158fe4c81bc0d006f1ec8aa68636686ddc Mon Sep 17 00:00:00 2001 From: jinhaosong-source Date: Sat, 15 Aug 2026 01:47:28 +0000 Subject: [PATCH] feat(infra-ai): add OrcaRouter as a named LLM provider Mirror the existing aihubmix/siliconflow OpenAI-compatible provider wiring: - ModelProvider.ORCA_ROUTER("orcarouter") - OrcaRouterChatClient (AbstractOpenAIStyleChatClient subclass) - ai.providers.orcarouter config (https://api.orcarouter.ai/v1/chat/completions) - chat candidate orca-auto (model orcarouter/auto) appended to standard tier Co-Authored-By: Claude --- bootstrap/src/main/resources/application.yaml | 10 +++- .../infra/chat/OrcaRouterChatClient.java | 46 +++++++++++++++++++ .../ai/ragent/infra/enums/ModelProvider.java | 5 ++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 infra-ai/src/main/java/com/nageoffer/ai/ragent/infra/chat/OrcaRouterChatClient.java diff --git a/bootstrap/src/main/resources/application.yaml b/bootstrap/src/main/resources/application.yaml index b20129c..c5f4be6 100644 --- a/bootstrap/src/main/resources/application.yaml +++ b/bootstrap/src/main/resources/application.yaml @@ -205,6 +205,11 @@ ai: endpoints: chat: /v1/chat/completions embedding: /v1/embeddings + orcarouter: + url: https://api.orcarouter.ai + api-key: ${ORCAROUTER_API_KEY:} + endpoints: + chat: /v1/chat/completions selection: failure-threshold: 2 @@ -235,6 +240,9 @@ ai: - id: gpt-5.4 provider: aihubmix model: gpt-5.4 + - id: orca-auto + provider: orcarouter + model: orcarouter/auto default-tier: standard deep-thinking-tier: deep @@ -244,7 +252,7 @@ ai: candidates: [ qwen-flash, qwen-plus, qwen3-local ] timeout-ms: 5000 standard: - candidates: [ qwen3-max, qwen-plus, qwen3-local, gpt-5.4 ] + candidates: [ qwen3-max, qwen-plus, qwen3-local, gpt-5.4, orca-auto ] timeout-ms: 30000 deep: candidates: [ qwen3-max, glm-4.7 ] diff --git a/infra-ai/src/main/java/com/nageoffer/ai/ragent/infra/chat/OrcaRouterChatClient.java b/infra-ai/src/main/java/com/nageoffer/ai/ragent/infra/chat/OrcaRouterChatClient.java new file mode 100644 index 0000000..e2516ab --- /dev/null +++ b/infra-ai/src/main/java/com/nageoffer/ai/ragent/infra/chat/OrcaRouterChatClient.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.nageoffer.ai.ragent.infra.chat; + +import com.nageoffer.ai.ragent.framework.convention.ChatRequest; +import com.nageoffer.ai.ragent.framework.trace.RagTraceNode; +import com.nageoffer.ai.ragent.infra.enums.ModelProvider; +import com.nageoffer.ai.ragent.infra.model.ModelTarget; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +public class OrcaRouterChatClient extends AbstractOpenAIStyleChatClient { + + @Override + public String provider() { + return ModelProvider.ORCA_ROUTER.getId(); + } + + @Override + @RagTraceNode(name = "orcarouter-chat", type = "LLM_PROVIDER") + public String chat(ChatRequest request, ModelTarget target) { + return doChat(request, target); + } + + @Override + public StreamCancellationHandle streamChat(ChatRequest request, StreamCallback callback, ModelTarget target) { + return doStreamChat(request, callback, target); + } +} diff --git a/infra-ai/src/main/java/com/nageoffer/ai/ragent/infra/enums/ModelProvider.java b/infra-ai/src/main/java/com/nageoffer/ai/ragent/infra/enums/ModelProvider.java index db5704a..008963b 100644 --- a/infra-ai/src/main/java/com/nageoffer/ai/ragent/infra/enums/ModelProvider.java +++ b/infra-ai/src/main/java/com/nageoffer/ai/ragent/infra/enums/ModelProvider.java @@ -48,6 +48,11 @@ public enum ModelProvider { */ AI_HUB_MIX("aihubmix"), + /** + * OrcaRouter AI 模型路由网关 + */ + ORCA_ROUTER("orcarouter"), + /** * 空实现,用于测试或占位 */ -- Gitee