anthropic_mock_wrapper
A lightweight wrapper around the Anthropic Python client for testing purposes.
Save money on your Anthropic API usage by mocking responses when your API key is prefixed with TEST_.
Installation
You can install the anthropic_mock_wrapper package using pip:
pip install anthropic_mock_wrapper
from anthropic_mock_wrapper import AnthropicMockWrapper
Initialize the client
client = AnthropicMockWrapper(api_key="TEST_your_api_key_here")
Use the client to interact with Anthropic's API
response = client.complete(
prompt="Hello, world!",
model="claude-2",
max_tokens_to_sample=100
)
print(response)
from anthropic_mock_wrapper import AnthropicMockWrapper
# Initialize the testable client
testable_client = AnthropicMockWrapper(api_key="test_key")
#Set a mock response
testable_client.set_mock_response({
"completion": "This is a mock response",
"stop_reason": "stop_sequence",
"model": "claude-2"
})
# Use the client in your tests
response = testable_client.complete(
prompt="Test prompt",
model="claude-2",
max_tokens_to_sample=100
)
assert response["completion"] == "This is a mock response"
Build
python -m build
License
This project is licensed under the MIT License - see the LICENSE file for details.
Disclaimer
This is an unofficial Mocker and is not affiliated with or endorsed by Anthropic. Use at your own risk.
Metadata
Release files for anthropic-mock-wrapper 0.2.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| anthropic_mock_wrapper-0.2.10.tar.gz | 4.7 kB | Without provenance | Details for anthropic_mock_wrapper-0.2.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| anthropic_mock_wrapper-0.2.10-py3-none-any.whl | Python 3 | none | any | Details for anthropic_mock_wrapper-0.2.10-py3-none-any.whl |
Total release size: 9.7 kB
Release files / anthropic_mock_wrapper-0.2.10.tar.gz
| Download URL | anthropic_mock_wrapper-0.2.10.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be76fa53cac39bdb9ece2b2aed67837d56aaae5c8ea3383fef557a16f84f2a16
|
|
BLAKE2b-256 checksum How to use checksums |
2ebc0f0c64c450235836020f1580d4a92b8fa5d80ea3db3b6bd4735e0b2e430c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / anthropic_mock_wrapper-0.2.10-py3-none-any.whl
| Download URL | anthropic_mock_wrapper-0.2.10-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
55820c0e278075df06a2b97905ef7be0b73c261ab2f765d99cae636d383dec1d
|
|
BLAKE2b-256 checksum How to use checksums |
0328bedfa53d901966325486e12ecdf75846499e3d1263f443b6f0eaaafb2223
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Security for anthropic-mock-wrapper 0.2.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.