Skip to main content

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.

pypi

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

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 openinference_instrumentation_vertexai-0.1.4.tar.gz.

File metadata

File hashes

Hashes for openinference_instrumentation_vertexai-0.1.4.tar.gz
Algorithm Hash digest
SHA256 05df65e5e947ae3f18b8eaa50ef7871ea958443bf003aee45efdf7f6a477a40a
MD5 8cc0ac6e9c5a5687d75a0f637b0183de
BLAKE2b-256 2b9e89f35afb276722ec597b926dd3edba40500d4e3155132999fa170f0514f1

See more details on using hashes here.

File details

Details for the file openinference_instrumentation_vertexai-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for openinference_instrumentation_vertexai-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 975a765e7547e7cb54a9266e3f3766613a7957a861529ef825fb365ef2d61e4a
MD5 732a2c6aefd6c5a25120dcb0a0bfcea3
BLAKE2b-256 a5be074453b6c14a2f6fc9fe1447b405b1ab539ea4e957e05c0da72eac65e8a9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page