FlowiseAI / Flowise

Drag & drop UI to build your customized LLM flow
https://flowiseai.com
Apache License 2.0
31.02k stars 16.16k forks source link

[FEATURE] Set custom langfuse trace ID #2808

Open danieldabate opened 3 months ago

danieldabate commented 3 months ago

Describe the feature you'd like When using langfuse the trace ID is randomly generated, this the default behaviour of the langfuse SDK. After the trace is created there is no way of matching a langfuse trace with a Flowise message.

One limitation of this is that it's impossible to use langfuse score API to store the feedback from the user, because we don't have the trace id of each message.

Different solution approaches could be:

I checked the code and Flowise is using both langfuse and langfuse-langchain SDKs for different use cases. I'm not entirely sure which use case use which SDK. I'm testing a basic chain flow and it uses the langfuse-langchain SDK.

There is also an ongoing dicussion on langfuse side: https://github.com/orgs/langfuse/discussions/953

HenryHengZJ commented 3 months ago

I think its somewhat similar in this PR (https://github.com/FlowiseAI/Flowise/pull/2195/files) where we used a correlationId to track the parent message

danieldabate commented 3 months ago

I'm not sure how that correlationId is stored in Langchain, but we need the traceId anyways to do things through Langfuse's API.

What we are doing in the meantime is using the metadata field of the traces to store a custom responseId and then before setting a score for that trace, we go over all the traces in the session and get the one matching the responseId to get the traceId. This works but it's very hacky.

automacao-topnet commented 3 weeks ago

How do you set this metadata to each trace? @danieldabate