Now there are two people on the internet who agree that using LangGraph exclusively whether for simple DAG (Directed Acyclic Graphs) or to add cycles and persistence is the way to go. Thank you very much for this most excellent walkthrough and code example.
Thank you for this. I think your conclusion is correct. LangGraph is the way to go, documentation notwithstanding. This has been the way to do things (framework based) since around ~2012, which is when I first worrked with this pattern with Apache Storm in 2012 (now owned by Twitter). It's extremely powerful, expressive and easy to modify.
It’s really cool to see the comparison. Langgraph is the winner. You can use lcel in langgraph, but not vice versa. There are a lot more options with langgraph
I use LangGraph almost exclusively and on a daily basis, it makes the code more readable. Debugging also works much better. But sometimes I use LCEL as a one-liner for simple things (prompt template | llm | output parser). This can also make the code more readable, because otherwise you have some kind of subgraph again instead of a one-liner. Conclusion: Your opinion is tried and tested 👍
Interesting, first I had the same thought of, only use Langgraph for complex scenarios, but since I've beign trying Langgraph I dont get why dont use it more, even for more simple scenarios. Im pretty sure that for DAG might be less stressing/less code with only LCEL but coming back later for the same code is a little bit more complex to read and understand what is happening, Langgraph on the other way, its easier to debug, check the graph and see how the flow is working. But thats only my opinion, right now I definely agree with your final conclusions
LangGraph seem very complicated but it's actually very modularized and aligns with the human brain's of logical thinking since human always thinks logically and tends to work step-by-step. Then, I can't agree more with you on the matter of debugging. Sometimes, I don't even understand my code even when it works after I have written a tons of codes on computer using LCEL😅 (U can imagine when it doesn't work and needs debugging😂)
Which would you recommend for creating complex, production-ready agents with more than 30 nodes, with cycling and branching capabilities: Haystack, LangGraph, or a custom-built framework? I haven't seen a comparison between Haystack and LangGraph for real product development. What is your opinion?
Anyone who've built complex systems will agree that the langgraph approach is, yes more complex, but also better structured. That's a golden rule in software, if you want things to be standardized, easier to extend, easier to debug, and harder to break, you will need to write a bit more code. Of course simplicity wins always, but simplicity != less code, it means easily readable and understandable code.
the langchain docs go only for now to langchain and langsmith, I imagine LangGraph documentation is going to mature tremendously over time. the langchain videos bounce over to langsmith to trace stuff can you incorporate that so we can see 'under-the-hood'?
Can you make a in-depth playlist for langchain for 2024 a lot of things have changed , it would be amazing ! And you can make it with both lcel and langgraph
Now there are two people on the internet who agree that using LangGraph exclusively whether for simple DAG (Directed Acyclic Graphs) or to add cycles and persistence is the way to go. Thank you very much for this most excellent walkthrough and code example.
You and me? ;-)
THREE people now :)
Make it four 😄
@@bsarel And five!
Thank you for this. I think your conclusion is correct. LangGraph is the way to go, documentation notwithstanding. This has been the way to do things (framework based) since around ~2012, which is when I first worrked with this pattern with Apache Storm in 2012 (now owned by Twitter). It's extremely powerful, expressive and easy to modify.
@@nyceyes thanks for that comment:)
It’s really cool to see the comparison. Langgraph is the winner. You can use lcel in langgraph, but not vice versa. There are a lot more options with langgraph
I use LangGraph almost exclusively and on a daily basis, it makes the code more readable. Debugging also works much better. But sometimes I use LCEL as a one-liner for simple things (prompt template | llm | output parser). This can also make the code more readable, because otherwise you have some kind of subgraph again instead of a one-liner.
Conclusion: Your opinion is tried and tested 👍
Interesting, first I had the same thought of, only use Langgraph for complex scenarios, but since I've beign trying Langgraph I dont get why dont use it more, even for more simple scenarios.
Im pretty sure that for DAG might be less stressing/less code with only LCEL but coming back later for the same code is a little bit more complex to read and understand what is happening, Langgraph on the other way, its easier to debug, check the graph and see how the flow is working. But thats only my opinion, right now I definely agree with your final conclusions
Introducted that idea to my colleagues today, but they did not appreciate my initiave too much :(
LangGraph seem very complicated but it's actually very modularized and aligns with the human brain's of logical thinking since human always thinks logically and tends to work step-by-step. Then, I can't agree more with you on the matter of debugging. Sometimes, I don't even understand my code even when it works after I have written a tons of codes on computer using LCEL😅 (U can imagine when it doesn't work and needs debugging😂)
After understanding the three most important concepts its actually quite easy :). I struggle less than just using lcel
I agree with you, thanks for showing us the light :D
Which would you recommend for creating complex, production-ready agents with more than 30 nodes, with cycling and branching capabilities: Haystack, LangGraph, or a custom-built framework? I haven't seen a comparison between Haystack and LangGraph for real product development. What is your opinion?
I am not that familiar with Haystack I have to admit and since I am pretty familar with LangChain my opinion would be pretty biased
I've suspected as much; not that I'm super experienced in either as yet.
Anyone who've built complex systems will agree that the langgraph approach is, yes more complex, but also better structured.
That's a golden rule in software, if you want things to be standardized, easier to extend, easier to debug, and harder to break, you will need to write a bit more code.
Of course simplicity wins always, but simplicity != less code, it means easily readable and understandable code.
I might be wrong here but we cant send the response as a stream with langgraph right?
yes, it depends on the model. You can stream with Langgraph and openai
I had success using Langgraph with openai, check his video about streaming with fastapi, it helped me a lot.
BTW I had to use astream_events
the langchain docs go only for now to langchain and langsmith, I imagine LangGraph documentation is going to mature tremendously over time. the langchain videos bounce over to langsmith to trace stuff can you incorporate that so we can see 'under-the-hood'?
Yes, but often its the way the data looks that leads to an error and with that langsmith is not too great tbh
how would you store a chat history here? So e.g. saving the last 2 qa pairs
just create a new attribute for that: history: list[BaseMessage]. You can just append to that and do whatever you want with it
Can you make a in-depth playlist for langchain for 2024 a lot of things have changed , it would be amazing ! And you can make it with both lcel and langgraph
My in depth stuff is actually Happening on udemy. :). Thats Kind of my Business Model if you want to say so ;)
@@codingcrashcourses8533 does it have the latest update on lcel ?
@@codingcrashcourses8533 is it updated for
Lcel
I hate chains, i want to know my data, see the my data going from one place to another.
I want to print my steps, but lecl is troublesome
So you like LangGraph for that reason? In an LCEL pattern I showed patterns for custom Runnables, which you might find helpful :)
LangGraph is very flexible, but their documentation is really bad.