def chat(self, messages: List[ChatMessage], **kwargs) -> ChatResponse:
        """
        Generate a chat response for the given messages.
        """
        messages_list = [
            {"role": msg.role, "content": msg.blocks[0].text} for msg in messages
        ]
        response = self._generate(
            knowledge=kwargs.get("knowledge_base"),
            messages=messages_list,
            model=self.model,
            system_prompt=self.system_prompt,
            **kwargs,
        )
        return ChatResponse(
            message=ChatMessage(role=MessageRole.ASSISTANT, content=response)
        )

        Generate a chat response for the given messages.
        
llama-index-integrations/llms/llama-index-llms-contextual/llama_index/llms/contextual/base.py