Skip to content

Commit

Permalink
feat(chat.cr): add helper for tracking token usage
Browse files Browse the repository at this point in the history
  • Loading branch information
stakach authored Nov 3, 2023
1 parent b6c669a commit f5d57e6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/openai/api/chat.cr
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ module OpenAI
# The name and arguments of a function that should be called, as generated by the model.
getter function_call : ChatFunctionCall?

def initialize(@role, @content = nil, @name = nil, @function_call = nil)
@[JSON::Field(ignore: true)]
property tokens : Int32 = 0

def initialize(@role, @content = nil, @name = nil, @function_call = nil, @tokens = 0)
end
end

Expand Down

0 comments on commit f5d57e6

Please sign in to comment.