A package for integrating RagMetrics with LLM calls
Project description
Ragmetrics
Call all LLM APIs using the OpenAI format.
Ragmetrics manages:
- Translate inputs to provider's
completionendpoints - Consistent
Traceslogged 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
modelis to refer the response generation modelgpt-4oin our case. Messagewith content for the actual developer's request to AI model.Metadatais to drive the experiments as defined below:pipelineStepfor selecting the evaluation step as per Ragmetrics platform experiments.propertyto 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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
411c64eba977f47c17016151239ebbce7b749624a7cd2e898d27ba1106790d27
|
|
| MD5 |
a7e709d7a8bdf3bc44ada604256cc757
|
|
| BLAKE2b-256 |
614336f9e3418eae98e02eccd460b8e713b4dcb5aff4541e6061747e06f688d1
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07ba2d640db4c7b25925114f946e9d971846b12c632db320c142c41ba119f3f7
|
|
| MD5 |
4318cad8cc7065f79497834030c8122b
|
|
| BLAKE2b-256 |
1b3485c319038462569d78942bce4ad07361f47141ab89e7fc344957158cbe43
|