Skip to main content

Atla is a platform for monitoring and improving AI agents.

Project description

Atla Insights

Atla is a platform for monitoring and improving AI agents.

Installation

pip install atla-insights

To install package-specific dependencies:

pip install "atla-insights[litellm]"

Usage

Configuration

Before using Atla Insights, you need to configure it with your authentication token:

from atla_insights import configure

configure(token="<MY_ATLA_INSIGHTS_TOKEN>")

Instrumentation

In order for spans/traces to become available in your Atla Insights dashboard, you will need to add some form of instrumentation.

As a starting point, you will want to instrument your GenAI library of choice.

We currently support the following:

OpenAI chat completions

You can instrument the entire OpenAI library via

from atla_insights import configure, instrument_openai
from openai import OpenAI

configure(...)

instrument_openai()

# Every subsequent OpenAI or AsyncOpenAI SDK chat completions call will be automatically instrumented.
client = OpenAI()
client.chat.completions.create(...)

Alternatively, you can also instrument an individual client.

from atla_insights import configure, instrument_openai
from openai import OpenAI

configure(...)

client_1 = OpenAI()
client_2 = OpenAI()

instrument_openai(client_1)

client_1.chat.completions.create(...)  # this call will be instrumented
client_2.chat.completions.create(...)  # this call will not

LiteLLM

You can instrument litellm (sync and async) completions via:

from atla_insights import configure, instrument_litellm
from litellm import completion

configure(...)

instrument_litellm()

# Every subsequent litellm completion or acompletion call will be automatically instrumented.
completion(...)

⚠️ Note that, by default, instrumented LLM calls will be treated independently from one another. In order to logically group LLM calls into a trace, you will need to group them as follows:

from atla_insights import configure, instrument, instrument_litellm
from litellm import completion

configure(...)
instrument_litellm()

@instrument("My agent doing its thing")
def run_my_agent() -> None:
    """The LiteLLM calls within this function will belong to the same trace and treated
    as subsequent steps in a single logical flow."""
    result_1 = completion(...)
    result_2 = completion(...)
    ...

Marking trace success / failure

The logical notion of success or failure plays a prominent role in the observability of (agentic) GenAI applications.

Therefore, the atla_insights package offers the functionality to mark a trace as a success or a failure like follows:

from atla_insights import (
    configure,
    instrument,
    instrument_openai,
    mark_failure,
    mark_success,
)
from openai import OpenAI

configure(...)
instrument_openai()

client = OpenAI()

@instrument("My agent doing its thing")
def run_my_agent() -> None:
    result = client.chat.completions.create(
        model=...,
        messages=[
            {
                "role": "user",
                "content": "What is 1 + 2? Reply with only the answer, nothing else.",
            }
        ]
    )
    response = result.choices[0].message.content

    # Note that you could have any arbitrary success condition, including LLMJ-based evaluations
    if response == "3":
        mark_success()
    else:
        mark_failure()

⚠️ Note that you should use this marking functionality within an instrumented function.

Compatibility with existing observability

As atla_insights provides its own instrumentation, we should note potential interactions with our instrumentation / observability providers.

atla_insights instrumentation is generally compatible with most popular observability platforms.

E.g. the following code snippet will make tracing available in both Atla and LangFuse.

from atla_insights import configure, instrument_openai
from langfuse.openai import OpenAI

configure(...)

instrument_openai()

client = OpenAI()
client.chat.completions.create(...)

OpenTelemetry compatibility

Next to the above, you also have the ability to export traces to any arbitrary additional opentelemetry provider by following this example:

from atla_insights import configure
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace.export import SimpleSpanProcessor

# This is the otel traces endpoint for my provider of choice.
my_otel_endpoint = "https://my-otel-provider/v1/traces"

my_span_exporter = OTLPSpanExporter(endpoint=my_otel_endpoint)
my_span_processor = SimpleSpanProcessor(my_span_exporter)

configure(
    token="<MY_ATLA_INSIGHTS_TOKEN>",
    # This will ensure traces get sent to my otel provider of choice
    additional_span_processors=[my_span_processor],
)

More examples

More specific examples can be found in the examples/ folder.

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

atla_insights-0.0.1a3.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

atla_insights-0.0.1a3-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file atla_insights-0.0.1a3.tar.gz.

File metadata

  • Download URL: atla_insights-0.0.1a3.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for atla_insights-0.0.1a3.tar.gz
Algorithm Hash digest
SHA256 e57181cffcb71a3f12919a8cf4389d15225de2672f5386569fd58faff05f213a
MD5 91348e61d08610c316bd9a6721e7d7a3
BLAKE2b-256 bf2a34cdc24bdd727c778269ee08ccdb3b96a8efa09d8420019c87af25f7e450

See more details on using hashes here.

Provenance

The following attestation bundles were made for atla_insights-0.0.1a3.tar.gz:

Publisher: package-publish.yaml on atla-ai/atla-insights

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

File details

Details for the file atla_insights-0.0.1a3-py3-none-any.whl.

File metadata

File hashes

Hashes for atla_insights-0.0.1a3-py3-none-any.whl
Algorithm Hash digest
SHA256 976b0e280e4b8c5a8e6e933fc952980fd5d8f3cb57049af2c19f70380ccb0976
MD5 42de0e3fe93cf47f183bd5c8644de8ba
BLAKE2b-256 80821caf367d6edb249350be0b7da441f19c9a56fed15a2cb665a3754cb9c866

See more details on using hashes here.

Provenance

The following attestation bundles were made for atla_insights-0.0.1a3-py3-none-any.whl:

Publisher: package-publish.yaml on atla-ai/atla-insights

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