/langfuse-python

Langfuse Python SDK

Primary LanguagePythonMIT LicenseMIT

Langfuse Python SDK

MIT License CI test status PyPI Version GitHub Repo stars Discord YC W23

pip install langfuse

Full documentation: https://docs.langfuse.com/sdk/python

Langchain documentation: https://docs.langfuse.com/langchain

Development

Add Poetry plugins

poetry self add poetry-dotenv-plugin
poetry self add poetry-bumpversion

Install dependencies

poetry install

Add Pre-commit

poetry run pre-commit install

Tests

Setup

  • Add .env based on .env.example

Run

  • Run all
    poetry run pytest -s -v --log-cli-level=INFO
    
  • Run a specific test
    poetry run pytest -s -v --log-cli-level=INFO tests/test_sdk.py::test_flush
    
  • E2E tests involving OpenAI and Serp API are usually skipped, remove skip decorators in tests/test_langchain.py to run them.

Update openapi spec

  1. Generate Fern Python SDK in langfuse and copy the files generated in generated/python into the langfuse/api folder in this repo.
  2. Rebuild and deploy the package to PyPi.

Publish release

  1. poetry version patch
    • poetry version prepatch for pre-release versions
  2. poetry build
  3. poetry publish