graph_with_llm

command
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Example: graph_with_llm — StateGraph with real LLM calls inside nodes.

What you'll learn:

  • How to wire a real LLM provider (OpenAI, Anthropic, Gemini, Ollama) into graph nodes
  • Building a multi-step workflow where each node calls the LLM for reasoning
  • Conditional routing based on LLM classification output
  • Using tools inside graph nodes for grounded agent behavior
  • Checkpointing and resume with SQLite persistence

Prerequisites:

  • Go 1.22+
  • At least one LLM API key (or Ollama running locally)

Environment variables (set ONE of these):

OPENAI_API_KEY=sk-...               → uses GPT-4o
ANTHROPIC_API_KEY=sk-ant-...        → uses Claude Sonnet 4
GEMINI_API_KEY=AIza...              → uses Gemini 2.0 Flash
(none)                              → uses Ollama at localhost:11434

Run:

export OPENAI_API_KEY=sk-your-key
go run ./examples/graph_with_llm/

YAML equivalent (same behavior, no Go code):

See examples/yaml-configs/graph-agent.yaml
CHRONOS_CONFIG=examples/yaml-configs/graph-agent.yaml go run ./cli/main.go run "Explain goroutines"

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL