๐ค 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
- OpenAI and every other LLM provider that implements the OpenAI API message formate
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.
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.
Contributing
See CONTRIBUTING.md
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
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ab03203e0b5a925b537872ccd397f17b89dc4438077cdebcfa2736fc73b13d3 |
|
MD5 | 1f5cca10e02a2583beed585b396bd485 |
|
BLAKE2b-256 | f17076f8348dd30de79493e83b090cff898e7ea46a8f8f67d2b404c4bc2d915c |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e98ec3b0278c329905de740b85eb2123292b170d97f78453d9bc604ffcca7da |
|
MD5 | e2e4e645eca025def657b1d818f01940 |
|
BLAKE2b-256 | b03fba9a6086bfab78364d6b7eaedc08e47eed32b953ab8e41ad56adf41737f4 |