Skip to content

feat: add OrcaRouter as an optional AI engine provider - #59

Open
XiaoHuo888-hue wants to merge 1 commit into
oficcejo:mainfrom
XiaoHuo888-hue:add-orcarouter-provider
Open

feat: add OrcaRouter as an optional AI engine provider#59
XiaoHuo888-hue wants to merge 1 commit into
oficcejo:mainfrom
XiaoHuo888-hue:add-orcarouter-provider

Conversation

@XiaoHuo888-hue

Copy link
Copy Markdown

Add OrcaRouter as an optional AI engine provider

This PR adds a named OrcaRouter provider alongside the existing DeepSeek integration. When ORCAROUTER_API_KEY is 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 at https://api.orcarouter.ai/v1, defaulting to the orcarouter/auto model. 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 — returns OrcaRouterClient when ORCAROUTER_API_KEY is set, otherwise DeepSeekClient.
  • orcarouter_client.py (new): OrcaRouterClient — subclasses DeepSeekClient, reusing all prompt/chat logic, only swapping the OpenAI-compatible endpoint & model.
  • config.py: ORCAROUTER_API_KEY / ORCAROUTER_BASE_URL (default https://api.orcarouter.ai/v1) / ORCAROUTER_MODEL (default orcarouter/auto). DEFAULT_MODEL_NAME auto-falls back to the OrcaRouter model when the key is configured.
  • config_manager.py: new OrcaRouter entries in the config UI + write_env; validate_config now 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/auto preset entry.
  • smart_monitor_deepseek.py: picks the OrcaRouter endpoint/credentials when configured.
  • All agent/engine modules now go through the llm_client factory.
  • .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.py6/6 passed.
  • python3 -m pytest utils/test_youchannels_research.py19 passed, 2 skipped (integration tests needing YDC_API_KEY, same as before).
  • python3 -m py_compile on all touched files — OK.
  • Live test against OrcaRouter (real key, orcarouter/auto): OrcaRouterClient.call_api → 200 with valid content; SmartMonitorDeepSeek provider path → HTTP 200, model qwen3.6-flash routed via orcarouter/auto.

Disclosure: I'm an engineer on the OrcaRouter team.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant