GoLangGraph

command module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2025 License: MIT Imports: 8 Imported by: 0

README ยถ

GoLangGraph Logo

๐Ÿš€ GoLangGraph

Build Intelligent AI Agent Workflows with Go

CI codecov Go Report Card GoDoc

Quick Start โ€ข Features โ€ข Examples โ€ข Documentation โ€ข Contributing


๐ŸŽฏ 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)
}

ReAct Agent with Tools

// 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
}

๐Ÿ”ง Tool Agent

Specialized agent focused on tool usage:

config := &agent.AgentConfig{
    Type:  agent.AgentTypeTool,
    Tools: []string{"file_read", "file_write", "shell"},
    // ... other config
}

๐Ÿ”ง Built-in Tools

  • ๐Ÿงฎ 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

  1. ๐Ÿด Fork the repository
  2. ๐ŸŒฟ Create a feature branch
  3. โœจ Make your changes and add tests
  4. ๐Ÿงช Run tests: go test ./...
  5. ๐Ÿ’พ Commit your changes
  6. ๐Ÿš€ Push and open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ†˜ Support & Community

Resource Link
๐Ÿ“š Documentation GoDoc
๐Ÿ› Issues GitHub Issues
๐Ÿ’ฌ Discussions GitHub Discussions
๐Ÿ“ง Email support@golanggraph.dev

๐Ÿ™ Acknowledgments

  • ๐ŸŒŸ Inspired by LangGraph and similar workflow engines
  • ๐Ÿน Built with the excellent Go ecosystem
  • ๐Ÿ‘ฅ Special thanks to all contributors

๐Ÿš€ GoLangGraph - Building intelligent AI workflows with Go! ๐Ÿš€

โญ Star us on GitHub โ€ข ๐Ÿ› Report Bug โ€ข ๐Ÿ’ฌ Request Feature

Documentation ยถ

The Go Gopher

There is no documentation for this package.

Directories ยถ

Path Synopsis
cmd
examples command
golanggraph command
agents command
pkg
agent
Package agent provides intelligent agent implementations for building AI-powered workflows.
Package agent provides intelligent agent implementations for building AI-powered workflows.
core
Package core provides the fundamental building blocks for creating and executing graph-based workflows in GoLangGraph.
Package core provides the fundamental building blocks for creating and executing graph-based workflows in GoLangGraph.
llm

Jump to

Keyboard shortcuts

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