Skip to main content

OpenInference OpenLIT Instrumentation

Project description

OpenInference OpenLit Instrumentation

Python auto-instrumentation library for OpenLIT. This library allows you to convert OpenLIT traces to OpenInference, which is OpenTelemetry compatible, and view those traces in Arize Phoenix.

Installation

pip install openinference-instrumentation-openlit

Quickstart

This quickstart shows you how to view your OpenLIT traces in Phoenix.

Install required packages.

pip install arize-phoenix opentelemetry-sdk opentelemetry-exporter-otlp openlit semantic-kernel

Start Phoenix in the background as a collector. By default, it listens on http://localhost:6006. You can visit the app via a browser at the same address.

phoenix serve

Here's a simple example that demonstrates how to convert OpenLIT traces into OpenInference and view those traces in Phoenix:

import os
import grpc
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from phoenix.otel import register
from openinference.instrumentation.openlit import OpenInferenceSpanProcessor
from semantic_kernel import Kernel
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion
import openlit

# Set your OpenAI API key
os.environ["OPENAI_API_KEY"] = "YOUR_OPENAI_API_KEY"

# Set up the tracer provider
tracer_provider = register(
    project_name="default" #Phoenix project name
)

tracer_provider.add_span_processor(OpenInferenceSpanProcessor())
    
tracer_provider.add_span_processor(
    BatchSpanProcessor(
        OTLPSpanExporter(
            endpoint="http://localhost:4317", #if using phoenix cloud, change to phoenix cloud endpoint (phoenix cloud space -> settings -> endpoint/hostname)
            headers={},
            compression=grpc.Compression.Gzip,  # use enum instead of string
        )
    )
)

# Initialize OpenLit tracer
tracer = tracer_provider.get_tracer(__name__)
openlit.init(tracer=tracer)

# Set up Semantic Kernel with OpenLIT
kernel = Kernel()
kernel.add_service(
    OpenAIChatCompletion(
        service_id="default",
        ai_model_id="gpt-4o-mini",
    ),
)

# Define and invoke your model
result = await kernel.invoke_prompt(
    prompt="What is the national food of Yemen?",
    arguments={},
)

# Now view your converted OpenLIT traces in Phoenix!

This example:

  1. Uses OpenLIT Instrumentor to instrument the application.
  2. Defines a simple Semantic Kernel model and runs a query
  3. Queries are exported to Phoenix using a span processor.

The traces will be visible in the Phoenix UI at http://localhost:6006.

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

openinference_instrumentation_openlit-0.1.7.tar.gz (12.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_openlit-0.1.7.tar.gz.

File metadata

File hashes

Hashes for openinference_instrumentation_openlit-0.1.7.tar.gz
Algorithm Hash digest
SHA256 92bc97e9d3b3bb5de2c3f5576836ccb8145a67fe1253451a6394181bda03cf9e
MD5 8ab1f46bffedc95c8c318b2028e2060c
BLAKE2b-256 7d9c0fa6311090d0cc83495a5f4ee8b4d66dea55d5ce73a3c4317ff6ee251eef

See more details on using hashes here.

Provenance

The following attestation bundles were made for openinference_instrumentation_openlit-0.1.7.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_openlit-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for openinference_instrumentation_openlit-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b268f522207a9300faf98920b49da477568d13ad094c446e05a681a06d44908a
MD5 0bcd26ed77c14379f260e9dbb22053b4
BLAKE2b-256 b712062b44ac1fb2c4b8a672f4abdf0c106bf999ce1656e09be2da4d08a35340

See more details on using hashes here.

Provenance

The following attestation bundles were made for openinference_instrumentation_openlit-0.1.7-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