Skip to content

Commit

Permalink
Merge pull request #24 from mlang/usageMonoid
Browse files Browse the repository at this point in the history
Usage is a Monoid
  • Loading branch information
nickhs authored Jul 13, 2024
2 parents e02e5d8 + 176a757 commit b1756a4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions openai-servant/src/OpenAI/Resources.hs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ data Usage = Usage

$(deriveJSON (jsonOpts 2) ''Usage)

instance Semigroup Usage where
Usage a1 a2 a3 <> Usage b1 b2 b3 = Usage (a1 + b1) (a2 + b2) (a3 + b3)

instance Monoid Usage where
mempty = Usage 0 0 0

------------------------
------ Model API
------------------------
Expand Down

0 comments on commit b1756a4

Please sign in to comment.