Skip to content

feat(friendli): add Friendli provider with GLM-5.2 support#721

Open
Lee-Si-Yoon wants to merge 11 commits into
Zoo-Code-Org:mainfrom
Lee-Si-Yoon:feat/friendli-provider
Open

feat(friendli): add Friendli provider with GLM-5.2 support#721
Lee-Si-Yoon wants to merge 11 commits into
Zoo-Code-Org:mainfrom
Lee-Si-Yoon:feat/friendli-provider

Conversation

@Lee-Si-Yoon

@Lee-Si-Yoon Lee-Si-Yoon commented Jun 25, 2026

Copy link
Copy Markdown

Related Issue

Closes #722

Description

Friendli = new OpenAI-compatible provider. Base URL https://api.friendli.ai/serverless/v1. Bearer auth (flp_... personal API keys).

Models (IDs + pricing from Friendli Model APIs pricing endpoint):

  • zai-org/GLM-5.2 (default) — 1M ctx / 128k out. $1.4 in / $0.26 cached / $4.4 out per 1M tok.
  • zai-org/GLM-5.1 — 200k ctx / 128k out.
  • deepseek-ai/DeepSeek-V3.2 — 163.8k ctx.
  • MiniMaxAI/MiniMax-M2.5 — 204.8k ctx.

Impl:

  • Handler = minimal BaseOpenAiCompatibleProvider subclass (19 lines).
  • Wiring across registries: providerNames, zod schema, SECRET_STATE_KEYS, buildApiHandler switch, ProfileValidator, webview ApiOptions/constants/validate/useSelectedModel/providerModelConfig, bug-report dropdown.
  • i18n keys (friendliApiKey / getFriendliApiKey) across 18 locales, "Friendli" brand translated per locale.

Test Procedure

Handler + wiring:

  • npx vitest run api/providers/__tests__/friendli.spec.ts → 17 tests (base URL, API key, default model, 4 models config, stream text/usage, completePrompt success/empty/missing-choices, multi-chunk, temp override).
  • npx vitest run shared/__tests__/ProfileValidator.spec.ts → 29 tests (friendli in apiModelId provider list).
  • npx vitest run webview Friendli wiring → validate.spec.ts (2), useSelectedModel.spec.ts (2), Friendli.spec.tsx (2).

Patch coverage: sister OpenAI-compatible providers (Fireworks/Baseten/etc.) carry no tests for buildApiHandler switch or ApiOptions provider-branch. Stayed consistent — 2 lines uncovered by deliberate choice:

  • src/api/index.ts case "friendli" (1 line)
  • webview-ui/src/components/settings/ApiOptions.tsx selectedProvider === "friendli" partial

Happy to add follow-up if maintainers want the gate tightened uniformly across sisters.

Type-check + lint clean:

  • pnpm --filter @roo-code/types check-types
  • pnpm --filter zoo-code check-types
  • pnpm --filter @roo-code/vscode-webview check-types
  • pnpm --filter <each> lint ✓ (types, src, webview-ui)

Manual verify (local Ext Dev Host F5):

스크린샷 2026-06-26 004509

Pre-Submission Checklist

  • Issue Linked: Closes [ENHANCEMENT] Add Friendli as an API provider for GLM-5.2 #722
  • Scope: Friendli provider + 4 models.
  • Self-Review: 36 changed files.
  • Testing: handler spec (17) + ProfileValidator (29) + webview wiring (6); types + lint clean; F5 smoke done.
  • Docs Impact: User-facing providers page may want Friendli entry — separate PR to Zoo-Code-Docs.
  • Contribution Guidelines: Read + agree.

Contact

Discord username on request.

Summary by CodeRabbit

  • New Features
    • Added Friendli provider support end-to-end, including available models, default model selection, and provider-specific API key configuration.
    • Added Friendli API key settings to the UI with localized labels across supported languages.
  • Bug Fixes
    • Updated profile/model validation to correctly recognize Friendli and require the Friendli API key.
  • Tests
    • Added coverage for Friendli request handling (including streaming), provider model selection, settings validation, and the Friendli settings UI.

Friendli OpenAI-compatible provider. Models: GLM-5.2, GLM-5.1,
DeepSeek-V3.2, MiniMax-M2.5. Pricing from friendli.ai pricing API.

Mirror fireworks provider pattern (commit 4a9222b):
- types: model info, schema, secret key, provider name
- api: BaseOpenAiCompatibleProvider handler at api.friendli.ai/serverless/v1
- webview: provider UI, model picker, validation, i18n (18 locales)
- tests: handler spec, ProfileValidator entry

Reasoning streams back via base handler's reasoning_content extraction.
Friendli defaults parse_reasoning=true for GLM reasoning models.
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds Friendli as an API provider across shared types, backend routing, settings UI, validation, and localized settings text.

Changes

Friendli provider support

