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.0.tar.gz (11.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_langchain-0.1.0.tar.gz.

File metadata

File hashes

Hashes for respan_instrumentation_langchain-0.1.0.tar.gz
Algorithm Hash digest
SHA256 451a989575bbc1a11c14196eacfbf6c3cbc1f3419fbb2377225ea712d60e8a25
MD5 575dc8f91fda324191a07386e0afd3f9
BLAKE2b-256 0483fba3ad6e858bb3e1431cd2710e69da3318ae03b16de6b949b9c7d11edd2f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for respan_instrumentation_langchain-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d35c70ea3ae0028fde3bc78261c76199857c9974c6fa2ab14bc286f19fb03199
MD5 4dc37bee190fb1445c96f873bd537ba6
BLAKE2b-256 f92b0a4b41a19980f2df775b10a3dbab69e41285517ddcdb82c81137c9b72921

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