Markdown Converter
Agent skill for markdown-converter
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Sign in to like and favorite skills
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is the Langfuse Python SDK, a client library for accessing the Langfuse observability platform. The SDK provides integration with OpenTelemetry (OTel) for tracing, automatic instrumentation for popular LLM frameworks (OpenAI, Langchain, etc.), and direct API access to Langfuse's features.
# Install Poetry plugins (one-time setup) poetry self add poetry-dotenv-plugin # Install all dependencies including optional extras poetry install --all-extras # Setup pre-commit hooks poetry run pre-commit install
# Run all tests with verbose output poetry run pytest -s -v --log-cli-level=INFO # Run a specific test poetry run pytest -s -v --log-cli-level=INFO tests/test_core_sdk.py::test_flush # Run tests in parallel (faster) poetry run pytest -s -v --log-cli-level=INFO -n auto
# Format code with Ruff poetry run ruff format . # Run linting (development config) poetry run ruff check . # Run type checking poetry run mypy . # Run pre-commit hooks manually poetry run pre-commit run --all-files
# Build the package locally (for testing) poetry build # Generate documentation poetry run pdoc -o docs/ --docformat google --logo "https://langfuse.com/langfuse_logo.svg" langfuse
Releases are automated via GitHub Actions. To release:
The workflow handles versioning, building, PyPI publishing (via OIDC), and GitHub release creation.
: Main SDK implementation built on OpenTelemetrylangfuse/_client/
client.py: Core Langfuse client with OTel integrationspan.py: LangfuseSpan, LangfuseGeneration, LangfuseEvent classesobserve.py: Decorator for automatic instrumentationdatasets.py: Dataset management functionality
: Auto-generated Fern API clientlangfuse/api/
: Background processinglangfuse/_task_manager/
Integration modules:
langfuse/openai.py: OpenAI instrumentationlangfuse/langchain/: Langchain integration via CallbackHandlerThe SDK is built on OpenTelemetry for observability, using:
LangfuseOtelSpanAttributes)The client follows an async-first design with automatic batching of events and background flushing to the Langfuse API.
Environment variables (defined in
_client/environment_variables.py):
LANGFUSE_PUBLIC_KEY / LANGFUSE_SECRET_KEY: API credentialsLANGFUSE_HOST: API endpoint (defaults to https://cloud.langfuse.com)LANGFUSE_DEBUG: Enable debug loggingLANGFUSE_TRACING_ENABLED: Enable/disable tracingLANGFUSE_SAMPLE_RATE: Sampling rate for traces.env file based on .env.template for integration tests@pytest.mark.skip decorators in test files to run external API testsrespx for HTTP mocking and pytest-httpserver for test serverspyproject.toml: Poetry configuration, dependencies, and tool settingsruff.toml: Local development linting config (stricter)ci.ruff.toml: CI linting config (more permissive)langfuse/version.py: Version string (updated by CI release workflow)The
langfuse/api/ directory is auto-generated from the Langfuse OpenAPI specification using Fern. To update:
generated/python to langfuse/api/poetry run ruff format . to format the generated code