Skip to main content

Respan instrumentation plugin for AutoGen AgentChat

Project description

respan-instrumentation-autogen

Respan instrumentation plugin for AutoGen AgentChat. Wraps OpenInference's AutoGen AgentChat instrumentor and translates spans into the Respan tracing shape automatically.

Configuration

1. Install

pip install respan-ai respan-instrumentation-autogen

2. Set Environment Variables

Variable Required Description
RESPAN_API_KEY Yes Your Respan API key. Authenticates gateway requests and trace export.
RESPAN_BASE_URL No Defaults to https://api.respan.ai/api.
RESPAN_MODEL No Defaults to gpt-4o-mini.

Quickstart

import asyncio
import os

from dotenv import load_dotenv

load_dotenv()

from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
from respan import Respan
from respan_instrumentation_autogen import AutoGenInstrumentor

respan_api_key = os.environ["RESPAN_API_KEY"]
respan_base_url = os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api")
respan_model = os.getenv("RESPAN_MODEL", "gpt-4o-mini")

respan = Respan(
    api_key=respan_api_key,
    base_url=respan_base_url,
    instrumentations=[AutoGenInstrumentor()],
)

model_client = OpenAIChatCompletionClient(
    model=respan_model,
    api_key=respan_api_key,
    base_url=respan_base_url,
)


async def main() -> None:
    agent = AssistantAgent(
        name="assistant",
        model_client=model_client,
        system_message="You are a helpful assistant.",
    )
    result = await agent.run(task="Write one sentence about recursive functions.")
    print(result.messages[-1].content)
    await model_client.close()
    respan.flush()


asyncio.run(main())

Further Reading

See the Respan example projects for runnable scripts.

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

respan_instrumentation_autogen-0.1.0.tar.gz (3.9 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 respan_instrumentation_autogen-0.1.0.tar.gz.

File metadata

File hashes

Hashes for respan_instrumentation_autogen-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f323da994d22e406eebcf8592eed0e532ae7ceaa4f74f288c50e81d975c23d10
MD5 04b8fe1225ceed7d836b2ebb53498d71
BLAKE2b-256 fe915e926af82826ca3efa8fad26120ddf2e879166c0feb497dea7b5dfb69665

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for respan_instrumentation_autogen-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dea548d9eabcb73fbae01240839886124acb36b5d52c84cdce0bef90118e7c3a
MD5 066c54e2193f184cff4b0cfd37019e13
BLAKE2b-256 dd5ca205f2b7c3d79a628e09cef37aee6e044a391be660d1684fbcf4801a089f

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