condition_fn
works. We had this code:# If there are players found, search for them in the vector store # If there are teams found, search for them in the vector store p.add_link("get_players", "player_vector", condition_fn=lambda x: len(x) > 0) p.add_link("get_teams", "teams_vector", condition_fn=lambda x: len(x) > 0) # Generate a context object that contains the player and team data in a json format # This is so that the context can be passed to the text_to_sql component with player and team ids etc p.add_link("player_vector", "generate_prompt", dest_key="data") p.add_link("teams_vector", "generate_prompt", dest_key="data") p.add_link("input", "generate_prompt", dest_key="input")
player_vector
and teams_vector
are connecting to generate_prompt
and it was optional to either of them to extract data, and it was working fine. But now, if any of those two condition_fn
returns false
, the pipeline does not continue to generate_prompt
and stops there. Is that expected or was it a bug introduced in 0.10.29
?generate_prompt
can run if it doesn't have all its dependencies connected?def generate_prompt(input, teams = None, players = None): return """\ Query: {input} example rows: {teams} {players} """ FnComponent(fn=generate_prompt) # If there are players found, search for them in the vector store # If there are teams found, search for them in the vector store p.add_link("get_players", "player_vector", condition_fn=lambda x: len(x) > 0) p.add_link("get_teams", "teams_vector", condition_fn=lambda x: len(x) > 0) # Generate a context object that contains the player and team data in a json format # This is so that the context can be passed to the text_to_sql component with player and team ids etc p.add_link("player_vector", "generate_prompt", dest_key="players") p.add_link("teams_vector", "generate_prompt", dest_key="teams") p.add_link("input", "generate_prompt", dest_key="input") # Generate an SQL Query based on the context object p.add_link("generate_prompt", "text_to_sql") return p
0.10.29
, generate_prompt
is not even called if at least one of the condition_fn return false, even if the other one returns truedef get_players(query: str): return [1] def get_teams(query: str): return [2] def player_vector(query: str): return [3] def teams_vector(query: str): return [4] def generate_prompt(input, teams = None, players = None): return "\n".join([input, str(teams), str(players)]) pipeline = QueryPipeline( modules={ "input": InputComponent(), "get_players": FnComponent(get_players), "get_teams": FnComponent(get_teams), "player_vector": FnComponent(player_vector), "teams_vector": FnComponent(teams_vector), "generate_prompt": FnComponent(generate_prompt, opt_params=set(["teams", "players"])) }, verbose=True ) pipeline.add_link("input", "get_players") pipeline.add_link("get_players", "player_vector", condition_fn=lambda x: len(x) > 0) pipeline.add_link("input", "get_teams") pipeline.add_link("get_teams", "teams_vector", condition_fn=lambda x: len(x) >0) pipeline.add_link("input", "generate_prompt", dest_key="input") pipeline.add_link("teams_vector", "generate_prompt", dest_key="players") pipeline.add_link("player_vector", "generate_prompt", dest_key="teams") print(pipeline.run(input="hello!"))