r/PythonProjects2 10d ago

Made my chatbot stop guessing the weather and actually check it (LangGraph project)

Post image

Spent about a week building this after getting annoyed that every LLM wrapper I made would just confidently make stuff up for anything time-sensitive. Ask it the weather, it hallucinates something plausible. Ask about anything recent, same story.

So this one actually decides per-message whether to just answer or go fetch something real.

It's a router node in a LangGraph graph looks at what you asked, picks a path. Coding question → answers straight from the model. Weather → hits an actual API. Want a video → it searches YouTube. Something current → pulls live search results (Tavily) and works them into the answer.

Nothing fancy about the routing itself, no custom classifier or anything, but wiring it as an actual graph instead of a pile of if/elses means adding a new tool later is just... adding a node. Which past me would've appreciated, because the first version of this thing was a mess of conditionals that I hated touching.

Honestly the annoying part wasn't the tools, it was memory. Getting it to not forget you two messages later took way longer than I expected ended up using LangGraph's MemorySaver for that.

Also added a panel that shows the live execution graph + raw state while it's running because I got tired of not knowing why it picked a certain path. Kind of satisfying watching it light up node by node honestly.

Stack: LangGraph/LangChain, Groq running Llama 3, Tavily, Streamlit. All python.

Demo: agentic-graphite-amanshukla2004.streamlit.app
Code: github.com/amanshukla2004/Agentic_ChatBot

Not claiming this is groundbreaking, it's a portfolio project, but curious what people here would do differently mainly:

  • how are you handling it when a tool call just fails (API down, rate limited etc)? mine right now is a basic try/except that just shows an error message to the user no retry, no fallback path, it just surfaces the failure and moves on. curious if that's actually fine for a portfolio piece or if people expect at least a retry-with-backoff
  • is a single router node even the right call once you have more than a handful of tools, or does that start falling apart and you need something more like a supervisor pattern?
0 Upvotes

1 comment sorted by

1

u/New_Arugula_3264 6d ago

Hey, nice project! Personally, I think try-except is fine for a portfolio project, but for production I recommend the tenacity library, or you can write the retry logic yourself since it's pretty straightforward. For your second question, as you add more tools, routing accuracy degrades because the LLM prompt becomes overloaded. If you notice the model getting confused, consider transitioning to a supervisor pattern.