๐ฏ Overview
GoLangGraph is a Go framework for building AI agent workflows using graph-based execution. Create intelligent agents that can reason, use tools, and execute complex workflows with the performance and reliability of Go.
๐ก Perfect for: Building AI applications, RAG systems, multi-agent workflows, and intelligent automation tools using local LLMs like Ollama.
๐ Graphical Interface Studio
GoLangGraphStudio -> we are working on a GUI based Studio component for this library GoLangGraphStudio
don't hesitate to contribute !
โจ Key Features
- ๐ Graph-Based Execution - Build workflows as directed graphs with nodes and edges
- ๐ง AI Agent Framework - Chat, ReAct, and Tool agents with different capabilities
- ๐ Multi-LLM Support - OpenAI, Ollama, and Gemini provider integrations
- ๐ง Built-in Tools - Calculator, web search, file operations, and more
- ๐พ State Management - Thread-safe state containers with persistence options
- ๐ Auto Server - Automatically generate REST APIs for your agents
- ๐ Monitoring & Observability - Grafana dashboards, Prometheus metrics, and comprehensive monitoring
- ๐ณ Production Ready - Docker support, comprehensive testing, and error handling
๐ฆ Installation
go get github.com/piotrlaczkowski/GoLangGraph
๐ Quick Start
Prerequisites
- Go 1.21+
- Ollama (optional, for local LLM testing)
Simple Chat Agent
package main
import (
"context"
"fmt"
"log"
"github.com/piotrlaczkowski/GoLangGraph/pkg/agent"
"github.com/piotrlaczkowski/GoLangGraph/pkg/llm"
"github.com/piotrlaczkowski/GoLangGraph/pkg/tools"
)
func main() {
// Create LLM provider manager
llmManager := llm.NewProviderManager()
// Add Ollama provider (requires Ollama running locally)
provider, err := llm.NewOllamaProvider(&llm.ProviderConfig{
Endpoint: "http://localhost:11434",
Model: "gemma3:1b",
})
if err != nil {
log.Fatal(err)
}
llmManager.RegisterProvider("ollama", provider)
// Create tool registry
toolRegistry := tools.NewToolRegistry()
// Create chat agent
config := &agent.AgentConfig{
Name: "chat-agent",
Type: agent.AgentTypeChat,
Model: "gemma3:1b",
Provider: "ollama",
SystemPrompt: "You are a helpful AI assistant.",
Temperature: 0.7,
MaxTokens: 500,
}
chatAgent := agent.NewAgent(config, llmManager, toolRegistry)
// Execute
ctx := context.Background()
execution, err := chatAgent.Execute(ctx, "Hello! Tell me about Go programming.")
if err != nil {
log.Fatal(err)
}
fmt.Printf("๐ค Agent: %s\n", execution.Output)
}
// Create ReAct agent with tools
config := &agent.AgentConfig{
Name: "react-agent",
Type: agent.AgentTypeReAct,
Model: "gemma3:1b",
Provider: "ollama",
Tools: []string{"calculator", "web_search"},
MaxIterations: 5,
SystemPrompt: "You are a helpful assistant that can use tools to solve problems.",
}
reactAgent := agent.NewAgent(config, llmManager, toolRegistry)
// Execute complex task
execution, err := reactAgent.Execute(ctx, "What is 25 * 34?")
if err != nil {
log.Fatal(err)
}
fmt.Printf("๐ง ReAct Agent: %s\n", execution.Output)
Graph Workflow
// Create custom graph workflow
graph := core.NewGraph("my-workflow")
// Add processing node
graph.AddNode("process", "Process Input", func(ctx context.Context, state *core.BaseState) (*core.BaseState, error) {
input, _ := state.Get("user_input")
state.Set("processed_input", fmt.Sprintf("Processing: %s", input))
return state, nil
})
// Add response node
graph.AddNode("respond", "Generate Response", func(ctx context.Context, state *core.BaseState) (*core.BaseState, error) {
processed, _ := state.Get("processed_input")
state.Set("response", fmt.Sprintf("Response: %s", processed))
return state, nil
})
// Connect nodes
graph.AddEdge("process", "respond", nil)
graph.SetStartNode("process")
graph.AddEndNode("respond")
// Execute graph
initialState := core.NewBaseState()
initialState.Set("user_input", "Hello, world!")
result, err := graph.Execute(context.Background(), initialState)
if err != nil {
log.Fatal(err)
}
fmt.Printf("๐ Graph Result: %v\n", result.Get("response"))
๐๏ธ Architecture
GoLangGraph follows a modular architecture:
๐ pkg/
โโโ ๐ง core/ # Graph execution engine and state management
โโโ ๐ค agent/ # AI agent implementations (Chat, ReAct, Tool)
โโโ ๐ llm/ # LLM provider integrations (OpenAI, Ollama, Gemini)
โโโ ๐ง tools/ # Built-in tools and tool registry
โโโ ๐พ persistence/ # Database integration and checkpointing
โโโ ๐ server/ # HTTP server and WebSocket support
โโโ ๐๏ธ builder/ # Quick builder patterns for rapid development
โโโ ๐ debug/ # Debugging and visualization tools
๐ฏ Agent Types
๐ฌ Chat Agent
Simple conversational agent for basic interactions:
config := &agent.AgentConfig{
Type: agent.AgentTypeChat,
// ... other config
}
๐ง ReAct Agent
Reasoning and Acting agent that can use tools:
config := &agent.AgentConfig{
Type: agent.AgentTypeReAct,
Tools: []string{"calculator", "web_search"},
MaxIterations: 5,
// ... other config
}
Specialized agent focused on tool usage:
config := &agent.AgentConfig{
Type: agent.AgentTypeTool,
Tools: []string{"file_read", "file_write", "shell"},
// ... other config
}
- ๐งฎ Calculator - Mathematical operations
- ๐ Web Search - Information retrieval
- ๐ File Operations - Read/write files
- ๐ HTTP Client - Web requests
- โฐ Time - Date and time operations
- ๐ฅ๏ธ Shell - Command execution
๐ LLM Providers
OpenAI
provider, err := llm.NewOpenAIProvider(&llm.ProviderConfig{
APIKey: "your-api-key",
Model: "gpt-4",
})
Ollama (Local)
provider, err := llm.NewOllamaProvider(&llm.ProviderConfig{
Endpoint: "http://localhost:11434",
Model: "gemma3:1b",
})
Gemini
provider, err := llm.NewGeminiProvider(&llm.ProviderConfig{
APIKey: "your-gemini-api-key",
Model: "gemini-pro",
})
๐ Auto Server & API Generation
GoLangGraph can automatically generate REST APIs for your agents:
import "github.com/piotrlaczkowski/GoLangGraph/pkg/server"
// Create auto server
config := server.DefaultAutoServerConfig()
config.Port = 8080
config.EnableWebUI = true
config.EnablePlayground = true
autoServer := server.NewAutoServer(config)
// Register your agents
autoServer.RegisterAgent("chat-agent", chatAgentDefinition)
autoServer.RegisterAgent("react-agent", reactAgentDefinition)
// Generate endpoints automatically
autoServer.GenerateEndpoints()
// Start server
ctx := context.Background()
autoServer.Start(ctx)
This automatically creates:
- ๐ REST Endpoints:
/api/{agent-id} for each agent
- ๐ฎ Web UI: Interactive chat interface at
/
- ๐ง API Playground: Test endpoints at
/playground
- ๐ Metrics: System metrics at
/metrics
- ๐ Health Checks: Status monitoring at
/health
๐ Examples
Explore comprehensive examples in the /examples directory:
Running Examples
# Prerequisites: Install Ollama and pull models
ollama serve
ollama pull gemma3:1b
# Run any example
cd examples/01-basic-chat
go run main.go
๐ ๏ธ Development
๐ Prerequisites
- ๐น Go 1.21+ - Latest Go version
- ๐ฆ Ollama (optional) - For local LLM testing
- ๐ณ Docker (optional) - For containerized development
๐ Setup
# Clone repository
git clone https://github.com/piotrlaczkowski/GoLangGraph.git
cd GoLangGraph
# Install dependencies
make install
# Build the project
make build
# Run tests
make test
# Run examples
cd examples/01-basic-chat
go run main.go
๐งช Testing & Quality
# Run all tests
make test
# Run tests with coverage
make test-coverage
# Run integration tests
make test-integration
# Code quality checks
make lint # Run linter
make fmt # Format code
make vet # Run go vet
make security # Security scan
# Complete quality check
make check # Run all checks
๐ณ Docker & Production
# Build Docker images
make docker-build-agent
# Production deployment
make build-release
# Local development with Ollama
make ollama-setup
make test-local
๐ Security
- โ
Input Validation - All inputs are validated and sanitized
- ๐ก๏ธ SQL Injection Prevention - Parameterized queries throughout
- ๐ Secure Credential Handling - Environment variable management
- ๐ Audit Logging - Comprehensive execution logging
๐ค Contributing
We welcome contributions! Please see our Contributing Guide for details.
๐ Development Workflow
- ๐ด Fork the repository
- ๐ฟ Create a feature branch
- โจ Make your changes and add tests
- ๐งช Run tests:
go test ./...
- ๐พ Commit your changes
- ๐ Push and open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- ๐ Inspired by LangGraph and similar workflow engines
- ๐น Built with the excellent Go ecosystem
- ๐ฅ Special thanks to all contributors