def from_ai_reply()

in bot/gemini_model.py [0:0]


    def from_ai_reply(cls, response: GenerateContentResponse | Part) -> "ChatPart":
        """
        Create a model ChatPart object from Gemini response.

        Stores the text content of the message and assigns the `role` as "model".
        Saves the token count from the model response.
        """
        part = Part.from_text(text=response.text)
        if isinstance(response, GenerateContentResponse):
            tokens = response.usage_metadata.candidates_token_count
        else:
            tokens = cls._count_tokens(part)
        return cls(part, "model", tokens)