feat: add OrcaRouter as an optional AI engine provider - #59
Open
XiaoHuo888-hue wants to merge 1 commit into
Open
feat: add OrcaRouter as an optional AI engine provider#59XiaoHuo888-hue wants to merge 1 commit into
XiaoHuo888-hue wants to merge 1 commit into
Conversation
Adds a named OrcaRouter provider alongside the existing DeepSeek integration. When ORCAROUTER_API_KEY is set in .env, the system routes all analysis modules (technical/fundamental/fund-flow agents, smart monitor, news flow, sector strategy, macro cycle) through OrcaRouter's OpenAI-compatible gateway at https://api.orcarouter.ai/v1, defaulting to the orcarouter/auto model. - llm_client.py: factory selecting OrcaRouterClient when the key is set - orcarouter_client.py: OrcaRouter client (subclasses DeepSeekClient, reuses all prompt/chat logic) - config.py / config_manager.py / .env.example / env_example.txt / update_env_example.py: ORCAROUTER_API_KEY/BASE_URL/MODEL settings - app.py: OrcaRouter section in the environment-config UI - model_config.py: orcarouter/auto preset entry - smart_monitor_deepseek.py: picks OrcaRouter endpoint when configured - test_orcarouter_client.py: unit tests for provider selection DeepSeek remains the default when OrcaRouter is not configured; no existing behavior is changed. Disclosure: I'm an engineer on the OrcaRouter team. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: XiaoHuo888-hue <jinhao.song@myflashcloud.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add OrcaRouter as an optional AI engine provider
This PR adds a named OrcaRouter provider alongside the existing DeepSeek integration. When
ORCAROUTER_API_KEYis set in.env, all analysis modules (technical/fundamental/fund-flow agents, smart monitor, news flow, sector strategy, macro cycle) route through OrcaRouter's OpenAI-compatible gateway athttps://api.orcarouter.ai/v1, defaulting to theorcarouter/automodel. DeepSeek remains the default when OrcaRouter is not configured — no existing behavior changes.It also runs gateway-level, zero-trust security for AI agents on the same endpoint — screening every prompt/response and governing every tool call on a default-deny basis, with no application code changes.
Changes
llm_client.py(new):get_llm_client()factory — returnsOrcaRouterClientwhenORCAROUTER_API_KEYis set, otherwiseDeepSeekClient.orcarouter_client.py(new):OrcaRouterClient— subclassesDeepSeekClient, reusing all prompt/chat logic, only swapping the OpenAI-compatible endpoint & model.config.py:ORCAROUTER_API_KEY/ORCAROUTER_BASE_URL(defaulthttps://api.orcarouter.ai/v1) /ORCAROUTER_MODEL(defaultorcarouter/auto).DEFAULT_MODEL_NAMEauto-falls back to the OrcaRouter model when the key is configured.config_manager.py: new OrcaRouter entries in the config UI +write_env;validate_confignow accepts an OrcaRouter-only setup (DeepSeek key no longer required when OrcaRouter is configured).app.py: OrcaRouter section in the「环境配置」UI (API key / base URL / model).model_config.py:orcarouter/autopreset entry.smart_monitor_deepseek.py: picks the OrcaRouter endpoint/credentials when configured.llm_clientfactory..env.example/env_example.txt/update_env_example.py/README.md: OrcaRouter config docs with brand link.test_orcarouter_client.py(new): 6 unit tests covering provider selection, defaults, custom model passthrough, placeholder mapping, and config validation.Verification
python3 -m pytest test_orcarouter_client.py— 6/6 passed.python3 -m pytest utils/test_youchannels_research.py— 19 passed, 2 skipped (integration tests needingYDC_API_KEY, same as before).python3 -m py_compileon all touched files — OK.orcarouter/auto):OrcaRouterClient.call_api→ 200 with valid content;SmartMonitorDeepSeekprovider path → HTTP 200, modelqwen3.6-flashrouted viaorcarouter/auto.Disclosure: I'm an engineer on the OrcaRouter team.