Skip to main content

๐Ÿค— Observers: A Lightweight Library for AI Observability

Project description

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

A Lightweight Library for AI Observability

Observers Logo

Installation

First things first! You can install the SDK with pip as follows:

pip install observers

Or if you want to use other LLM providers through AISuite or Litellm, you can install the SDK with pip as follows:

pip install observers[aisuite] # or observers[litellm]

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).

To get started you can run the code below. It sends requests to a HF serverless endpoint and log the interactions into a Hub dataset, using the default store DatasetsStore. The dataset will be pushed to your personal workspace (http://hf.co/{your_username}). To learn how to configure stores, go to the next section.

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

store = DuckDBStore()

openai_client = OpenAI()
client = wrap_openai(openai_client, store=store)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Tell me a joke."}],
)

Observers

Supported Observers

Change OpenAI compliant LLM provider

The wrap_openai function allows you to wrap any OpenAI compliant LLM provider. Take a look at the example doing this for Ollama for more details.

Stores

Supported Stores

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

Viewing / Querying

Hugging Face Datasets Store

To view and query Hugging Face Datasets, you can use the Hugging Face Datasets Viewer. You can find example datasets on the Hugging Face Hub. From within here, you can query the dataset using SQL or using your own UI. Take a look at the example for more details.

Hugging Face Datasets Viewer

DuckDB Store

The default store is DuckDB and can be viewed and queried using the DuckDB CLI. Take a look at the example for more details.

> 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. Take a look at the example for more details.

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.3.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

observers-0.1.3-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: observers-0.1.3.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.21.0 CPython/3.12.7 Darwin/24.1.0

File hashes

Hashes for observers-0.1.3.tar.gz
Algorithm Hash digest
SHA256 94775905f5890abf252e257b3ef7c8ab5663c32b782bdd323914110067d8148e
MD5 7fb6b1b5138026738061d660843460cb
BLAKE2b-256 82feaaff678ec54bb1b0ee2959ff00f4c1a4671765b8bb70d28550b4f8feee4f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: observers-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.21.0 CPython/3.12.7 Darwin/24.1.0

File hashes

Hashes for observers-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4602f73c0a61fe052e50a6fd1b0a46705744ca78543446a08228b4f3038e1278
MD5 cf6917d21b217eaeb4acf6369c270bed
BLAKE2b-256 97f3b0b3d496062f9df180d2d2c1585db979b55cad0b4d4a6c6dfb2db763131d

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