Skip to content
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

Allow user to provide their own HTTP client. #47

Closed
MichealReed opened this issue May 12, 2023 · 5 comments
Closed

Allow user to provide their own HTTP client. #47

MichealReed opened this issue May 12, 2023 · 5 comments

Comments

@MichealReed
Copy link

Per this issue -- invertase/dart_edge#34 this library is hard to use with serverless functions. It would be nice if this library allowed users to provide their own HTTP client for use such as supabase or https://pub.dev/documentation/googleapis_auth/latest/auth_io/clientViaServiceAccount.html.

@anasfik
Copy link
Owner

anasfik commented May 21, 2023

Hello, thank you for mentioning this!

Please, if you can, can you provide me with a clear explanation of the difference between having an internal http client and providing a way to assign a new one externally.

and if I am getting it right, you mean that all methods in client.dart should use that http client, right?

Thank you

@MichealReed
Copy link
Author

Exactly. Sometimes environments have specific requirements that cause devs to modify or create their own HTTP client. If we could optionally specify our own client and all methods used the custom http, devs could fix these problems without submitting issues here.

@anasfik
Copy link
Owner

anasfik commented May 23, 2023

Seems good to me, working on it!

@anasfik
Copy link
Owner

anasfik commented May 27, 2023

starting from 1.9.93, all package method that uses an HTTP client internally offers now the option to set your custom client to:

final cmpl = await OpenAI.instance.completion.create(
  // ...
  client: MyCustomClient(),
);

@MichealReed
Copy link
Author

@anasfik is there a way to update the instance's client globally? This works for completions but I cannot use with other modules like transcription.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants