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 (
object) – OpenAI Completion object (openai.Completion). Must contain ausageattribute that containsprompt_tokensandcompletion_tokenscounts as attributes.
- Returns:
dict– Dictionary with updated usage statistics.