def chat_completions(
        self, messages: list, tools: list = [], stop=None, response_format=None
    ):
        """Get completions for chat.

        tools docs: https://docs.anthropic.com/en/docs/build-with-claude/tool-use
        """
        system, messages = self._format_messages(messages)
        params = {
            "model": self.chat_model,
            "messages": messages,
            "system": system,
            "max_tokens": self.max_tokens,
        }
        if tools:
            params["tools"] = self._format_tools(tools)

        try:
            response = self.client.messages.create(**params)
        except Exception as e:
            raise e
            return LLMResponse(content=f"Error: {e}")

        return LLMResponse(
            content=response.content[0].text,
            tool_calls=[
                {
                    "id": response.content[1].id,
                    "tool": {
                        "name": response.content[1].name,
                        "arguments": response.content[1].input,
                    },
                    "type": response.content[1].type,
                }
            ]
            if next(
                (block for block in response.content if block.type == "tool_use"), None
            )
            is not None
            else [],
            finish_reason=response.stop_reason,
            send_tokens=response.usage.input_tokens,
            recv_tokens=response.usage.output_tokens,
            total_tokens=(response.usage.input_tokens + response.usage.output_tokens),
            status=LLMResponseStatus.SUCCESS,
        )
Get completions for chat.

        tools docs: https://docs.anthropic.com/en/docs/build-with-claude/tool-use
        
backend/director/llm/anthropic.py