OpenTelemetry openai instrumentation
Project description
opentelemetry-instrument-openai
It's OpenTelemetry instrumentation (python) for OpenAI's library.
Project site: https://github.com/cartermp/opentelemetry-instrument-openai-py
Supported APIs:
- Chat
- Embeddings
- Moderation
- Image (generation, edit, variation)
- Audio (transcribe, translate)
- Completion (GPT-3)
- Edit (GPT-3)
How to use it
Simple! First, install this package.
Usage
With autoinstrumentation agent:
poetry add opentelemetry-instrument-openai
poetry run opentelemetry-bootstrap -a install
poetry run opentelemetry-instrument python your_app.py
If you prefer to do it in code, you can do that too:
import openai
from dotenv import load_dotenv
from opentelemetry.instrument.openai import OpenAIInstrumentor
OpenAIInstrumentor().instrument()
load_dotenv()
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[{"role":"user", "content":"Tell me a joke about opentelemetry"}],
)
You can then run your app normally with your own opentelemetry initialization.
How to develop
Get poetry.
Now install and run tests:
poetry install
poetry run pytest
Now you can develop and run tests as you go!
How to run the example
Click the example folder and read the README.
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
Built Distribution
File details
Details for the file opentelemetry_instrument_openai-0.7.1.tar.gz
.
File metadata
- Download URL: opentelemetry_instrument_openai-0.7.1.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.9.18 Linux/6.5.0-1016-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f751eef76758e733972c42c2df036cbe30c0fa3e757dcc81c99a3335e70da72f |
|
MD5 | ff0ca160ffc76047337ee43627634800 |
|
BLAKE2b-256 | 8b913410ae1327532beac1ab8670096c1f20e15fc405ab36be42705625ac9efc |
File details
Details for the file opentelemetry_instrument_openai-0.7.1-py3-none-any.whl
.
File metadata
- Download URL: opentelemetry_instrument_openai-0.7.1-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.9.18 Linux/6.5.0-1016-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfe5dbe8ca7140bd4db06670a528eb2576470dd34a7e398b9f505aad55bb56c4 |
|
MD5 | 5bc484f62d4549138002d2bf552d60ad |
|
BLAKE2b-256 | d0531d254187ca210af444e3b3317c9bc738fd90254c2df99e131773f5889053 |