diff --git a/bootstrap/src/main/resources/application.yaml b/bootstrap/src/main/resources/application.yaml index b20129cece93dad7c610eb9b74e8b4bf8e57b616..c5f4be63e1aad7076d056d5d573cf606a4d9a74b 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 0000000000000000000000000000000000000000..e2516ab3824cec68573c06d93f0d1334f58df38d --- /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 db5704a8e59fe32c56d6ae1d2881b177ff61dcd1..008963b2189175e0896521d041eb76f6c2392968 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"), + /** * 空实现,用于测试或占位 */