Skip to main content

Respan instrumentation plugin for LangChain, LangGraph, and Langflow

Project description

respan-instrumentation-langchain

Python instrumentation for LangChain-compatible callback flows. It emits Respan/Traceloop spans through respan-tracing, so LangChain chains, chat models, tools, retrievers, LangGraph runs, and Langflow components that execute LangChain/LangGraph callbacks are exported into the normal Respan trace pipeline.

Configuration

1. Install

pip install respan-instrumentation-langchain

2. Set Environment Variables

Variable Required Description
RESPAN_API_KEY Yes Your Respan API key.
RESPAN_BASE_URL No Defaults to https://api.respan.ai.

Quickstart

3. Run Script

from respan import Respan
from respan_instrumentation_langchain import LangChainInstrumentor

respan = Respan(instrumentations=[LangChainInstrumentor()])

chain.invoke({"question": "hello"})
respan.flush()

For explicit per-run callbacks:

from respan_instrumentation_langchain import add_respan_callback

chain.invoke(
    {"question": "hello"},
    config=add_respan_callback({"tags": ["demo"]}),
)

The same config helper works with LangGraph:

graph.invoke(
    {"messages": [{"role": "user", "content": "hi"}]},
    config=add_respan_callback({"configurable": {"thread_id": "thread-1"}}),
)

Langflow custom components can use get_callback_handler() or add_respan_callback() when invoking LangChain or LangGraph objects.

4. View Dashboard

After running the script, traces appear on your Respan dashboard.

Further Reading

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_langchain-0.1.1.tar.gz (13.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 respan_instrumentation_langchain-0.1.1.tar.gz.

File metadata

File hashes

Hashes for respan_instrumentation_langchain-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8695aad50d225af1431e35a998f8fdb9d3d00474164238f1811867c09a39c6e2
MD5 91c79898a974d4ab2be6d526138a82fe
BLAKE2b-256 321c7a989f925cd5ccda32c4a7e4346871dceecf7910126db086191dc0bd8882

See more details on using hashes here.

File details

Details for the file respan_instrumentation_langchain-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for respan_instrumentation_langchain-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 81016717d290f955503d7270853a1376dc11b781fd53d98cae88a786d342a537
MD5 007b76919d57c4fad309cab2064ab723
BLAKE2b-256 25cab795d8c9431d28febdd2523a40915c385c66e4c6b17fad7f46edb6a72042

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