Skip to main content

Python Ragmetrics

Call all LLM APIs using the OpenAI format.

PyPI Version

Ragmetrics manages:

  • Translate inputs to provider's completion endpoints
  • Consistent Traces logged on Ragmetrics portal
  • Realtime Monitoring and AB Test Evaluations

Support for more providers. Contact our team to get it done.

Usage Docs

pip install ragmetrics-pkg

Portal Login

import ragmetrics

## login to ragmetrics account via portal key
ragmetrics.login(key="febfe*****************", off=False)

Here off flag helps developer to toggle traces.
off -> True (will turn off the traces and vice versa)

Monitoring/AB Testing/Evaluation (based on compare models)

import ragmetrics

## starts monitoring all LLM calls from this client
ragmetrics.monitor(client, context={"user": True})

Context will help to feed as dataset over Ragmetrics Tasks for Evaluation

Code Utilisation

from openai import OpenAI
import ragmetrics

client = OpenAI()

# Start monitoring all LLM calls from this client
ragmetrics.monitor(client, context={"user": True})

# Use regular OpenAI API calls with an extra optional metadata parameter
chat_completion = client.chat.completions.create(
  model="gpt-4o", 
  messages=[{"role": "user", "content": "Hello Ragmetrics"}],
  metadata={"pipelineStep":"generation", "property1":"Accuracy and Clarity"},
  comparison_model="gpt-4-turbo"
)
  • Here model is to refer the response generation model gpt-4o in our case.
  • Message with content for the actual developer's request to AI model.
  • Metadata is to drive the experiments as defined below:
    • pipelineStep for selecting the evaluation step as per Ragmetrics platform experiments.
    • property to add multiple criteria needs to be performed under evaluation (will be added with keys property1, property2... etc.)

Code Examples

Example 1

from openai import OpenAI
import ragmetrics

ragmetrics.login(key="febfe*****************", off=False)

client = OpenAI()

ragmetrics.monitor(client, context={"user": True})

chat_completion = client.chat.completions.create(
  model="gpt-4o", 
  messages=[{"role": "user", "content": "Hello World !!!"}],
  metadata={"pipelineStep":"generation", "property1":"Accuracy and Clarity"},
  comparison_model="gpt-4-turbo"
  )

Example 2

from openai import OpenAI
import ragmetrics

ragmetrics.login(key="febfe*****************", off=False)

client = OpenAI()

ragmetrics.monitor(client, context={"user": True})

chat_completion = client.chat.completions.create(
  model="gpt-3.5-turbo", 
  messages=[{"role": "user", "content": "How's the day today?"}],
  metadata={"pipelineStep":"generation", "property1":"Accuracy and Clarity", "property2":"Buddy-Friendly Tone"},
  comparison_model="gpt-4o"
  )

Portal Keys UI on Ragmetrics Portal

portal_keys.png

Why did we build this

  • Need for simplicity: We need to provide developers a hassle-free solution to interact and monitor their interaction with LLM models like Azure, OpenAI, LiteLLM ... etc.

Contributors

Metadata

Release files for ragmetrics-pkg 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ragmetrics-pkg 0.1.4
File Size Uploaded Provenance Actions
ragmetrics-pkg-0.1.4.tar.gz 5.0 kB Without provenance Details for ragmetrics-pkg-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ragmetrics-pkg 0.1.4
File Interpreter ABI Platform Actions
ragmetrics_pkg-0.1.4-py3-none-any.whl Python 3 none any Details for ragmetrics_pkg-0.1.4-py3-none-any.whl

Total release size: 10.3 kB

Release files / ragmetrics-pkg-0.1.4.tar.gz

Download URL ragmetrics-pkg-0.1.4.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
411c64eba977f47c17016151239ebbce7b749624a7cd2e898d27ba1106790d27
BLAKE2b-256 checksum
How to use checksums
614336f9e3418eae98e02eccd460b8e713b4dcb5aff4541e6061747e06f688d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.10.12

Release files / ragmetrics_pkg-0.1.4-py3-none-any.whl

Download URL ragmetrics_pkg-0.1.4-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
07ba2d640db4c7b25925114f946e9d971846b12c632db320c142c41ba119f3f7
BLAKE2b-256 checksum
How to use checksums
1b3485c319038462569d78942bce4ad07361f47141ab89e7fc344957158cbe43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.10.12

Security for ragmetrics-pkg 0.1.4

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page