Layer / File(s) Summary
Provider contracts and model catalog
packages/types/src/global-settings.ts, packages/types/src/provider-settings.ts, packages/types/src/providers/friendli.ts, packages/types/src/providers/index.ts
Adds friendliApiKey secret-state typing, Friendli provider schemas and model metadata, and default-model lookup wiring in the shared types package.
Backend handler and routing
src/api/providers/friendli.ts, src/api/providers/index.ts, src/api/index.ts, src/shared/ProfileValidator.ts, src/shared/__tests__/ProfileValidator.spec.ts
Introduces FriendliHandler, exports it through the API barrels, routes apiProvider: "friendli" to it, and updates profile model-id extraction and its test.
Friendli handler tests
src/api/providers/__tests__/friendli.spec.ts
Exercises Friendli handler construction, model selection, request parameters, completion handling, and streamed text and usage chunks.
Settings registry and validation wiring
webview-ui/src/components/settings/constants.ts, webview-ui/src/components/settings/utils/providerModelConfig.ts, webview-ui/src/components/ui/hooks/useSelectedModel.ts, webview-ui/src/utils/validate.ts
Registers Friendli in provider constants, model config, selected-model lookup, and API-key validation.
Friendli settings form
webview-ui/src/components/settings/ApiOptions.tsx, webview-ui/src/components/settings/providers/Friendli.tsx, webview-ui/src/components/settings/providers/index.ts
Renders the Friendli provider settings panel, re-exports it from the providers barrel, and adds it to the settings provider switch.
Friendli copy and helper text
webview-ui/src/i18n/locales/*/settings.json
Adds Friendli API-key and retrieval strings across the localized settings files.

Sequence Diagram(s)

sequenceDiagram
  participant buildApiHandler
  participant FriendliHandler
  participant FriendliAPI
  buildApiHandler->>FriendliHandler: returns new FriendliHandler(options)
  FriendliHandler->>FriendliAPI: sends requests to https://api.friendli.ai/serverless/v1
  FriendliAPI-->>FriendliHandler: streams completion chunks and usage data
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

awaiting-author

Suggested reviewers

  • JamesRobert20
  • navedmerchant
  • hannesrudolph
  • edelauna
  • taltas

Poem

I hopped through types with a Friendli grin,
New models burrowed neatly in.
My paws tapped keys, the streams rolled by,
Hello, GLM-5.2 in the sky!
🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.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
Title check ✅ Passed The title clearly states the new Friendli provider and its GLM-5.2 support, matching the main change.
Description check ✅ Passed The description covers issue linkage, implementation, and testing, but it omits the screenshots/videos section and some template headings.
Linked Issues check ✅ Passed The PR adds Friendli wiring, API key handling, model metadata, UI selection, and tests, satisfying the linked issue's requirements.
Out of Scope Changes check ✅ Passed The added tests, locales, and provider wiring all support Friendli integration, with no clear unrelated code changes.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@Lee-Si-Yoon Lee-Si-Yoon marked this pull request as ready for review June 25, 2026 16:20
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (3)
webview-ui/src/utils/validate.ts (1)

120-124: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a validation test for the new friendliApiKey requirement.

Please add/extend local unit tests to cover the new friendli branch returning the API-key validation error when key is missing.

As per coding guidelines, "**/*.{test,spec}.{ts,tsx,js}: Use package-local unit tests for pure logic... validation..."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@webview-ui/src/utils/validate.ts` around lines 120 - 124, Add or extend the
package-local unit tests for validate.ts to cover the new friendli branch in the
validation logic. Update the tests around the validation function that checks
apiConfiguration so that when the provider is "friendli" and friendliApiKey is
missing, it returns the same API-key validation error as the other providers.
Reference the validate logic and the existing validation error key assertions to
keep the test aligned with the new friendliApiKey requirement.

Source: Coding guidelines

webview-ui/src/components/ui/hooks/useSelectedModel.ts (1)

327-331: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add unit coverage for the new friendli selection branch.

Please add local tests for the new path (default fallback + model info lookup) so provider-specific selection behavior is locked down.

