Skip to main content

Respan instrumentation plugin for Dify

Project description

Respan Dify instrumentation

Trace the dify-client Python package with Respan.

This package patches Dify's Service API client methods and emits canonical Respan spans for chat, completion, workflow, file, feedback, application, and conversation requests. Streaming responses are traced when the returned stream is consumed.

Install

pip install respan-ai respan-instrumentation-dify dify-client

Usage

import os

from dify_client import ChatClient
from respan import Respan
from respan_instrumentation_dify import DifyInstrumentor

respan = Respan(
    api_key=os.environ["RESPAN_API_KEY"],
    instrumentations=[DifyInstrumentor()],
)

client = ChatClient(os.environ["DIFY_CHAT_API_KEY"])
response = client.create_chat_message(
    inputs={},
    query="Reply with one concise sentence about tracing.",
    user="respan-example-user",
    response_mode="blocking",
)
response.raise_for_status()
print(response.json()["answer"])

respan.flush()
respan.shutdown()

Use Respan.propagate_attributes(...) to attach customer, thread, trace group, metadata, or prompt context to Dify spans.

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_dify-0.1.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

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

respan_instrumentation_dify-0.1.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file respan_instrumentation_dify-0.1.0.tar.gz.

File metadata

File hashes

Hashes for respan_instrumentation_dify-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3ae7d12ef39e02d032323fa6bf56c357ef53316190a93d1d6bea1ebb6c23708b
MD5 823b19674aed81d3fb7951dbb40ce072
BLAKE2b-256 0b1e9da390843a248320facac94fdb92d195a49c349ad6b49262f59728e0f92a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for respan_instrumentation_dify-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e8a34042a71f193a78b50fc816ef5ad8cd4eff12f6fb559a9cb4fa8a98eaa02e
MD5 3f90586feffbe15edc8aa43c5ca22e69
BLAKE2b-256 7261f7d247bcc5038de0522f113df959e3d2dab0fead2d0fb734098bc25d16be

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