Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@geoah
Copy link

@geoah geoah commented Jun 5, 2025

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.

@geoah geoah requested a review from cpluss June 5, 2025 08:49
@github-actions
Copy link

github-actions bot commented Jun 5, 2025


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


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.

Comment on lines 26 to 34
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove these - it'll just confuse a rebase and it does not really add any concrete value :)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to a trait with arc

@geoah geoah force-pushed the goah/token-method branch 3 times, most recently from e799b23 to bc84211 Compare June 6, 2025 13:04
@geoah geoah force-pushed the goah/token-method branch from bc84211 to cae4b8e Compare June 6, 2025 13:17
@geoah geoah merged commit 66cbaae into main-reflection Jun 6, 2025
1 check failed
@geoah geoah deleted the goah/token-method branch June 6, 2025 14:25
@github-actions github-actions bot locked and limited conversation to collaborators Jun 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants