4.5 Defining Nodes
How a node works
A LangGraph node in this app is just a Python function that accepts state and returns updated state.
For example, the flight specialist:
This exhibits the common node pattern:
- create or access an LLM
- build a prompt from structured state
- invoke the model
- save the result into state
- set the next node
The hotel and activity nodes follow the same structure, which makes the workflow easy to explain.
Knowledge Check
When creating the LLM for the flight_specialist node, we specified
a temperature of 0.4. What does this mean?
Click here to see the answer
Temperature controls how random or creative the model’s responses are.
- Lower temperature (e.g., 0.0–0.3): more deterministic and consistent responses
- Medium (around 0.4–0.7): balanced between accuracy and creativity
- Higher (0.8+): more diverse and creative, but less predictable
So setting temperature=0.4 means the flight_specialist agent will produce
responses that are mostly consistent and reliable, with a small amount of
variation, which useful for tasks that need correctness but not completely rigid answers.