๐ค 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
- OpenAI and every other LLM provider that implements the OpenAI API message formate
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.
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.
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.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | d474e5a80182a612c053ccb58319a08a050f62c09a939a23ceb391e5aa7685e7 |
|
MD5 | 3b77518000f0907f9d8ef7709fb199f3 |
|
BLAKE2b-256 | a32957d20c42aedbb55201db9ad41831a3fcd817f3dd10bd2b308d8edb439b8b |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | e76bdc26074141eb3155faaedc7cb2b00af7789d0853489b88255b3ef06f26b7 |
|
MD5 | 3c12762d4c2e9c63a7d4b8c65411107b |
|
BLAKE2b-256 | 2b421bb135cb97e5108523debde30a145d4bc7b5d3c5fc38b4a30cd749bbc777 |