OpenInference VertexAI Instrumentation
Project description
OpenInference Google VertexAI Instrumentation
Python auto-instrumentation library for VertexAI SDK and the Google Cloud AI Platform. Traces are fully OpenTelemetry compatible and can be sent to any OpenTelemetry collector for viewing, such as Arize Phoenix.
Installation
pip install -Uqqq openinference-instrumentation-vertexai
Quickstart
Install openinference-instrumentation-vertexai
and arize-phoenix
.
pip install -U \
openinference-instrumentation-vertexai \
arize-phoenix \
opentelemetry-sdk \
opentelemetry-exporter-otlp \
"opentelemetry-proto>=1.12.0"
Start the phoenix
server so that it is ready to receive traces.
The phoenix
server runs entirely on your machine and does not send data over the internet.
python -m phoenix.server.main serve
Instrumenting vertexai
is simple.
from openinference.instrumentation.vertexai import VertexAIInstrumentor
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
endpoint = "http://127.0.0.1:4317"
tracer_provider = TracerProvider()
tracer_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint)))
VertexAIInstrumentor().instrument(tracer_provider=tracer_provider)
Now, all calls by generative_models
are instrumented and can be viewed in the phoenix
UI.
import vertexai
from vertexai.generative_models import GenerativeModel
vertexai.init(location="us-central1")
model = GenerativeModel("gemini-1.5-flash")
print(model.generate_content("Why is sky blue?"))
More Info
More details about tracing with OpenInference and phoenix
can be found in the phoenix
documentation.
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 openinference_instrumentation_vertexai-0.1.2.tar.gz
.
File metadata
- Download URL: openinference_instrumentation_vertexai-0.1.2.tar.gz
- Upload date:
- Size: 20.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35c509dcb4f453549d07b07d44d324e1f19622fd06bc9638b445299c42b63db3 |
|
MD5 | 0bebbfcd6520982ca94435803d3579c3 |
|
BLAKE2b-256 | 14d346fbe23ea957a4921e3f0abc50e9dd90c746c2f2ca2ffd7dd8658730682d |
File details
Details for the file openinference_instrumentation_vertexai-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: openinference_instrumentation_vertexai-0.1.2-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31b55e3d39a821012040932d38ef110898e93091c0584e586a0b222366b29585 |
|
MD5 | 7d741ba8bae476c1cb0ed364de021434 |
|
BLAKE2b-256 | d601616bdc137d51d1a3a853e93915696f6e163f5604d5edcb3d9350df9ef21d |