TL;DR: Using a well written blog about langGraph and a Claude-3 prompt, I have a guide and starting point to build my own system using LangChain.
LangGraph takes a minute to wrap your head around but is brilliant. Rotem Weiss wrote a brilliant blog that explains it with a simple example from his GPT-Newspaper.
I used that blog's content (yes the full content) in combination with Claude-3-opus and my own idea (A research tool) that I needed to build a LangGraph for, and got a great response!
Copy-Paste the text from the blog in Claude then copy-paste this:
Given the logic of how LangGraph works given that example.
Help me come up with a LangGraph setup (help me with the
logic of the nodes, the edges and the conditional edges
knowing that we can define as many as we want and we also
define the functions and every fully customizable)...
for a system that will Research a topic in XYZ. I have a
knowledge base that can be searched using a hybrid search
(vector and keyword), I have the internet to search, I have a
query deconstructor (to help break the user's research
question down into multiple queries), I have a research
planner that will help determine the tasks, I have a
summarizer, and then a final_responder .. add any other
functions or roles you can think of and give me the outline
of the graph.
Here is the response I got!
Here's a proposed LangGraph setup for a system that researches a topic in XYZ based on the components you mentioned:
Nodes (Functions):
-
query_deconstructor
: Breaks down the user's research question into multiple sub-queries. -
research_planner
: Determines the tasks and steps needed to answer the sub-queries. -
knowledge_base_searcher
: Searches the internal knowledge base using hybridSearch (vector and keyword). -
internet_searcher
: Searches the internet for relevant information. -
information_filter
: Filters and selects the most relevant information from the search results. -
information_synthesizer
: Combines and synthesizes the filtered information into coherent sections. -
section_critic
: Critiques and provides feedback on the synthesized sections. -
section_reviser
: Revises the sections based on the feedback from the critic. -
summarizer
: Summarizes the revised sections into a concise overview. -
final_responder
: Generates the final response to the user's research question.
Edges:
-
query_deconstructor
->research_planner
-
research_planner
->knowledge_base_searcher
-
research_planner
->internet_searcher
-
knowledge_base_searcher
->information_filter
-
internet_searcher
->information_filter
-
information_filter
->information_synthesizer
-
information_synthesizer
->section_critic
-
section_critic
->section_reviser
(conditional edge) -
section_critic
->summarizer
(conditional edge) -
section_reviser
->section_critic
-
summarizer
->final_responder
Conditional Edges:
-
section_critic
->section_reviser
: If the critic finds issues or suggests improvements, the section is sent to the reviser for refinement. -
section_critic
->summarizer
: If the critic approves the section, it is sent to the summarizer.
Additional Functions/Roles:
-
data_visualizer
: Creates visualizations and infographics based on the researched information to enhance the final output. -
citation_manager
: Manages and formats citations for the information used in the research. -
glossary_generator
: Generates a glossary of key terms and concepts related to the researched topic. -
executive_summary_generator
: Produces an executive summary of the research findings.
Outline of the Graph:
- Start with the
query_deconstructor
to break down the user's research question. - Pass the deconstructed queries to the
research_planner
to determine the tasks and steps. - The
research_planner
initiates searches in theknowledge_base_searcher
andinternet_searcher
. - The search results are passed to the
information_filter
for selection of the most relevant information. - The filtered information is sent to the
information_synthesizer
to create coherent sections. - The synthesized sections are critiqued by the
section_critic
. - If the
section_critic
suggests improvements, the section is sent to thesection_reviser
for refinement and then back to thesection_critic
for re-evaluation. - If the
section_critic
approves the section, it is passed to thesummarizer
. - The
summarizer
condenses the revised sections into a concise overview. - The summarized content is sent to the
final_responder
to generate the final response to the user's research question. - Additional functions like
data_visualizer
,citation_manager
,glossary_generator
, andexecutive_summary_generator
can be integrated at appropriate points in the graph to enhance the final output.
Honestly, that's not bad for the fact that LangGraph is new and Claude 3 has absolutely no knowledge of LangChain's LangGraph.
Top comments (0)