Skip to main content

API Client for Tumeryk_Guardrails

Project description

Tumeryk Guardrails Client

The Tumeryk Guardrails Client is a Python package that provides an interface to the Tumeryk Guardrails API. The client allows you to easily use the API from your Python code.

Setup

To install the Tumeryk Guardrails Client, use pip:

pip install tumeryk_guardrails

Example .env File

TUMERYK_USERNAME=sample_username
TUMERYK_PASSWORD=sample_password
TUMERYK_POLICY=hr_policy

Simple Usage

You can use the Tumeryk Guardrails Client with minimal setup. The client will automatically load the configuration from the .env file if it exists. Here's an example of simple usage:

from dotenv import load_dotenv
load_dotenv()

import tumeryk_guardrails


messages = [{"role": "user", "content": "hi"}]

response = tumeryk_guardrails.tumeryk_completions(messages=messages)

print(response)

Manual Usage

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")

Configuration

The Tumeryk Guardrails Client uses environment variables to store credentials and policy. Here's an example of how to use environment variables:

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("TUMERYK_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
    }]
}

Available Methods

The Tumeryk Guardrails Client provides the following methods to interact with the Tumeryk Guardrails API:

  • login(username, password): Authenticate and store access token.
  • get_policies(): Fetch available policies and return a list.
  • set_policy(config_id): Set the configuration/policy to be used by the user.
  • tumeryk_completions(messages): Send user input to the Guard service.
  • get_base_url(): Get the current base URL.
  • set_base_url(base_url): Set a new base URL.

Dependencies

  • requests: Used for making HTTP requests to the API.

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

tumeryk_guardrails-0.1.97.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

tumeryk_guardrails-0.1.97-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file tumeryk_guardrails-0.1.97.tar.gz.

File metadata

  • Download URL: tumeryk_guardrails-0.1.97.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for tumeryk_guardrails-0.1.97.tar.gz
Algorithm Hash digest
SHA256 389c104b932548f197defd9e2ea75764623cd3ee470baf08a0a1c2c417a835e1
MD5 dec5dd3ba150f5d1f4dc5bff2a92a526
BLAKE2b-256 f7ac35342786530e03b226995ada462b586616d1a3ada29ee1cea0a9b81b73c5

See more details on using hashes here.

File details

Details for the file tumeryk_guardrails-0.1.97-py3-none-any.whl.

File metadata

File hashes

Hashes for tumeryk_guardrails-0.1.97-py3-none-any.whl
Algorithm Hash digest
SHA256 8d29f1c1ddfaab93d3c51889ef9b6de387dff17c24afa6094231ab6426ade7e6
MD5 ed9bba19f4865c47e5f85c92fba61b6d
BLAKE2b-256 5bc649667149e65b54c6ffb64a3e09598adc88bded8e1c2c6e1b999cf302b307

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