Closed BrikerMan closed 2 months ago
thanks for sharing! If you create a new callbackhandler for every execution of summerize
this will currently create a new langfuse sdk instance for every invocation of the function which in turn creates a new background thread to batch events to the langfuse api. I'd recommend to migrate to the langfuse decorator + langfuse_context.get_langchain_handler as this will only create a single langfuse client instance -> way more scalable. This is a current limitation of the langchain intgeration which would ideally only create a single client instance. However, this would be a breaking change for some users who rely on this behavior.
docs on this here, happy to help with this change in case this is unclear: https://langfuse.com/docs/integrations/langchain/tracing#interoperability
Thanks, I updated my code according to your suggestion. I will test about 1-2 days and let you know the result.
Thanks, I updated my code according to your suggestion. I will test about 1-2 days and let you know the result.
Sounds great, closing the issue for now. please let me know in case this did not resolve it for you
It is fixed, thanks for the help.
awesome, thanks for confirming!
Describe the bug
Thanks for building this amazing tool. I had been loving it.
While I am using langchain to process lots of webpage in bulk, I run into hight CPU issue after task runs for few minutes, so far I find if the task is less than 100, it works fine. But when I have long context and 100+ task on each run, it reaches to 100% cpu even on my M2 Max Macbook.
PS: I have the same issue whether I am using ThreadPoolExecutor with sync invoke of langchain or using async for limited concurrency using ainvoke in langchain.
To reproduce
Here is my code to reproduce this issues. Please be aware need to change to data to something larget.
SDK and container versions
Current Version
langfuse 2.44.0 langchain 0.2.14 langchain-core 0.2.34 langchain-openai 0.1.22 langchain-text-splitters 0.2.2
Langfuse Server Docker. 2.71.0
But I had this issue for several past version, I tried to keep updating but so far not fixed the issue.
Additional information
Host info
Are you interested to contribute a fix for this bug?
Yes