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 -Uqqq openinference-instrumentation-vertexai arize-phoenix

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openinference_instrumentation_vertexai-0.1.0.tar.gz (19.1 kB view details)

Uploaded Source

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.0.tar.gz.

File metadata

File hashes

Hashes for openinference_instrumentation_vertexai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ba337c0648477b526aaede7506678561a0b2e2461a91e4758648b153c394d079
MD5 c07d8c1420f66d37c2f5d4b82e570398
BLAKE2b-256 4e7dcb77aed709ca0be03b65e7f47c0ff24cc4493418acf12b40f6d1bd2b0c43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openinference_instrumentation_vertexai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eb185bbbb8a5504899f63f2d2e9e98d911876b5bea088baaa6df32728c91f6ca
MD5 44e19de2a9e429904ff3a494bb13be51
BLAKE2b-256 429a25f5dec4116b16cbcfd365087329eda0660b6628b130b0e8b5af45e8723b

See more details on using hashes here.

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