Skip to main content

Tools for testing, debugging, and evaluating LLM features.

Project description

Baserun

Baserun is the collaborative workspace for AI teams. Our mission is to simplify the testing, debugging, and evaluation of LLM features to help you get your app production-ready.

Quick Start

Install baserun

pip install baserun

Get your API key from the Baserun dashboard and set it as an environment variable:

export BASERUN_API_KEY="your_api_key_here"

Use our pytest plugin and start immediately logging to Baserun. By default all OpenAI completion and chat requests will be logged to Baserun. Logs are aggregated by test.

# test_module.py

import openai

def test_paris_trip():
    response = openai.ChatCompletion.create(
        model="gpt-3.5-turbo",
        temperature=0.7,
        messages=[
            {
                "role": "user",
                "content": "What are three activities to do in Paris?"
            }
        ],
    )
    
    assert "Eiffel Tower" in response['choices'][0]['message']['content']

To run the test and log to baserun:

pytest --baserun test_module.py
...
========================Baserun========================
Test results available at: https://baserun.ai/runs/<id>
=======================================================

Custom logs

log

Logs a custom message to Baserun. If Baserun is not initialized, this function will have no effect.

Parameters

  • message (str): The custom log message to be recorded.
  • payload (Union[str, Dict]): The log's additional data, which can be either a string or a dictionary.
import baserun

def test_custom_log():
    ...
    baserun.log("CustomEvent", payload={"key": "value"})

Production monitoring with baserun.trace

trace

Aggregates a trace of all logs generated by a function call to Baserun. By default all OpenAI completion and chat requests will be logged as part of the trace. If Baserun is not initialized, baserun.trace will have no effect.

Parameters

  • function (Callable): The function to be traced.
  • metadata (Optional[Dict]): Additional metadata to record alongside the traced logs.

Initialization

Add your BASERUN_API_KEY as an environment variable and then initialize Baserun at the entry point of your application.

import baserun

if env == 'production':
    baserun.init()

Then either decorate the function that you would like to trace:

import baserun

@baserun.trace
def get_response():
    ...

or wrap the function and optionally pass any additional metadata:

import baserun

def get_response(message):
    ...

traced_get_response = baserun.trace(get_response, {"userId": 123})
traced_get_response(message)

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

baserun-0.4.1.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

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

baserun-0.4.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file baserun-0.4.1.tar.gz.

File metadata

  • Download URL: baserun-0.4.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for baserun-0.4.1.tar.gz
Algorithm Hash digest
SHA256 96db6ef010925867108fb88906d11feac040ab0a61293269adea4a777244cafb
MD5 63b04750e502a477616c909feff26e7b
BLAKE2b-256 86165eaae9fb0a75c889e4e22995f1be31ed8069a753acf419e803f98ef04305

See more details on using hashes here.

File details

Details for the file baserun-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: baserun-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for baserun-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8dab65771bf3c6cd7b435af0cbe878a9ce53f29615deba75e44a018eccd18eb7
MD5 f6f778c1e16a6dc232ba7279c633677d
BLAKE2b-256 2b742883123c07bf535381babbcfce9933370d56cb7c1481e816792973959891

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