View module source on GitHub

GeminiUtils

class GeminiUtils()

parse_gemini_generation_content

@staticmethod
def parse_gemini_generation_content(
        response: GenerateContentResponse) -> Dict[str, Any]

Parse the generation response from Google’s Generative AI API into a standardized format.

Arguments:

NameTypeDescription
responseGenerateContentResponseThe raw response from the model

Returns:

Dict[str, Any]: A dictionary containing the parsed response with standardized fields:

  • usage: Token counts for prompt and completion
  • id: Generated UUID for the response
  • created: Unix timestamp of when response was parsed