Accepting Inputs

Accepting Inputs

How to get external data into your graph.

Accepting Inputs

Your graph is an encapsulated system. Input is injected via graph.invoke().

The Input Schema

Ideally, your Input Schema should be a subset of your State Schema.

# 1. Define inputs
inputs = {
    "messages": [("user", "Hello, do you know the weather?")],
    "user_id": "12345"
}

# 2. Inject
# The graph assigns these values to the initial state
graph.invoke(inputs)

Sanitizing Input

The first node (Entry Point) is the best place to sanitize input.

  • Truncate overly long messages (to save tokens).
  • Remove PII (Personally Identifiable Information).
  • Format the user query into a structured prompt.

Subscribe to our newsletter

Get the latest posts delivered right to your inbox.

Subscribe on LinkedIn