-
Notifications
You must be signed in to change notification settings - Fork 21
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
fix(auth): simplify provider handling with URL-based configuration #465
Conversation
- Refactor provider service to support multiple authentication methods\n- Add support for Antinomy provider\n- Update OpenRouter URL from api.openrouter.io to openrouter.ai\n- Improve provider architecture with generics\n- Add force_antinomy flag for environment configuration\n- Restructure client builder pattern for better type safety
…der configuration
- Remove serde feature from url dependency - Remove Serialize, Deserialize and From derives from Provider enum - Extract provider resolution logic to a separate method
crates/forge_infra/src/env.rs
Outdated
@@ -33,14 +33,24 @@ impl ForgeEnvironmentService { | |||
fn get(&self) -> Environment { | |||
dotenv::dotenv().ok(); | |||
let cwd = std::env::current_dir().unwrap_or(PathBuf::from(".")); |
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.
Provider can store the key.
Added a new commit to further simplify the Provider implementation:
This continues the refactoring work to streamline the authentication system. |
)), | ||
|
||
forge_domain::Provider::Anthropic => Ok(Client::Anthropic( | ||
Anthropic::builder().api_key(api_key).build()?, |
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.
Use a derived builder.
- Restructure Provider enum to include API keys in its variants - Remove dependency on Infrastructure in ForgeProviderService - Update Environment to store Provider instance instead of separate URL and key - Add serde feature to URL dependency for serialization support - Update tests to use the new Provider structure - Simplify client builder to get API key directly from Provider
…r handling - Remove mutex and lazy initialization in ForgeProviderService - Add key() and is_antinomy() helper methods to Provider struct - Replace ClientBuilder with simpler Client::new() constructor - Update AnthropicBuilder to use derive_builder::Builder - Improve URL handling in OpenRouter implementation
} | ||
if self.provider.is_open_router() | self.provider.is_antinomy() { | ||
// For Eg: https://openrouter.ai/api/v1/parameters/google/gemini-pro-1.5-exp | ||
let path = format!("parameters/{}", model.as_str()); |
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.
let path = format!("parameters/{}", model.as_str()); | |
let path = if self.provider.is_antinomy() { | |
format!("model/{}/parameters", model.as_str()) | |
} else { | |
format!("parameters/{}", model.as_str()) | |
}; |
…enhance parameter fetching logic
This PR refactors the authentication system to use URL-based provider detection instead of enum-based configuration, providing more flexibility in supporting different provider endpoints.
Changes
Testing
The implementation preserves backward compatibility while adding new functionality.