openinference-instrumentation-smolagents (original) (raw)
Project description
Python auto-instrumentation library for LLM agents implemented with smolagents
Crews are fully OpenTelemetry-compatible and can be sent to an OpenTelemetry collector for monitoring, such as arize-phoenix.
Installation
pip install openinference-instrumentation-smolagents
Quickstart
This quickstart shows you how to instrument your LLM agent application.
You've already installed openinference-instrumentation-smolagents. Next is to install packages for smolagents, Phoenix and opentelemetry-instrument
, which exports traces to it.
pip install smolagents arize-phoenix opentelemetry-sdk opentelemetry-exporter-otlp-proto-grpc opentelemetry-distro
Start Phoenix in the background as a collector, which listens on http://localhost:6006
and default gRPC port 4317. Note that Phoenix does not send data over the internet. It only operates locally on your machine.
python -m phoenix.server.main serve
Create an example like this:
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=HfApiModel())
agent.run("How many seconds would it take for a leopard at full speed to run through Pont des Arts?")
Then, run it like this:
opentelemetry-instrument python example.py
Finally, browse for your trace in Phoenix at http://localhost:6006
!
Manual instrumentation
opentelemetry-instrument
is the Zero-code instrumentation approach for Python. It avoids explicitly importing and configuring OpenTelemetry code in your main source. Alternatively, you can copy-paste the following into your main source and run it without opentelemetry-instrument
.
from opentelemetry.sdk.trace import TracerProvider
from openinference.instrumentation.smolagents import SmolagentsInstrumentor from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter from opentelemetry.sdk.trace.export import SimpleSpanProcessor
otlp_exporter = OTLPSpanExporter(endpoint="http://localhost:4317", insecure=True) trace_provider = TracerProvider() trace_provider.add_span_processor(SimpleSpanProcessor(otlp_exporter))
SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)
More Info
- More info on OpenInference and Phoenix
- How to customize spans to track sessions, metadata, etc.
- How to account for private information and span payload customization
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 openinference_instrumentation_smolagents-0.1.13.tar.gz
.
File metadata
- Download URL: openinference_instrumentation_smolagents-0.1.13.tar.gz
- Upload date: Jun 9, 2025
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
Hashes for openinference_instrumentation_smolagents-0.1.13.tar.gz | Algorithm | Hash digest | | | ----------- | ---------------------------------------------------------------- | | | SHA256 | f63ed427a3e5edd23d7b96b8e64dce0b5ff6f193aa0e26d6efb7a3e2b44507cb | | | MD5 | 18e1fd67df079bd6020cee69bf619ade | | | BLAKE2b-256 | c1843ccbdcc948ee16b578274739af66b78fca060e0d95f651415e1a3e472c19 | |
See more details on using hashes here.
File details
Details for the file openinference_instrumentation_smolagents-0.1.13-py3-none-any.whl
.
File metadata
- Download URL: openinference_instrumentation_smolagents-0.1.13-py3-none-any.whl
- Upload date: Jun 9, 2025
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
Hashes for openinference_instrumentation_smolagents-0.1.13-py3-none-any.whl | Algorithm | Hash digest | | | ----------- | ---------------------------------------------------------------- | | | SHA256 | fa96994dcabcc8a9f0c5dbe00443d21c1eb08d43f21ecce645ff03d52709d9ae | | | MD5 | 891d0d6aa6a325c5c84b7e2439295632 | | | BLAKE2b-256 | 6e58de671acd01d91cd8668a04e33cc6cec808438d8c1f25ccfeea94aa8a51c6 | |