-
|
Hello, I am completely new to Haystack, and I am trying to learn it by example. However, when I run the code it returns an error: I don't know what is wrong with this example and I am looking for some help/direction. Environment: Microsoft Windows 11 Home |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
|
The error says that
So, you need to change the prompt format in the template to country = "France"
question = f"What is the official language of {country}?"
template = """
...
Question: {{ question }}
"""and pass a query string (contained in the result = pipe.run({
"retriever": {"query": question}, # added
"prompt_builder": {"question": question} # changed
})Both stages require
If you want to iterate through each country defined in a list countries = ["France", "Germany", "Spain"]
...
for country in countries: # iterate through every country in list
question = f"What is the official language of {country}?"
result = pipe.run({
"retriever": {"query": question},
"prompt_builder": {"question": question}
})I cannot test it, but this would be the logic I would go with. I hope this helps. |
Beta Was this translation helpful? Give feedback.
-
|
@d-kleine thank you for explaining. I have a follow up question. Let's say that you have a pipeline with 2 components A and B connected in a loop A->B->A. Suppose that initially you provide a query to A which generates a single input for B which in turns produces 5 different texts. Is it possible to feed A with each independent piece of text (which would then generate 5 new loops)? Also, what would be the way to define the exit branch in the graph? Note: Please note that this example above is a copy&paste from the official doc here which according to the explanation above requires a correction. |
Beta Was this translation helpful? Give feedback.
The error says that
retriever(which is InMemoryBM25Retriever in your case) does not provide any input forquery. But this is mandatory for running your retriever, see here in the table:So, you need to change the prompt format in the template to
and pass a query string (contained in the
questionvariable for the value) to the"query"key for theretrieverin yourpipe.run()workflow, for example: