Skip to content

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

Open
Lee-Si-Yoon wants to merge 4 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 4 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 GitHub Issue

Closes: #722

Description

Add Friendli as a new OpenAI-compatible provider. Friendli serves models at https://api.friendli.ai/serverless/v1 with Bearer auth (flp_... personal API keys).

Models added (IDs and pricing sourced from the Friendli Model APIs pricing endpoint):

  • zai-org/GLM-5.2 (default) — 1M context / 128k max output. Input $1.4 / cached $0.26 / output $4.4 per 1M tokens.
  • zai-org/GLM-5.1 — 200k context / 128k max output.
  • deepseek-ai/DeepSeek-V3.2 — 163.8k context.
  • MiniMaxAI/MiniMax-M2.5 — 204.8k context.

Implementation details / trade-offs:

  • Handler is the minimal BaseOpenAiCompatibleProvider subclass (19 lines).
  • Full wiring across the registries: providerNames, zod schema, SECRET_STATE_KEYS, buildApiHandler switch, ProfileValidator, webview ApiOptions/constants/validate/useSelectedModel/providerModelConfig, and the bug-report provider dropdown.
  • i18n keys (friendliApiKey / getFriendliApiKey) added across all 18 locales, translating the "Friendli" brand name per each locale convention.

Test Procedure

Unit tests cover the handler and profile validation:

  • npx vitest run api/providers/__tests__/friendli.spec.ts → 17 tests pass (base URL, API key, default model, each of the 4 models config, stream text/usage, completePrompt success/empty/missing-choices, multi-chunk, temperature override).
  • npx vitest run shared/__tests__/ProfileValidator.spec.ts → 29 tests pass (includes friendli in the apiModelId provider list).

Type-check and lint pass clean for all three packages:

  • 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 verification (done locally in the Extension Development Host via F5):

스크린샷 2026-06-26 004509

Pre-Submission Checklist

  • Issue Linked: Closes [ENHANCEMENT] Add Friendli as an API provider for GLM-5.2 #722
  • Scope: Focused on adding the Friendli provider and its 4 models.
  • Self-Review: Reviewed all 36 changed files.
  • Testing: Handler spec (17 tests) + ProfileValidator spec (29 tests) added/updated; type-check + lint clean; local F5 smoke test done.
  • Documentation Impact: User-facing docs (providers page) may want a Friendli entry; can be filed against Zoo-Code-Docs separately.
  • Contribution Guidelines: Read and agree.

Get in Touch

Discord username available on request.

Summary by CodeRabbit

  • New Features
    • Added Friendli provider support end-to-end, including model selection, default model, and provider-specific API key configuration.
    • Added Friendli API key settings UI and localized labels for the new provider across supported languages.
  • Bug Fixes
    • Extended settings/profile validation so Friendli API keys and model IDs are handled consistently.
  • Tests
    • Added a comprehensive test suite covering Friendli request handling, streaming behavior, and settings validation.

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: df035ba1-40fd-4086-b430-b6b6a0345101

📥 Commits

Reviewing files that changed from the base of the PR and between d687acc and 0261b74.

📒 Files selected for processing (19)
  • packages/types/src/global-settings.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
✅ Files skipped from review due to trivial changes (18)
  • webview-ui/src/i18n/locales/ko/settings.json
  • webview-ui/src/i18n/locales/pl/settings.json
  • webview-ui/src/i18n/locales/nl/settings.json
  • webview-ui/src/i18n/locales/ca/settings.json
  • webview-ui/src/i18n/locales/zh-CN/settings.json
  • webview-ui/src/i18n/locales/tr/settings.json
  • webview-ui/src/i18n/locales/es/settings.json
  • webview-ui/src/i18n/locales/en/settings.json
  • webview-ui/src/i18n/locales/it/settings.json
  • webview-ui/src/i18n/locales/zh-TW/settings.json
  • webview-ui/src/i18n/locales/ru/settings.json
  • webview-ui/src/i18n/locales/id/settings.json
  • webview-ui/src/i18n/locales/vi/settings.json
  • webview-ui/src/i18n/locales/de/settings.json
  • packages/types/src/global-settings.ts
  • webview-ui/src/i18n/locales/hi/settings.json
  • webview-ui/src/i18n/locales/fr/settings.json
  • webview-ui/src/i18n/locales/ja/settings.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • webview-ui/src/i18n/locales/pt-BR/settings.json

📝 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

  • Zoo-Code-Org/Zoo-Code#81 — Both PRs extend the same provider-wiring code paths in packages/types, API handler routing, and UI model config for a different provider.
  • Zoo-Code-Org/Zoo-Code#344 — Both PRs update provider registration surfaces in shared types and backend routing for a new apiProvider entry.
  • Zoo-Code-Org/Zoo-Code#345 — Both PRs add provider-specific validation branches in webview-ui/src/utils/validate.ts.

Suggested labels

awaiting-review

Suggested reviewers

  • edelauna
  • JamesRobert20
  • navedmerchant
  • hannesrudolph
  • 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 is concise and accurately summarizes the new Friendli provider and its GLM-5.2 support.
Description check ✅ Passed The PR description covers the linked issue, implementation details, testing, checklist items, and UI evidence well enough for review.
Linked Issues check ✅ Passed The changes add Friendli wiring, API-key support, model metadata, UI settings, and tests, matching issue #722's requested behavior.
Out of Scope Changes check ✅ Passed All changes stay focused on adding Friendli provider support and related localization, tests, and wiring.
✨ 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

@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.

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

1 participant