feat(friendli): add Friendli provider with GLM-5.2 support#721
feat(friendli): add Friendli provider with GLM-5.2 support#721Lee-Si-Yoon wants to merge 4 commits into
Conversation
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (19)
✅ Files skipped from review due to trivial changes (18)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds Friendli as an API provider across shared types, backend routing, settings UI, validation, and localized settings text. ChangesFriendli provider support
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
webview-ui/src/utils/validate.ts (1)
120-124: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a validation test for the new
friendliApiKeyrequirement.Please add/extend local unit tests to cover the new
friendlibranch 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 winAdd unit coverage for the new
friendliselection 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 winAdd local webview tests for the new Friendli settings component.
This introduces new rendering/input behavior but no corresponding
webview-uiVitest 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 localwebview-uitests... Add or update Vitest coverage underwebview-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
📒 Files selected for processing (36)
.github/ISSUE_TEMPLATE/bug_report.ymlpackages/types/src/global-settings.tspackages/types/src/provider-settings.tspackages/types/src/providers/friendli.tspackages/types/src/providers/index.tssrc/api/index.tssrc/api/providers/__tests__/friendli.spec.tssrc/api/providers/friendli.tssrc/api/providers/index.tssrc/shared/ProfileValidator.tssrc/shared/__tests__/ProfileValidator.spec.tswebview-ui/src/components/settings/ApiOptions.tsxwebview-ui/src/components/settings/constants.tswebview-ui/src/components/settings/providers/Friendli.tsxwebview-ui/src/components/settings/providers/index.tswebview-ui/src/components/settings/utils/providerModelConfig.tswebview-ui/src/components/ui/hooks/useSelectedModel.tswebview-ui/src/i18n/locales/ca/settings.jsonwebview-ui/src/i18n/locales/de/settings.jsonwebview-ui/src/i18n/locales/en/settings.jsonwebview-ui/src/i18n/locales/es/settings.jsonwebview-ui/src/i18n/locales/fr/settings.jsonwebview-ui/src/i18n/locales/hi/settings.jsonwebview-ui/src/i18n/locales/id/settings.jsonwebview-ui/src/i18n/locales/it/settings.jsonwebview-ui/src/i18n/locales/ja/settings.jsonwebview-ui/src/i18n/locales/ko/settings.jsonwebview-ui/src/i18n/locales/nl/settings.jsonwebview-ui/src/i18n/locales/pl/settings.jsonwebview-ui/src/i18n/locales/pt-BR/settings.jsonwebview-ui/src/i18n/locales/ru/settings.jsonwebview-ui/src/i18n/locales/tr/settings.jsonwebview-ui/src/i18n/locales/vi/settings.jsonwebview-ui/src/i18n/locales/zh-CN/settings.jsonwebview-ui/src/i18n/locales/zh-TW/settings.jsonwebview-ui/src/utils/validate.ts
|
Hi maintainers 👋 — the patch coverage check flags the |
Related GitHub Issue
Closes: #722
Description
Add Friendli as a new OpenAI-compatible provider. Friendli serves models at
https://api.friendli.ai/serverless/v1with 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:
BaseOpenAiCompatibleProvidersubclass (19 lines).providerNames, zod schema,SECRET_STATE_KEYS,buildApiHandlerswitch,ProfileValidator, webviewApiOptions/constants/validate/useSelectedModel/providerModelConfig, and the bug-report provider dropdown.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 (includesfriendliin theapiModelIdprovider 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):
Pre-Submission Checklist
Get in Touch
Discord username available on request.
Summary by CodeRabbit