Skip to main content

A package for integrating RagMetrics with LLM calls

Project description

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

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

ragmetrics-pkg-0.1.4.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ragmetrics_pkg-0.1.4-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file ragmetrics-pkg-0.1.4.tar.gz.

File metadata

  • Download URL: ragmetrics-pkg-0.1.4.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.12

File hashes

Hashes for ragmetrics-pkg-0.1.4.tar.gz
Algorithm Hash digest
SHA256 411c64eba977f47c17016151239ebbce7b749624a7cd2e898d27ba1106790d27
MD5 a7e709d7a8bdf3bc44ada604256cc757
BLAKE2b-256 614336f9e3418eae98e02eccd460b8e713b4dcb5aff4541e6061747e06f688d1

See more details on using hashes here.

File details

Details for the file ragmetrics_pkg-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: ragmetrics_pkg-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.12

File hashes

Hashes for ragmetrics_pkg-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 07ba2d640db4c7b25925114f946e9d971846b12c632db320c142c41ba119f3f7
MD5 4318cad8cc7065f79497834030c8122b
BLAKE2b-256 1b3485c319038462569d78942bce4ad07361f47141ab89e7fc344957158cbe43

See more details on using hashes here.

Supported by

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