From 393ca3373e478583549ac134ef923fa8bc9295f9 Mon Sep 17 00:00:00 2001 From: orcasjh Date: Sat, 15 Aug 2026 15:06:17 +0000 Subject: [PATCH] feat(model): support OrcaRouter as a named OpenAI-compatible model type Add OrcaRouter (https://www.orcarouter.ai) as a first-class model type in SolidUI's code-generation flow, mirroring the existing gpt branch: - configure_for_orcarouter builds an OpenAI-compatible /v1/chat/completions request and defaults to https://api.orcarouter.ai when no base URL is set - get_code dispatches type_name == 'orcarouter' to the new configurator - send_request_and_process_response parses the OpenAI-format response - README/README_CN feature lists mention OrcaRouter support Co-Authored-By: Claude --- README.md | 1 + README_CN.md | 1 + solidui/views/utils.py | 28 +++++++++++++++++++++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bee251f..9b5c9c6 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ AI-generated Graphic Models. * Support plug-in robot * Support SolidUI-Model * Support Large Language Model +* Support [OrcaRouter](https://www.orcarouter.ai) model * Containerized deployment # QuickStart diff --git a/README_CN.md b/README_CN.md index f724f67..7f0b581 100644 --- a/README_CN.md +++ b/README_CN.md @@ -60,6 +60,7 @@ AI生成图形模型 * 支持插件机器人 * 支持SolidUI模型 * 支持大模型接入 +* 支持[OrcaRouter](https://www.orcarouter.ai) 模型接入 * 容器化部署 # 快速开始 diff --git a/solidui/views/utils.py b/solidui/views/utils.py index 213dbbc..0b9b2bd 100644 --- a/solidui/views/utils.py +++ b/solidui/views/utils.py @@ -41,7 +41,8 @@ async def send_request_and_process_response(url, headers, data, type_name, proce return process_response_func(response.json()["response"]), 200 elif type_name == "gpt": return process_response_func(response.json()["choices"][0]["message"]["content"]), 200 - + elif type_name == "orcarouter": + return process_response_func(response.json()["choices"][0]["message"]["content"]), 200 async def get_code(gpt_prompt, user_prompt, type_name, model_code, user_key="", base_url="default_url", @@ -53,6 +54,8 @@ async def get_code(gpt_prompt, user_prompt, type_name, model_code, user_key="", url, headers, data = configure_for_glm(base_url, model, user_key, new_prompt) elif type_name == "gpt": url, headers, data = configure_for_gpt(base_url, model, user_key, new_prompt) + elif type_name == "orcarouter": + url, headers, data = configure_for_orcarouter(base_url, model, user_key, new_prompt) else: raise ValueError("Unsupported model type") @@ -115,3 +118,26 @@ def configure_for_gpt(base_url, model, user_key, prompt): url = f"{base_url}/v1/chat/completions" return url, headers, data + + +def configure_for_orcarouter(base_url, model, user_key, prompt): + headers = { + "Content-Type": "application/json", + "Authorization": f"Bearer {user_key}", + } + + data = { + "model": model, + "messages": [ + { + "role": "user", + "content": prompt, + }, + ], + "temperature": 0.7, + } + + # OrcaRouter is an OpenAI-compatible routing gateway. + url = f"{base_url or 'https://api.orcarouter.ai'}/v1/chat/completions" + + return url, headers, data -- Gitee