openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

feat: add Novita AI provider

Open Alex-yang00 opened this issue 6 months ago • 1 comments

Summary

Add Novita AI as a provider using the existing OpenAI-compatible provider path.

Changes

  • Add Novita AI to the built-in cloud provider chips
  • Configure the Novita endpoint as https://api.novita.ai/openai with bearer auth
  • Prefill Novita routing with deepseek/deepseek-v4-pro
  • Add AIPanel coverage for Novita connection and routing defaults

Verification

  • pnpm --dir app exec vitest run --config test/vitest.config.ts src/components/settings/panels/tests/AIPanel.test.tsx
  • pnpm --dir app exec tsc --noEmit
  • git diff --check

Summary by CodeRabbit

  • New Features
    • Added Novita as a built-in AI provider with a default endpoint, default model preselection, and Novita-specific API key placeholder.
    • Novita integrated into provider selection lists, provider connect flow, per-workload custom routing, and model placeholder behavior when switching providers.
  • Tests
    • Added integration tests covering Novita connection, API-key flow, and routing/model defaults.

Review Change Stack

Alex-yang00 avatar May 18 '26 10:05 Alex-yang00

📝 Walkthrough

Walkthrough

Adds Novita as a built-in cloud provider: provider metadata and endpoint, default model mappings, custom-routing model seeding and placeholders, provider UI/editor wiring for Novita, and tests for connect and routing flows.

Changes

AI Settings Panel Refactor

Layer / File(s) Summary
Built-in provider metadata (Novita)
app/src/components/settings/panels/AIPanel.tsx
Adds novita to the built-in provider catalog and slug list, registers a default model entry, and maps the default endpoint to https://api.novita.ai/openai/v1.
Provider key dialog, chips, and editor options
app/src/components/settings/panels/AIPanel.tsx
Renders provider chips from the expanded built-in slug list (including Novita), adds a Novita-specific API key placeholder in ProviderKeyDialog, and sources CloudProviderEditor default slug and dropdown options from CLOUD_EDITOR_SLUGS plus the currently selected slug when needed.
CustomRoutingDialog model seeding & placeholders
app/src/components/settings/panels/AIPanel.tsx
Seeds CustomRoutingDialog initial model from BUILTIN_PROVIDER_DEFAULT_MODELS for built-in slugs, updates provider-switch logic to set the mapped default model, and updates the model input placeholder to prefer the built-in default model.
Tests for Novita connect and routing
app/src/components/settings/panels/__tests__/AIPanel.test.tsx
Adds tests covering: connecting Novita via the API-key dialog and asserting saved provider shape/call to setCloudProviderKey, routing a workload to Novita with the prefilled default model, and a Custom-editor default retention scenario.

Sequence Diagram

sequenceDiagram
  participant User
  participant AIPanel
  participant ProviderKeyDialog
  participant CustomRoutingDialog
  participant useAISettings

  User->>AIPanel: Toggle "Connect Novita AI" chip
  AIPanel->>ProviderKeyDialog: Open (novita-specific placeholder)
  User->>ProviderKeyDialog: Enter API key + Save
  ProviderKeyDialog->>useAISettings: setCloudProviderKey('novita', key)
  User->>AIPanel: Open CustomRoutingDialog for workload
  CustomRoutingDialog->>AIPanel: prefill model from BUILTIN_PROVIDER_DEFAULT_MODELS['novita']
  User->>CustomRoutingDialog: Save routing draft
  CustomRoutingDialog->>useAISettings: saveAISettings(draft with novita routing)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

feature

Poem

🐰 I hopped into settings, bright and spry,
I added Novita to the provider sky,
A key, a chip, a model prefilled,
Routing saved and tests fulfilled,
A tiny hop, a curious sigh!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add Novita AI provider' is concise, specific, and accurately describes the main change—adding Novita as a new built-in cloud provider.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
⚔️ Resolve merge conflicts
  • [ ] Resolve merge conflict in branch pullman-novita-ai-provider

[!WARNING] There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar May 18 '26 10:05 coderabbitai[bot]

I picked up the current CI failure here. The Coverage Gate is failing because the Novita provider placeholder branch in AIPanel.tsx is uncovered (Novita API key). I opened a helper PR against the source branch with a focused test assertion: https://github.com/Alex-yang00/openhuman/pull/1\n\nValidation on the helper branch:\n- pnpm exec vitest run --config test/vitest.config.ts src/components/settings/panels/tests/AIPanel.test.tsx --reporter=dot\n- pnpm exec prettier --check src/components/settings/panels/tests/AIPanel.test.tsx\n- git diff --check -- app/src/components/settings/panels/tests/AIPanel.test.tsx\n\nThe E2E failures in the current run look unrelated to this Novita change: several clicks are being intercepted by eact-joyride-portal, and this PR is also currently marked dirty against main, so it will still need a branch sync/conflict resolution after the coverage helper lands.

Felyx-Fu avatar Jun 17 '26 16:06 Felyx-Fu