Skip to main content

CustomGPT Metrics SDK

CustomGPT Metrics is a Python SDK designed to analyze and evaluate chatbot interactions using various metrics. This SDK seamlessly integrates with the CustomGPT platform, offering a straightforward way to assess chatbot performance.

Installation

To install the CustomGPT Metrics SDK, use the following pip command:

pip install customgpt_metrics

Usage

  1. First basic way to use the metrics sdk is to pass a dict and the sdk will out the metric using analyze_log method.
from customgpt_metrics import CustomGPTMetrics

# Initialize the CustomGPTMetrics object
metrics = CustomGPTMetrics(api_key="your_api_key_here")

# Define a sample chat interaction
input_chat = {
    'user_query': 'Can I upload my PDF files to build the ChatGPT chatbot?',
    'openai_query': """Using only the following context, answer the questions.
    If context has no information about the question say sorry you can't answer as you don't have enough knowledge about that subject.
    You are a custom chatbot assistant called CustomGPT that answers questions based on the given context.
    Be as helpful as possible.
    ...
    --END OF CONTEXT--""",
    'openai_response': 'Yes, you can upload your PDF files to build the ChatGPT chatbot. The platform supports uploading documents in 1400+ formats, including PDFs, Microsoft Office docs, Google docs, and audio files. You can simply go to your CustomGPT dashboard and upload the documents to build your custom chatbots in minutes.'
}

# Analyze the chat interaction
output = metrics.analyze_log(input_chat)

# Access individual metric values
print(f"Context Check: {output.context_check}")
print(f"Emotion Check: {output.emotion_check}")
print(f"Intent Check: {output.intent_check}")
print(f"Language Check: {output.language_check}")
  1. The other way to use inject logs to the sdk is by using MySQL Database url passed to analyze_logs and allows streaming to get output for each metric.
from customgpt_metrics import CustomGPTMetrics

metrics = CustomGPTMetrics(api_key="your_api_key_here")
metric_outputs = metrics.stream_analyze_logs("mysql://root:password@localhost/customgpt", limit=10, metrics=['emotion', 'context', 'language', 'intent'])
for output in metric_outputs:
    print(output)
  1. The other way to use inject logs to the sdk is by using MySQL Database url passed to analyze_logs and allows to get output as list.
from customgpt_metrics import CustomGPTMetrics

metrics = CustomGPTMetrics(api_key="your_api_key_here")
metric_outputs = metrics.analyze_logs("mysql://root:password@localhost/customgpt", limit=10, metrics=['emotion', 'context', 'language', 'intent'])

for output in metric_outputs:
    print(output)

Easy Metric Addition Capability

To add more metrics to the output all you need to do is add another python file to metrics directory. It should be subclass of BaseMetric

class BaseMetric:
    key = None
    
    def __init__(self, api_key, base_url, model_provider='openai'):
        pass
    def evaluate(self, log_entry):
        # Add logic to evaluate the metric based on the adapted log entry
        pass

Make sure to replace "your_api_key_here" with your actual OpenAI API key.

The SDK allows for easy analysis of various metrics and provides flexibility to customize metrics based on your requirements. The output is a parsed Metric object containing the evaluated metric values.

Explore the additional features and metrics provided by the CustomGPT Metrics SDK to tailor the analysis to your specific use case.

Metadata

Release files for customgpt-metrics 0.1.9

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

Source distribution (sdist)

Source distribution for customgpt-metrics 0.1.9
File Size Uploaded
customgpt_metrics-0.1.9.tar.gz 16.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for customgpt-metrics 0.1.9
File Interpreter ABI Platform
customgpt_metrics-0.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 31.4 kB

Release files / customgpt_metrics-0.1.9.tar.gz

Download URL customgpt_metrics-0.1.9.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9edd979d1c43f1222fdd6104dfa2c7170add859fb37edc753eece4da8b2f2e3a
BLAKE2b-256 checksum
How to use checksums
48d71d2dc9c5764f544a404361f1680e91a868ce3c6683d2f40721fbae03a6d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.8.10 Linux/5.15.0-89-generic

Release files / customgpt_metrics-0.1.9-py3-none-any.whl

Download URL customgpt_metrics-0.1.9-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e73e18736e7891e227b7616cf52eeb4d2115f9723537070928343f893d926c2f
BLAKE2b-256 checksum
How to use checksums
a5835841f09be0891d4fa5b43c74a9afa4f76bbc502f7514232b090d58f25bbe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.8.10 Linux/5.15.0-89-generic

Release history Release notifications | RSS feed

This release

0.1.9 This release

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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