-
Notifications
You must be signed in to change notification settings - Fork 662
feat: create "providers" package #1198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
davidturnbull
wants to merge
20
commits into
main
Choose a base branch
from
davidt-providers-package
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29eebb6 to
09e1d7e
Compare
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors provider management across the Lingo.dev monorepo by consolidating scattered provider-specific code into two new shared packages:
@lingo.dev/providersand@lingo.dev/config.What Changed
For Users:
For Developers:
@lingo.dev/providerspackage that centralizes:createProviderClient())ProviderKeyMissingError,ProviderAuthFailedError,UnsupportedProviderError)@lingo.dev/configpackage for RC file management:getRcConfig()- reads from~/.lingodotdevrcsaveRcConfig()- writes to~/.lingodotdevrcPackages Modified
packages/cli/- Uses new provider factory and config packagepackages/compiler/- Uses new provider factory and config packagepackages/spec/- Enhanced provider type definitionspackages/config/- NEW - RC file managementpackages/providers/- NEW - Centralized provider logicFiles Changed
34 files changed: +1,016 insertions, -741 deletions
Key changes:
configandproviderscompiler/src/utils/llm-api-key.ts,compiler/src/utils/rc.tsTesting Instructions
Prerequisites
Test 1: Run Unit Tests
Providers package:
CLI provider routing:
Compiler provider routing:
Test 2: Test CLI with Different Providers
Configure a provider in your
i18n.json:{ "provider": { "id": "openai", "model": "gpt-4o", "prompt": "Translate professionally" } }Set the corresponding API key:
Run localization:
Test with other providers by changing
idto:anthropic,google,groq,mistral,ollama, oropenrouterTest 3: Test Compiler with Different Providers
The compiler is used via bundler integration (Vite, Next.js, etc.). Test with a demo project:
Using Vite demo:
cd demo/vite-projectConfigure the compiler in
vite.config.tswith a specific provider:Set API keys and run the dev server:
The compiler will validate provider API keys on startup and show clear error messages if any are missing.
Test other demo projects:
Test 4: Verify Error Handling
CLI - Test missing API key:
Compiler - Test missing API key:
Test 5: Config Commands
Test RC file operations:
Test 6: Full Regression
Run all tests:
pnpm testBuild all packages:
Migration Notes
No migration required - this is a non-breaking internal refactoring.