Skip to main content

๐Ÿค— Observers: A lightweight library for (generative) AI observability, enabling insights into model interactions and everything that comes with it.

Project description

๐Ÿค—๐Ÿ”ญ Observers ๐Ÿ”ญ๐Ÿค—

A lightweight library for (generative) AI observability.

Installation

pip install observers

Usage

We differentiate between observers and stores. Observers wrap generative AI APIs (like OpenAI or llama-index) and track their interactions. Stores are classes that sync these observations to different storage backends (like duckdb or Hugging Face datasets).

import os

from observers.observers.models.openai import wrap_openai
from observers.stores.duckdb import DuckDBStore
from openai import OpenAI

store = DuckDBStore()

api_key = os.environ["HF_TOKEN"]
openai_client = OpenAI(
    base_url="https://api-inference.huggingface.co/v1/", api_key=api_key
)

client = wrap_openai(openai_client, store=store)

response = client.chat.completions.create(
    model="Qwen/Qwen2.5-Coder-32B-Instruct",
    messages=[{"role": "user", "content": "Tell me a joke."}],
)

Observers

Supported Observers

Stores

Supported Stores

Store Annotate Local Free UI filters SQL filters
Hugging Face Datasets โŒ โŒ โœ… โœ… โœ…
DuckDB โŒ โœ… โœ… โŒ โœ…
Argilla โœ… โŒ โœ… โœ… โŒ

Viewing / Querying

Hugging Face Datasets

To view and query Hugging Face Datasets, you can use the Hugging Face Datasets Viewer. From within here, you can query the dataset using SQL or using your own UI.

Hugging Face Datasets Viewer

DuckDB Store

The default store is DuckDB and can be viewed and queried using the DuckDB CLI.

> duckdb store.db
> from openai_records limit 10;
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚          id          โ”‚        model         โ”‚      timestamp       โ”‚       messages       โ”‚ โ€ฆ โ”‚  error  โ”‚     raw_response     โ”‚ synced_at โ”‚
โ”‚       varchar        โ”‚       varchar        โ”‚      timestamp       โ”‚ struct("role" varcโ€ฆ  โ”‚   โ”‚ varchar โ”‚         json         โ”‚ timestamp โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 89cb15f1-d902-4586โ€ฆ  โ”‚ Qwen/Qwen2.5-Coderโ€ฆ  โ”‚ 2024-11-19 17:12:3โ€ฆ  โ”‚ [{'role': user, 'cโ€ฆ  โ”‚ โ€ฆ โ”‚         โ”‚ {"id": "", "choiceโ€ฆ  โ”‚           โ”‚
โ”‚ 415dd081-5000-4d1aโ€ฆ  โ”‚ Qwen/Qwen2.5-Coderโ€ฆ  โ”‚ 2024-11-19 17:28:5โ€ฆ  โ”‚ [{'role': user, 'cโ€ฆ  โ”‚ โ€ฆ โ”‚         โ”‚ {"id": "", "choiceโ€ฆ  โ”‚           โ”‚
โ”‚ chatcmpl-926         โ”‚ llama3.1             โ”‚ 2024-11-19 17:31:5โ€ฆ  โ”‚ [{'role': user, 'cโ€ฆ  โ”‚ โ€ฆ โ”‚         โ”‚ {"id": "chatcmpl-9โ€ฆ  โ”‚           โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 3 rows                                                                                                                16 columns (7 shown) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Argilla Store

The Argilla Store allows you to sync your observations to Argilla. To use it, you first need to create a free Argilla deployment on Hugging Face.

Argilla Store

Contributing

See CONTRIBUTING.md

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

observers-0.1.1.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

observers-0.1.1-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file observers-0.1.1.tar.gz.

File metadata

  • Download URL: observers-0.1.1.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.18.0 CPython/3.12.7 Darwin/24.0.0

File hashes

Hashes for observers-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9ab03203e0b5a925b537872ccd397f17b89dc4438077cdebcfa2736fc73b13d3
MD5 1f5cca10e02a2583beed585b396bd485
BLAKE2b-256 f17076f8348dd30de79493e83b090cff898e7ea46a8f8f67d2b404c4bc2d915c

See more details on using hashes here.

File details

Details for the file observers-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: observers-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.18.0 CPython/3.12.7 Darwin/24.0.0

File hashes

Hashes for observers-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4e98ec3b0278c329905de740b85eb2123292b170d97f78453d9bc604ffcca7da
MD5 e2e4e645eca025def657b1d818f01940
BLAKE2b-256 b03fba9a6086bfab78364d6b7eaedc08e47eed32b953ab8e41ad56adf41737f4

See more details on using hashes here.

Supported by

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