Skip to content

Commit 75c0e37

Browse files
authored
Fix details fields to be optional (#45)
Testing shows that they aren't always present
1 parent 6641dee commit 75c0e37

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/OpenAI/V1/Usage.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ import OpenAI.Prelude
1212

1313
-- | Breakdown of tokens used in a completion
1414
data CompletionTokensDetails = CompletionTokensDetails
15-
{ accepted_prediction_tokens :: Natural
16-
, audio_tokens :: Natural
17-
, reasoning_tokens :: Natural
18-
, rejected_prediction_tokens :: Natural
15+
{ accepted_prediction_tokens :: Maybe Natural
16+
, audio_tokens :: Maybe Natural
17+
, reasoning_tokens :: Maybe Natural
18+
, rejected_prediction_tokens :: Maybe Natural
1919
} deriving stock (Generic, Show)
2020
deriving anyclass (FromJSON)
2121

2222
-- | Breakdown of tokens used in the prompt
2323
data PromptTokensDetails = PromptTokensDetails
24-
{ audio_tokens :: Natural
25-
, cached_tokens :: Natural
24+
{ audio_tokens :: Maybe Natural
25+
, cached_tokens :: Maybe Natural
2626
} deriving stock (Generic, Show)
2727
deriving anyclass (FromJSON)
2828

0 commit comments

Comments
 (0)