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

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

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 openai import OpenAI

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)

response = client.chat.completions.create(
    model="Qwen/Qwen2.5-Coder-32B-Instruct",
    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. 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.2.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

observers-0.1.2-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: observers-0.1.2.tar.gz
  • Upload date:
  • Size: 8.5 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.2.tar.gz
Algorithm Hash digest
SHA256 d474e5a80182a612c053ccb58319a08a050f62c09a939a23ceb391e5aa7685e7
MD5 3b77518000f0907f9d8ef7709fb199f3
BLAKE2b-256 a32957d20c42aedbb55201db9ad41831a3fcd817f3dd10bd2b308d8edb439b8b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: observers-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.8 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e76bdc26074141eb3155faaedc7cb2b00af7789d0853489b88255b3ef06f26b7
MD5 3c12762d4c2e9c63a7d4b8c65411107b
BLAKE2b-256 2b421bb135cb97e5108523debde30a145d4bc7b5d3c5fc38b4a30cd749bbc777

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