We are excited to announce the release of v2.0.0 for Python and JS/TS SDKs. Langfuse has come a long way this year since initially launching v1 of the SDKs and it was time to finally group some necessary breaking changes into one release. The release includes simpler interfaces in Python, better defaults for the Langchain integration, and a performance upgrade for the JS/TS SDK. Read on for more details.
We have listened to your feedback and understood that importing Pydantic objects from our SDK is unintuitive and error prone. Hence, we removed Pydantic interfaces from function signatures. Your inputs are still validated and show improved logs in case validation fails.
from langfuse.model import CreateTrace
The biggest performance bottleneck for our SDKs was networking. We addressed this issue by implementing a batch endpoint on the server and migrating the Python SDK a few weeks ago. With the latest release, we have now added batching capabilities to the JS/TS SDK and migrated it to the new endpoint. As a result, we can handle production loads more efficiently and have also eliminated a significant amount of technical debt from our code base.
SDK 2.0 offers greater flexibility to handle diverse usage types while also maintaining compatibility with the OpenAI-style usage object. This allows us to add more usage units over the next few weeks. Here's a glimpse of how the new usage object works:
}, # defaults to "TOKENS" unit
For every chain run, a new trace is created. Previously all runs that were traced with the same Callback Handler instance were grouped into the same trace. While this was intended to be able to trace complex applications, it is not a great default for most users.
We strongly encourage upgrading to v2 to get all performance benefits and future security upgrades.
We teamed up with grit.io (opens in a new tab) to automate the migration process. Find more details on how to migrate your code base with one command for Python and JS/TS. The grit binary executes entirely locally with AST-based transforms. Thanks Team grit!
npx @getgrit/launcher apply langfuse_node_v2
npx @getgrit/launcher apply langfuse_v2
If you use one of the Langfuse integrations, there’s nothing to do for you. You’ll benefit from the more robust core by just continuously upgrading to the latest version of Flowise/LiteLLM/Langflow.
There is one more thing coming before the end of the year. Stay tuned!