Skip to content

Commit 9ff3dd5

Browse files
Add Client::build for full customizability during instantiation (64bit#197)
1 parent 7832a23 commit 9ff3dd5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

async-openai/src/client.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ impl Client<OpenAIConfig> {
3535
}
3636

3737
impl<C: Config> Client<C> {
38+
/// Create client with a custom HTTP client, OpenAI config, and backoff.
39+
pub fn build(
40+
http_client: reqwest::Client,
41+
config: C,
42+
backoff: backoff::ExponentialBackoff,
43+
) -> Self {
44+
Self {
45+
http_client,
46+
config,
47+
backoff,
48+
}
49+
}
50+
3851
/// Create client with [OpenAIConfig] or [crate::config::AzureConfig]
3952
pub fn with_config(config: C) -> Self {
4053
Self {

0 commit comments

Comments
 (0)