Skip to main content

A lightweight wrapper around the Anthropic Python client for testing purposes

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anthropic_mock_wrapper-0.2.8.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

anthropic_mock_wrapper-0.2.8-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file anthropic_mock_wrapper-0.2.8.tar.gz.

File metadata

File hashes

Hashes for anthropic_mock_wrapper-0.2.8.tar.gz
Algorithm Hash digest
SHA256 f55e4c6326a21117e33c224f00549e3bfa6f54da5e2d38ff74f15c5f37a92b17
MD5 d643fc899994bdf681471ffa599532fe
BLAKE2b-256 0b4199485260e97926d62746bae3d9de367ade93fad4ab5bd284c30dbce90b96

See more details on using hashes here.

File details

Details for the file anthropic_mock_wrapper-0.2.8-py3-none-any.whl.

File metadata

File hashes

Hashes for anthropic_mock_wrapper-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 40c6a75640b9f697cd6054e87f3de7471ea78b92762bed01d2451312e40f84a5
MD5 55a9b2cab2415f402c6c32d3cc531afd
BLAKE2b-256 a1f62e524576782a9a8bc206cb2c31a075826fe5e33d2f5b27fa2312f80fd8d9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page