Documentation Example Error

On the “Workflows + agents” page here Workflows and agents - Docs by LangChain

There seems to be an issue the Prompt Chaining example

The “if…else” statement below uses the “else” block to indicate that there was no punchline detected in the joke

Meanwhile, the if block is what actually runs if the joke fails with no punchline and is then improved

The else block runs if the joke actually passed the first time:

if "improved_joke" in state:
    print("Improved joke:")
    print(state["improved_joke"])
    print("\n--- --- ---\n")

    print("Final joke:")
    print(state["final_joke"])
else:
    print("Joke failed quality gate - no punchline detected!")

Yes, I came across it today as well and created a PR.

1 Like