def _get_prompt_to_summarize(
        self, chat_history_to_be_summarized: List[ChatMessage]
    ) -> str:
        """Ask the LLM to summarize the chat history so far."""
        # TODO: This probably works better when question/answers are considered together.
        prompt = '"Transcript so far: '
        for msg in chat_history_to_be_summarized:
            if not isinstance(msg.content, str):
                continue

            prompt += msg.role + ": "
            if msg.content:
                prompt += msg.content + "\n\n"
            else:
                prompt += (
                    "\n".join(
                        [
                            f"Calling a function: {call!s}"
                            for call in msg.additional_kwargs.get("tool_calls", [])
                        ]
                    )
                    + "\n\n"
                )
        prompt += '"\n\n'
        return prompt
Ask the LLM to summarize the chat history so far.
llama-index-core/llama_index/core/memory/chat_summary_memory_buffer.py