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

check api key on client init #7

Merged
merged 3 commits into from
Jan 5, 2022
Merged

check api key on client init #7

merged 3 commits into from
Jan 5, 2022

Conversation

alexguo247
Copy link
Contributor

Added check for api key validity on client init with tests.

@alexguo247 alexguo247 requested a review from jimwu6 January 4, 2022 23:11
example/main.go Outdated
co := cohere.CreateClient(apiKey)
co, err := cohere.CreateClient(apiKey)
if err != nil {
fmt.Println("invalid api key")
Copy link
Contributor

@jimwu6 jimwu6 Jan 5, 2022

Choose a reason for hiding this comment

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

we should probably just print the error here, since it could be a network issue or api issue

@@ -49,6 +70,7 @@ func (c *Client) post(model string, endpoint string, body interface{}) ([]byte,

req.Header.Set("Authorization", "BEARER "+c.APIKey)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Request-Source", "go-sdk")
Copy link
Contributor

Choose a reason for hiding this comment

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

nice catch!

@alexguo247 alexguo247 merged commit fcd44a7 into main Jan 5, 2022
@jimwu6 jimwu6 deleted the check-api-key branch January 5, 2022 16:50
CoderHam pushed a commit that referenced this pull request Jul 19, 2022
- It was changed to also return error in #7
CoderHam pushed a commit that referenced this pull request Jul 19, 2022
- function signature was changed to also return error in #7
CoderHam pushed a commit that referenced this pull request Jul 20, 2022
- function signature was changed to also return error in #7
CoderHam added a commit that referenced this pull request Jul 21, 2022
* Fix CreateClient usage in ReadMe
- function signature was changed to also return error in #7

* Add error checking and logging for CreateClient to ReadMe example

* replace tabs with spaces

Co-authored-by: CoderHam <hemanham@gmail.ßcom>
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.

3 participants