compass.services.openai.usage_from_response#
- usage_from_response(current_usage, response)[source]#
OpenAI usage parser
- Parameters:
current_usage (
dict
) – Dictionary containing current usage information. For OpenAI trackers, this may contain the keys"requests"
,"prompt_tokens"
, and"response_tokens"
if there is already existing tracking information. Empty dictionaries are allowed, in which case the three keys above will be added to this input.response (
openai.Completion
) – OpenAI Completion object. Must contain ausage
attribute that
- Returns:
dict
– Dictionary with updated usage statistics.