Skip to content

Removing client mutability #170

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

BRLunt
Copy link

@BRLunt BRLunt commented Jun 19, 2025

This PR removes &mut self from methods in the OpenAIClientimplementation as suggested in #168.

  • it removes the response_headers field from rhe OpenAIClient

This change was made to avoid the need to clone the client when making concurrent or repeated requests improving ergonomics.

Since the response headers were public, this is a breaking change IMO.

#[derive(Debug)]
pub struct OpenAIClient {
    api_endpoint: String,
    api_key: Option<String>,
    organization: Option<String>,
    proxy: Option<String>,
    timeout: Option<u64>,
    headers: Option<HeaderMap>,
    pub response_headers: Option<HeaderMap>,
}

armour-bees added 2 commits June 19, 2025 22:29
@dongri
Copy link
Owner

dongri commented Jun 19, 2025

@BRLunt Thank you for creating the PR. The reason I used &mut is that the rate limit information is returned in the headers of the API response, and this was implemented to handle that. However, this PR removes that functionality—what are your thoughts on this?

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

Successfully merging this pull request may close these issues.

2 participants