Show HN: LLM-mock – Record and replay OpenAI/Anthropic calls in pytest (v1.0) (github.com)

🤖 AI Summary
A new pytest plugin, **llm-mock**, has been released, enabling developers to effortlessly record and replay API calls made to OpenAI and Anthropic's language models in their tests. By using llm-mock, developers can record responses from the real APIs once, storing them as JSON files, which can be used for deterministic testing without requiring API keys during continuous integration (CI) runs. This significantly reduces costs associated with API usage during testing and eliminates issues related to non-deterministic responses, as tests can be run offline and execute instantly without network calls. The plugin seamlessly integrates with existing code, allowing developers to record responses in "record" mode while retaining the flexibility to replay them in tests with a simple decorator. It employs HTTP interception at the transport layer, ensuring that production code remains untouched. This approach not only enhances testing efficiency and reliability but also supports streaming responses, making it a valuable tool for the AI/ML community, particularly for developers seeking to streamline their testing processes while working with LLMs.
Loading comments...
loading comments...