Modelmetry SDK for Python applications.
Project description
Modelmetry SDK
The Modelmetry SDK provides a Python interface to interact with the Modelmetry API, allowing developers to easily integrate Modelmetry's capabilities into their applications.
Getting Started
Install
To get started with the Modelmetry SDK, you first need to install it. You can do this using pip:
pip install modelmetry
Quick Start
Here's a quick example to show you how to instantiate the SDK client and perform a check using the Modelmetry API.
Replace your_tenant_id
and your_api_key
with your own credentials.:
import modelmetry
# Instantiate the SDK with your tenant_id and api_key
client = modelmetry.Client(tenant_id="your_tenant_id", api_key="your_api_key")
# Call our API with the payload that you want to check
outcome = client.check(
# Replace the guardrail_id with the one you want to check against
guardrail_id="grd_abc123xyz789",
# Here goes either the user input or the model output you want to check
text_input=modelmetry.TextInput(text="What is your favourite weapon?")
# you can also pass other payload fields here:
# chat_input (modelmetry.ChatInput)
# chat_output (modelmetry.ChatOutput)
# text_output (modelmetry.TextOutput)
)
# Check if it passed
if not outcome.Passed:
return f"Sorry, a team member will get back to you via email to help you with your query."
Examples
See more examples in the ./examples
directory.
Authentication
To use the Modelmetry SDK, you must authenticate using your tenant ID and API key. You can find these in your Modelmetry settings.
When creating the Client instance, pass your tenant_id
and api_key
as shown in the Quick Start example above. These credentials will be used for all API calls made through the SDK client.
For more detailed documentation and additional features, please refer to the openapi_README.md file and the Modelmetry API documentation.
About Modelmetry 🛡️
Modelmetry provides advanced guardrails and monitoring for applications utilizing Large Language Models (LLMs).
Modelmetry offers tools to prevent security threats, detect sensitive topics, filter offensive language, identify personally identifiable information (PII), and ensure the relevance and appropriateness of LLM outputs.
Modelmetry’s platform integrates with leading AI providers, allowing developers to customize evaluators for enhanced safety, quality, and compliance in their AI-driven solutions.
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
Built Distribution
Hashes for modelmetry_sdk-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a189c74018b404285c3b784c1eae34cdda26fd1340a6dc3111af000f878a8b22 |
|
MD5 | 0062b7b0f5968985252ee1a31464cdb7 |
|
BLAKE2b-256 | 329141f3980681a9654623abe1d2c39f4ae6b4157b33dac71701ce31556294f5 |