Null values when using Haystack integration
Hi everyone! I've been checking the documentation to setup Haystack / Langfuse using the existing integration. Main problem I am facing right now is that I'm receiving nulls as input/output/metadata.
Current setup: Ubuntu 22.04 running self-hosted Langfuse, launching the Haystack code from the very same machine locally.
Things that work:
- I have setup my project and got API keys on Langfuse side
- I have configured the HAYSTACK_CONTENT_TRACING_ENABLED to True
- I have added a tracer component to my pipeline in Haystack
- I have been able to send traces to the server (trace name description and steps are correctly recorded, but content is empty)
Additional code in thread
10 Replies
This is the code I'm using:
Code continues:
Outputs are printed to console properly and traces are recorded on the langfuse side... but empty
If anyone has faced this issue or could offer any guidance about how to solve it, I would appreciate it
yes i faced the similar similar issue, my output is not able to trace. try flushing, it works for me.
please also see https://langfuse.com/faq/all/missing-traces
I will try flushing then. Copying the reference information from the tracing:
If you want to send a batch immediately, you can call the flush method on the client. In case of network issues, flush will log an error and retry the batch, it will never throw an exception.
Decorator
from langfuse.decorators import langfuse_context
langfuse_context.flush()
low-level SDK
langfuse.flush()
If you exit the application, use shutdown method to make sure all requests are flushed and pending requests are awaited before the process exits. On success of this function, no more events will be sent to Langfuse API.
langfuse.shutdown()
I have modified my code to add flushing without any significant difference. As a reference to add manual flushing:
Just to clarify, I am still getting nulls in the output
Advances and checks so far:
- I have tried adding flushing to Langfuse to see if it made any difference. Still returns nulls.
- I have tried switching from LlamaCppChatGenerator to OpenAIChatGenerator, querrying local Ollama as an OpenAI compatible endpoint. Still returns nulls.
- I have tried switching from OpenAIChatGenerator calling Ollama to OpenAIChatGenerator calling GPT-4o Mini at OpenAI endpoint. Still returns nulls in the traces.
- I have tried switching from local Langfuse to Cloud Langfuse. I am still getting nulls in my traces.
So, at this point I am quite sure there is something wrong in my code 🙂
I have tried replicating the Basic example in the Haystack-Langfuse integration:
https://langfuse.com/docs/integrations/haystack/example-python
This is the output from my command:
Trace url: https://cloud.langfuse.com/trace/d9bbf71d-8461-47e4-8b59-ca5f868861a4
Response: Truman Capote was an American author known for his works such as "Breakfast at Tiffany's" and "In Cold Blood." He was born Truman Persons but was later adopted by his stepfather and took on the last name Capote. Capote was known for his unique writing style and his ability to blend fiction and non-fiction in his works. He was also a prominent figure in the literary world and social scene in the mid-20th century.
And surprisingly...
Nulls again
Stack: local environment, running sample code, using chatgpt-3.5 turbo at OpenAI servers, cloud langfuse servers. Null output.
Maybe there is something wrong in my environment then. Time to rebuild from scratch.
Cookbook: Haystack Integration - Langfuse
Open-source observability for Haystack, a popular library to build RAG applications.
Second computer using Windows OS instead of Linux. Installed environment from scratch using:
Torch 2.4.0 returns an error about version not found, but 2.3.1 works.
When launching the default script from Haystack example:
I get as response in the console:
https://cloud.langfuse.com/trace/6d3d165c-4245-4660-a3ca-12a4bfadd147
And as you may guess again... nulls in the output!
I am done for today. Tried two computers, different OSs, my own code, two cookbook examples, self-hosted langfuse, cloud langfuse and a total of zero traces containing info using the Haystack-Langfuse integration.
Not done yet! Things I've discovered:
- I was able to create traces when NOT using the Haystack integration. In particular, I managed to trace using OpenAI, Ollama, LiteLLM without problems using the OpenAI SDK compatiblity of Langfuse. So it looks like the problem lies in the integration.
Thanks for raising this @elsatch! Does the observations within the trace include inputs/outputs?
Also, thanks for trying so many variations of the setup here to verify that it is an issue with the integration
If I use the LiteLLM + OpenAI SDK, correct traces are generated. Fortunately, Vladimir from Deepset is going to review the integration, to see if something has broken unexpectedly.
awesome, Vladimir is great!