How to use langfuse in langchain-chatchat #3225
-
LANGFUSE_SECRET_KEY="my_langfuse_secret_key" By setting the variables above, langfuse can be used normally in langserve or langchain tasks, but not in langchain-chatchat. Given that langchain-chatchat can be integrated with langsmith, I tried to set the langfuse address in the following variable, but it still doesn't work. In the langchain task and langserve task, to enable the effect of langfuse, it is necessary to use CallbackHandler(). By reviewing the source code, it was found that AsyncIteratorCallbackHandler and ConversationCallbackHandler are used in langchain-chatchat. However, there is no switch in the source code that allows langchain-chatchat to create CallbackHandler(). callbacks:[<langchain.callbacks.streaming_aiter.AsyncIteratorCallbackHandler object at 0x7feca8215150>, <server.callback_handler.conversation_callback_handler.ConversationCallbackHandler object at 0x7feca8e70c10>] Can someone guide me on how to use langfuse in langchain-chatchat? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Based on the information you've provided, it seems like you've set the environment variables correctly. However, it's important to ensure that these variables are being correctly accessed within the Langchain-Chatchat application. In Python, environment variables can be accessed using the If you're sure that the environment variables are being set and accessed correctly, the issue might be with how Langchain-Chatchat is using these variables to connect to Langfuse. Without more information about the specific error you're encountering, it's difficult to provide a more precise solution. If you're seeing an error message, could you please provide the exact text of the message? This could help in diagnosing the issue. Additionally, could you provide more information about how you're running Langchain-Chatchat? For example, are you running it in a Docker container, or directly on your machine? This information could also be helpful in identifying the problem. As for the Finally, while I strive to provide accurate and helpful information, there may be a better answer that I wasn't able to find. If you're still having trouble after trying the suggestions above, please provide more details about your issue and I'll do my best to help you resolve it. Sources
|
Beta Was this translation helpful? Give feedback.
Thank you for your answer. The above three variables did take effect in the operating system. The problem has been solved by modifying the source code of langchain-chatchat.
Make sure that LANGFUSE_SECRET_KEY, LANGFUSE_PUBLIC_KEY, and LANGFUSE_HOST are correctly configured in the system environment, and then make the following modifications:
vim Langchain-Chatchat/server/chat/chat.py
after line 48: callbacks.append(conversation_callback)