As per coding guidelines, "**/*.{test,spec}.{ts,tsx,js}: Use package-local unit tests for pure logic... state transitions, validation..."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@webview-ui/src/components/ui/hooks/useSelectedModel.ts` around lines 327 -
331, Add package-local unit tests for the new friendli branch in
useSelectedModel, covering both the default fallback when
apiConfiguration.apiModelId is unset and the model info lookup when it is set.
Exercise the friendli case in the selection logic and assert the returned { id,
info } matches defaultModelId or the configured model ID, with info resolved
from friendliModels, so the provider-specific behavior is locked down.

Source: Coding guidelines

webview-ui/src/components/settings/providers/Friendli.tsx (1)

16-50: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add local webview tests for the new Friendli settings component.

This introduces new rendering/input behavior but no corresponding webview-ui Vitest coverage was added (e.g., API-key input binding and “get API key” CTA visibility toggle).

As per coding guidelines, "webview-ui/src/**/*.{ts,tsx}: Prefer local webview-ui tests... Add or update Vitest coverage under webview-ui/src/**/__tests__."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@webview-ui/src/components/settings/providers/Friendli.tsx` around lines 16 -
50, The new Friendli settings component in Friendli needs local webview Vitest
coverage under webview-ui/src/**/__tests__ to cover its rendering and input
behavior. Add tests for the Friendli component that verify the friendliApiKey
field is bound through handleInputChange/setApiConfigurationField and that the
“get Friendli API key” CTA from VSCodeButtonLink is shown only when
apiConfiguration.friendliApiKey is empty. Use the Friendli component and its
API-key/CTA UI symbols to locate the behavior to test.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@webview-ui/src/components/settings/providers/Friendli.tsx`:
- Around line 16-50: The new Friendli settings component in Friendli needs local
webview Vitest coverage under webview-ui/src/**/__tests__ to cover its rendering
and input behavior. Add tests for the Friendli component that verify the
friendliApiKey field is bound through handleInputChange/setApiConfigurationField
and that the “get Friendli API key” CTA from VSCodeButtonLink is shown only when
apiConfiguration.friendliApiKey is empty. Use the Friendli component and its
API-key/CTA UI symbols to locate the behavior to test.

In `@webview-ui/src/components/ui/hooks/useSelectedModel.ts`:
- Around line 327-331: Add package-local unit tests for the new friendli branch
in useSelectedModel, covering both the default fallback when
apiConfiguration.apiModelId is unset and the model info lookup when it is set.
Exercise the friendli case in the selection logic and assert the returned { id,
info } matches defaultModelId or the configured model ID, with info resolved
from friendliModels, so the provider-specific behavior is locked down.

In `@webview-ui/src/utils/validate.ts`:
- Around line 120-124: Add or extend the package-local unit tests for
validate.ts to cover the new friendli branch in the validation logic. Update the
tests around the validation function that checks apiConfiguration so that when
the provider is "friendli" and friendliApiKey is missing, it returns the same
API-key validation error as the other providers. Reference the validate logic
and the existing validation error key assertions to keep the test aligned with
the new friendliApiKey requirement.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 27a3c674-5e8e-4e9e-8298-5a0dd130baa2

📥 Commits

Reviewing files that changed from the base of the PR and between 6670962 and bcaac83.

📒 Files selected for processing (36)
  • .github/ISSUE_TEMPLATE/bug_report.yml
  • packages/types/src/global-settings.ts
  • packages/types/src/provider-settings.ts
  • packages/types/src/providers/friendli.ts
  • packages/types/src/providers/index.ts
  • src/api/index.ts
  • src/api/providers/__tests__/friendli.spec.ts
  • src/api/providers/friendli.ts
  • src/api/providers/index.ts
  • src/shared/ProfileValidator.ts
  • src/shared/__tests__/ProfileValidator.spec.ts
  • webview-ui/src/components/settings/ApiOptions.tsx
  • webview-ui/src/components/settings/constants.ts
  • webview-ui/src/components/settings/providers/Friendli.tsx
  • webview-ui/src/components/settings/providers/index.ts
  • webview-ui/src/components/settings/utils/providerModelConfig.ts
  • webview-ui/src/components/ui/hooks/useSelectedModel.ts
  • webview-ui/src/i18n/locales/ca/settings.json
  • webview-ui/src/i18n/locales/de/settings.json
  • webview-ui/src/i18n/locales/en/settings.json
  • webview-ui/src/i18n/locales/es/settings.json
  • webview-ui/src/i18n/locales/fr/settings.json
  • webview-ui/src/i18n/locales/hi/settings.json
  • webview-ui/src/i18n/locales/id/settings.json
  • webview-ui/src/i18n/locales/it/settings.json
  • webview-ui/src/i18n/locales/ja/settings.json
  • webview-ui/src/i18n/locales/ko/settings.json
  • webview-ui/src/i18n/locales/nl/settings.json
  • webview-ui/src/i18n/locales/pl/settings.json
  • webview-ui/src/i18n/locales/pt-BR/settings.json
  • webview-ui/src/i18n/locales/ru/settings.json
  • webview-ui/src/i18n/locales/tr/settings.json
  • webview-ui/src/i18n/locales/vi/settings.json
  • webview-ui/src/i18n/locales/zh-CN/settings.json
  • webview-ui/src/i18n/locales/zh-TW/settings.json
  • webview-ui/src/utils/validate.ts

@Lee-Si-Yoon

Lee-Si-Yoon commented Jun 26, 2026

Copy link
Copy Markdown
Author

Hi maintainers 👋 — the patch coverage check flags the friendli wiring (buildApiHandler case, useSelectedModel, validate, ApiOptions, Friendli.tsx), but sibling OpenAI-compatible providers don't carry tests for those wiring points. Should I add them here to satisfy coverage, or stay consistent with sister providers? Happy to push the follow-up either way.

@edelauna

Copy link
Copy Markdown
Contributor

@Lee-Si-Yoon thank you for this contribution, before we do our review could you ensure codecov/patch step passes with 80% coverage for all changed files - thank you.

@Lee-Si-Yoon

Copy link
Copy Markdown
Author

@edelauna Thanks for the heads-up. I've added tests for all the changes

@github-actions github-actions Bot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Jun 30, 2026
@github-actions github-actions Bot removed the awaiting-review PR changes are ready and waiting for maintainer re-review label Jul 2, 2026
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.

[ENHANCEMENT] Add Friendli as an API provider for GLM-5.2

2 participants