Log requests in a beautiful, twitter-friendly format showing Claude to OpenAI mapping.
(
method, path, claude_model, openai_model, num_messages, num_tools, status_code
)
| 1662 | |
| 1663 | |
| 1664 | def log_request_beautifully( |
| 1665 | method, path, claude_model, openai_model, num_messages, num_tools, status_code |
| 1666 | ): |
| 1667 | """Log requests in a beautiful, twitter-friendly format showing Claude to OpenAI mapping.""" |
| 1668 | # Format the Claude model name nicely |
| 1669 | claude_display = f"{Colors.CYAN}{claude_model}{Colors.RESET}" |
| 1670 | |
| 1671 | # Extract endpoint name |
| 1672 | endpoint = path |
| 1673 | if "?" in endpoint: |
| 1674 | endpoint = endpoint.split("?")[0] |
| 1675 | |
| 1676 | # Extract just the OpenAI model name without provider prefix |
| 1677 | openai_display = openai_model |
| 1678 | if "/" in openai_display: |
| 1679 | openai_display = openai_display.split("/")[-1] |
| 1680 | openai_display = f"{Colors.GREEN}{openai_display}{Colors.RESET}" |
| 1681 | |
| 1682 | # Format tools and messages |
| 1683 | tools_str = f"{Colors.MAGENTA}{num_tools} tools{Colors.RESET}" |
| 1684 | messages_str = f"{Colors.BLUE}{num_messages} messages{Colors.RESET}" |
| 1685 | |
| 1686 | # Format status code |
| 1687 | status_str = ( |
| 1688 | f"{Colors.GREEN}✓ {status_code} OK{Colors.RESET}" |
| 1689 | if status_code == 200 |
| 1690 | else f"{Colors.RED}✗ {status_code}{Colors.RESET}" |
| 1691 | ) |
| 1692 | |
| 1693 | # Put it all together in a clear, beautiful format |
| 1694 | log_line = f"{Colors.BOLD}{method} {endpoint}{Colors.RESET} {status_str}" |
| 1695 | model_line = f"{claude_display} → {openai_display} {tools_str} {messages_str}" |
| 1696 | |
| 1697 | # Print to console |
| 1698 | print(log_line) |
| 1699 | print(model_line) |
| 1700 | sys.stdout.flush() |
| 1701 | |
| 1702 | |
| 1703 | if __name__ == "__main__": |
no outgoing calls
no test coverage detected