-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Better configuration #79
Conversation
* new functions to allow HTTPClient configuration * updated go.mod for testing from remote * updated go.mod for remote testing * revert go.mod replace directives * Fixed NewOrgClientWithTransport comment
@mwillfox @yangyanqing @DarkDust @ealvar3z @Rascal0814 @RobotSail would love your review! |
|
||
// ClientConfig is a configuration of a client. | ||
type ClientConfig struct { | ||
authToken string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is authToken
private, but the other fields are public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question! I made it public at first but then figured that I couldn't imagine a case where it needs to be modified or explicitly accessed.
I also thought it would prevent accidental logging, but it seems that it is not the case.
Should I make it public?
🤔 🤔 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just my opinion, but this is how I generally build clients - by allowing any tokens to be passed in at "construction" and then not accessed again. I'm not sure this actually increases security but, like you said, prevents it from being accidentally logged or exposed again. What happens if someone serializes the ClientConfig
to JSON? By not exporting the field you prevent that unintentional leak.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mwillfox btw, it leaks if you do %v
printing of the struct
LGTM |
This satisfies my original use case of plugging in |
Merged and published in /~https://github.com/sashabaranov/go-gpt3/releases/tag/v1.2.0 |
This PR aims to make the client completely configurable, following up #75 and #4. It also fixes #70.
The idea is to pass-by-value config struct, which would be encapsulated inside the client.
Here we preserve the standard way of creating clients as
client := gogpt.NewClient("auth token")
and add a new way of configuring clients: