Skip to content

Conversation

letschers
Copy link
Contributor

@letschers letschers commented Dec 8, 2022

I need to keep track of how much tokens every completion spended in my personal project. I noticed that the OpenAI API returns this information, so it was simple to add to the CompletionResponse

I noticed too that some responses of go-gpt3 already have this kind of data being returned, so I tried to follow the pattern of the EditsResponseUsage struct

This data being available may be helpful for someone in the future =]

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

✅ This pull request was sent to the PullRequest network.


@letschers you can click here to see the review status or cancel the code review job.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

PullRequest Breakdown

Reviewable lines of change

+ 8
- 0

100% Go

Type of change

Minor Update - These changes appear to be a minor update to existing functionality and features.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

This is fairly straightforward, I didn't notice any major issues.


Unrelated / low-priority / out of scope point. I did read through other parts of this file and noticed some typos. The word "response" is misspelled as "respnose" on line 16 and as "reponse" on line 21. Almost not worth calling out, but since I already noticed it, just wanted to briefly mention.

Image of Ryan B Ryan B


Was this helpful? Yes | No

Reviewers will be notified any time you reply to their comments or commit new changes.
You can also request a full follow-up review from your PullRequest dashboard.

models.go Outdated
Usage CompletionResponseUsage `json:"usage"`
}

//CompletionResponseUsage is the object that returns how many tokens the completion's request used
Copy link

Choose a reason for hiding this comment

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

Very minor nit: there's a space missing after the //:

// CompletionResponseUsage

🔹 Style Consistency (Nice to have)

Image of Ryan B Ryan B

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the review! Done

Copy link
Contributor

@tylermann tylermann left a comment

Choose a reason for hiding this comment

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

Thanks for the addition here @letschers, this looks good to me.

@tylermann tylermann merged commit 5ba9f56 into PullRequestInc:main Dec 8, 2022
@letschers letschers deleted the add-token-usage branch December 9, 2022 00:55
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