
AI
Elements
Master the foundational components: State, Nodes, Edges, Graphs, and Messages.
Elements
After understanding the concept of LangGraph and where it fits in the autonomy spectrum (from human-driven code to autonomous agents), we'll now explore the building blocks that make these complex state machines possible.
State
- The State is a shared data Structure that holds current information or context of an application.
- In simpler terms, it is application memory, keeping track of variables and data that nodes can access and modify as they execute.
Node
- Nodes are individual functions or operations that perform specific tasks within the graph.
- Each node receives input (often the current state), processes it, and produces an output or an updated state.
Graph ๐
- A graph in LangGraph is an overarching structure that maps out how different tasks (nodes) are connected and executed.
- It is the implementation of the Agent Loop model we discussed in the overview.
- It visually represents the workflow, showing the sequence and conditional paths between various operations.
Edge
- Edges are the connections between nodes that determine the flow of execution.
- They tell us which node should be executed next after the current one completes its task.
Conditional Edges
- Conditional Edges are specialized connections that decide the next node to execute based on specific conditions or logic applied to the current state.
Start ๐
- The State node is a virtual entry point in LangGraph, marking where the workflow begins.
- It doesn't perform any operations itself but serves as the designated starting position for the graph's execution.
End ๐
- The End nodes signifies the conclusion of workflow in LangGraph.
- Upon reaching this nodes, the graph's execution stops, indicating that all intended processes have been completed.
Tools ๐ ๏ธ
- Tools are specialized functions or utilities that nodes can utilize to perform specific tasks such as fetching data from an API.
- They enhance the capabilities of nodes by providing additional functionalities.
- Nodes are part of the graph structure, while tools are functionalities used within nodes.
ToolNode
- A toolnode is just a special kind of node whose main job is to run a tool.
- It connects the tool's output back into the state, so other nodes can use that information.
State Graph
- A stategraph is a class in LangGraph used to build and compile the graph structure.
- It manages the nodes, edges and the overall state, ensuring that the workflow operates in a unified way and that data flows correctly between components
Runnable โก๏ธ
- A runnable in LangGraph is a standardized, executable component that species a specific task within an AI workflow.
- It serves as a fundamental building block and allowing for us to create modular systems.
Messages ๐ฌ
๐จ๐ปโโ๏ธ Human Message
- Represents input from a user.
๐ป System Message
- Used to provide instructions or context to the model
๐งฉ Functional Message
- Represents the result of a function call
๐ค AI Message
- Represents responses generated by AI models
๐จ Tool Message
- Similar to Function Message, but specific to tool usage.