API Client for Tumeryk_Guardrails
Project description
Tumeryk Guardrails Client
Introduction
The Tumeryk Guardrails Client is an API client for interacting with Tumeryk Guardrails. It helps users to authenticate, retrieve available policies, set policies, and communicate with the Guard service. By default, the client connects to https://chat.tmryk.com, but the base URL can be changed if needed.
Installation
To install the Tumeryk Guardrails Client, use pip:
pip install tumeryk_guardrails
Configuration
The Tumeryk Guardrails Client uses chat.tmryk.com as the default base URL. However, you can change this URL if required. Here's how you can set a custom base URL:
import tumeryk_guardrails
# Set a custom base URL
tumeryk_guardrails.set_base_url("https://your-custom-url.com")
Example Usage
import tumeryk_guardrails
import os
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
# Retrieve credentials and policy from environment variables
username = os.getenv("TUMERYK_USERNAME")
password = os.getenv("TUMERYK_PASSWORD")
policy = os.getenv("POLICY")
# Authenticate with Tumeryk Guardrails
tumeryk_guardrails.login(username, password)
# Retrieve available policies
policies = tumeryk_guardrails.get_policies()
print("Available Policies:", policies)
# Set the chosen policy
tumeryk_guardrails.set_policy(policy)
# Prepare a message for the guard service
messages = [{"role": "user", "content": "Example input to guard"}]
# Send a request to the guard service
response = tumeryk_guardrails.tumeryk_completions(messages)
print("Guard Response:")
print(response)
Response Structure
The guard service returns a structured response. Here's an example:
{
'messages': [{
'role': 'assistant',
'content': 'I apologize, but I am not able to respond to that specific request. My purpose is to assist with tasks and provide information, not to access or modify code. Is there something else I can help you with?',
'Stats': '2 total calls, 1.89 total time, 1252 total tokens, 1170 total prompt tokens, 82 total completion tokens, [1.0, 0.89] as latencies',
'llm_process_time': 7.152557373046875e-07,
'violation': True
}]
}
Dependencies
- requests: Used for making HTTP requests to the API.
Project details
Release history Release notifications | RSS feed
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
Close
Hashes for tumeryk_guardrails-0.1.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 782d05bcbe16f73b3f16c082a2946ad399d7822c20253986d517be9bcd53c362 |
|
MD5 | b187c716f20a81e23972a331630bc6c9 |
|
BLAKE2b-256 | b3fd4a0fcdb7acae957ce1d6df62c75341cce51fd424549fc8d7d10667ac4c8e |