feat: Add api_key_provider to ModelProviderInfo#9
Conversation
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
There was a problem hiding this comment.
Please remove these - it'll just confuse a rebase and it does not really add any concrete value :)
There was a problem hiding this comment.
If we want a generic trait here let's make it such, rather than an anonymous function
// Note how we can enforce this trait to implement other traits to make it
// compatible, and avoid having to manually implement PartialEq here
trait ApiKeyProvider: Send + Sync + PartialEq + Debug {
fn get(): String;
}Then use as such, it's much cleaner, e.g.
pub api_key_provider: Option<dyn ApiKeyProvider>Might also make sense to not use an Arc here at all, as it's an upstream constraint you're enforcing? Have your trait engage with an arc instead (hold it, own it) :)
--
Another way we could do this btw is to replace the api_key with an enum, e.g.
enum ModelApiKey {
Provider(dyn ApiKeyProvider);
Env(string);
}Not strictly necessary for this hack though
e799b23 to
bc84211
Compare
I really am not sure what the method definition needs to look like, tried some much simpler approaches that didn't work.
Suggestions are more than welcome.