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 or Arize AX.

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

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file openinference_instrumentation_vertexai-0.1.17.tar.gz.

File metadata

File hashes

Hashes for openinference_instrumentation_vertexai-0.1.17.tar.gz
Algorithm Hash digest
SHA256 03afd70541d48af8b1cb49ff4fea940e2911cab57bfb2440442e85108697ebd7
MD5 5bbc4c54f4567aff1a3b49f9d9ca2b41
BLAKE2b-256 184dce2209ffe7f605b73d4ebb1fc84e5b4a8a2f8d4d4e121e44767a49b12f84

See more details on using hashes here.

Provenance

The following attestation bundles were made for openinference_instrumentation_vertexai-0.1.17.tar.gz:

Publisher: publish.yaml on Arize-ai/openinference

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for openinference_instrumentation_vertexai-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 baf6f6ed35b3ae740f7fbec108424023da082ba377f5bcdd1d0dbc07b20a1aeb
MD5 52a6fdf0c15752d22e0673c4aeae7810
BLAKE2b-256 2f240a1897ea4ae8de91daa3ecfc940b7a30cab3e1d6e99ed740aa2c369bf192

See more details on using hashes here.

Provenance

The following attestation bundles were made for openinference_instrumentation_vertexai-0.1.17-py3-none-any.whl:

Publisher: publish.yaml on Arize-ai/openinference

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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