Python client for Autoblocks
Project description
📚 Documentation • 🖥️ Application • 🏠 Home
Installation
poetry add autoblocksai
pip install autoblocksai
Examples
See our Python examples.
Quickstart
import os
import uuid
import traceback
import time
import openai
from autoblocks.tracer import AutoblocksTracer
openai.api_key = os.environ["OPENAI_API_KEY"]
messages = [
{
"role": "system",
"content": "You are a helpful assistant. You answer questions about a software product named Acme.",
},
{
"role": "user",
"content": "How do I sign up?",
},
]
request_params = dict(
model="gpt-3.5-turbo",
messages=messages,
temperature=0.7,
top_p=1,
frequency_penalty=0,
presence_penalty=0,
n=1,
)
tracer = AutoblocksTracer(
os.environ["AUTOBLOCKS_INGESTION_KEY"],
# All events sent below will have this trace ID
trace_id=str(uuid.uuid4()),
# All events sent below will include this property
# alongside any other properties set in the send_event call
properties=dict(
provider="openai",
),
)
tracer.send_event(
"ai.request",
properties=request_params,
)
try:
start_time = time.time()
response = openai.ChatCompletion.create(**request_params)
tracer.send_event(
"ai.response",
properties=dict(
response=response,
latency_ms=(time.time() - start_time) * 1000,
),
)
except Exception as error:
tracer.send_event(
"ai.error",
properties=dict(
error_message=str(error),
stacktrace=traceback.format_exc(),
),
)
# Simulate user feedback
tracer.send_event(
"user.feedback",
properties=dict(
feedback="good",
),
)
Documentation
Issues / Questions
Please open an issue if you encounter any bugs, have any questions, or have any feature requests.
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
autoblocksai-0.0.33.tar.gz
(19.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file autoblocksai-0.0.33.tar.gz.
File metadata
- Download URL: autoblocksai-0.0.33.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.8 Linux/6.5.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e00bc69cf876d4ec9ba2b9a07b579002989a3ac61bbb5c76515fd2ca3c246446
|
|
| MD5 |
54acdfdda8af800c353c13b7213eb5d9
|
|
| BLAKE2b-256 |
5127db719a196d7ba1371513d62df8b429a915b6e34509946ca093ab4e60e33a
|
File details
Details for the file autoblocksai-0.0.33-py3-none-any.whl.
File metadata
- Download URL: autoblocksai-0.0.33-py3-none-any.whl
- Upload date:
- Size: 27.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.8 Linux/6.5.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26f0f7877d9cf6ee1071b73d6bd86001f199ce27c552b52058a71699aa5a2ef6
|
|
| MD5 |
ce3c400cb5513a2f46f5506d76a4a9ea
|
|
| BLAKE2b-256 |
0ede7d5842ad97dec89b13a9c874027f77b658584b9b3b4df6a1ed5c24bedcac
|