Skip to main content

OpenInference instrumentation utilities

Project description

OpenInference Instrumentation

PyPI Version

Utility functions for OpenInference instrumentation.

Installation

pip install openinference-instrumentation

Customizing Spans

The openinference-instrumentation package offers utilities to track important application metadata such as sessions and metadata using Python context managers:

  • using_session: to specify a session ID to track and group a multi-turn conversation with a user
  • using_user: to specify a user ID to track different conversations with a given user
  • using_metadata: to add custom metadata, that can provide extra information that supports a wide range of operational needs
  • using_tag: to add tags, to help filter on specific keywords
  • using_prompt_template: to reflect the prompt template used, with its version and variables. This is useful for prompt template management
  • using_attributes: it helps handling multiple of the previous options at once in a concise manner

For example:

from openinference.instrumentation import using_attributes
tags = ["business_critical", "simple", ...]
metadata = {
    "country": "United States",
    "topic":"weather",
    ...
}
prompt_template = "Please describe the weather forecast for {city} on {date}"
prompt_template_variables = {"city": "Johannesburg", "date":"July 11"}
prompt_template_version = "v1.0"
with using_attributes(
    session_id="my-session-id",
    user_id="my-user-id",
    metadata=metadata,
    tags=tags,
    prompt_template=prompt_template,
    prompt_template_version=prompt_template_version,
    prompt_template_variables=prompt_template_variables,
):
    # Calls within this block will generate spans with the attributes:
    # "session.id" = "my-session-id"
    # "user.id" = "my-user-id"
    # "metadata" = "{\"key-1\": value_1, \"key-2\": value_2, ... }" # JSON serialized
    # "tag.tags" = "["tag_1","tag_2",...]"
    # "llm.prompt_template.template" = "Please describe the weather forecast for {city} on {date}"
    # "llm.prompt_template.variables" = "{\"city\": \"Johannesburg\", \"date\": \"July 11\"}" # JSON serialized
    # "llm.prompt_template.version " = "v1.0"
    ...

You can read more about this in our docs.

Tracing Configuration

This package contains the central TraceConfig class, which lets you specify a tracing configuration that lets you control settings like data privacy and payload sizes. For instance, you may want to keep sensitive information from being logged for security reasons, or you may want to limit the size of the base64 encoded images logged to reduced payload size.

In addition, you an also use environment variables, read more here. The following is an example of using the TraceConfig object:

from openinference.instrumentation import TraceConfig
config = TraceConfig(
    hide_inputs=hide_inputs,
    hide_outputs=hide_outputs,
    hide_input_messages=hide_input_messages,
    hide_output_messages=hide_output_messages,
    hide_input_images=hide_input_images,
    hide_input_text=hide_input_text,
    hide_output_text=hide_output_text,
    base64_image_max_length=base64_image_max_length,
)
tracer_provider=...
# This example uses the OpenAIInstrumentor, but it works with any of our auto instrumentors
OpenAIInstrumentor().instrument(tracer_provider=tracer_provider, config=config)

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

openinference_instrumentation-0.1.54.tar.gz (33.9 kB view details)

Uploaded Source

Built Distribution

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

openinference_instrumentation-0.1.54-py3-none-any.whl (41.2 kB view details)

Uploaded Python 3

File details

Details for the file openinference_instrumentation-0.1.54.tar.gz.

File metadata

File hashes

Hashes for openinference_instrumentation-0.1.54.tar.gz
Algorithm Hash digest
SHA256 9af9817bb38816ed32856fb4cd813c1a5d9f530ab589c3473b37e06cf406ab28
MD5 8a6f3c9fccdfd60a12898051b779002e
BLAKE2b-256 c1cc62c1175ee7edc2cbdf95b5b73e0b0f305e759d407bf1bc353ff30a763365

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for openinference_instrumentation-0.1.54-py3-none-any.whl
Algorithm Hash digest
SHA256 8bc991865c90c804ac9983ef93aa6081a7a2397dd113d3d38b5465cca17892bb
MD5 3ee69cb5895d1db7c8b27a9aff84b78f
BLAKE2b-256 38e3c7aa7bb4845e0cfdf477ff87f9a3ec0cd2aa55a34a9f31be84d724cabbb7

See more details on using hashes here.

Provenance

The following attestation bundles were made for openinference_instrumentation-0.1.54-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