Skip to content

lexlapax/go-llmspell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

go-llmspell

Cast scripting spells to animate LLM golems ๐Ÿง™โ€โ™‚๏ธโœจ

go-llmspell transforms complex LLM interactions into simple, magical scripts. Write spells in Lua, JavaScript, or Tengo that bring AI agents to life, automate conversations, and orchestrate intelligent workflowsโ€”all with the reliability and performance of Go.

-- example spell: creative-writer.lua
local topic = params.topic or "the future of AI"

-- Create an agent with creative writing abilities
local writer = agent.create({
    name = "creative_writer",
    system_prompt = "You are a creative writer with a vivid imagination."
})

-- Generate a story
local story = writer.run("Write a short story about " .. topic)

-- Save the result
fs.write("story.md", story)
log.info("Story created!", {topic = topic})

๐Ÿš€ Key Features

  • ๐Ÿช„ Scriptable Magic: Write spells in Lua, JavaScript, or Tengo to control LLMs
  • ๐Ÿค– Agent Orchestration: Create and manage AI agents with tools and workflows
  • ๐Ÿ”ง Tool Integration: Build custom tools that agents can use
  • โšก Go Performance: Native Go speed with embedded scripting flexibility
  • ๐Ÿ”’ Secure Execution: Sandboxed script execution with resource limits
  • ๐Ÿ“š Spellbook Library: Pre-written spells for common AI tasks

๐Ÿ“– Documentation

๐Ÿ—๏ธ Project Status

This project is under active development. See our TODO for current tasks and TODO-DONE for completed work.

Current Status

  • โœ… Architecture designed and documented
  • โœ… go-llms integration complete
  • โœ… Basic project structure
  • โœ… Core infrastructure implementation (Phase 1 complete)
    • โœ… Engine interface and registry system
    • โœ… Bridge infrastructure with lifecycle management
    • โœ… Security context with resource limits
  • โœ… LLM Bridge enhancement (Phase 2 complete)
    • โœ… Multi-provider support (OpenAI, Anthropic, Gemini)
    • โœ… Provider switching and model discovery
    • โœ… Type conversion utilities
    • โœ… Comprehensive test coverage
  • โœ… Lua engine implementation (Phase 3 complete)
    • โœ… Full Lua VM integration with security sandbox
    • โœ… Complete standard library (JSON, HTTP, Storage, Log, Promise)
    • โœ… LLM bridge for Lua scripts
    • โœ… Example spells demonstrating capabilities
  • โœ… Tool System implementation (Phase 4 complete)
    • โœ… Tool interface and registry for managing tools
    • โœ… Script-based tool creation with parameter validation
    • โœ… Lua bridge for tool system (tools module)
    • โœ… Example tools demonstrating the system
  • โœ… Agent System implementation (Phase 5 complete)
    • โœ… Agent interface and registry system
    • โœ… Default agent implementation with go-llms integration
    • โœ… Tool integration for agent capabilities
    • โœ… Agent bridge for script access
    • โœ… Lua integration with comprehensive examples
    • โœ… Research, Code Analysis, and Planning agent examples

๐Ÿ› ๏ธ Installation

# Clone the repository
git clone https://github.com/lexlapax/go-llmspell.git
cd go-llmspell

# Initialize submodules (for go-llms reference)
git submodule update --init --recursive

# Build the project
make build

# Run tests
make test

๐ŸŽฏ Quick Start

Setting Up API Keys

The easiest way to configure API keys is using a .env file:

# Copy the example environment file
cp .env.example .env

# Edit .env and add your API keys:
# OPENAI_API_KEY=sk-...
# ANTHROPIC_API_KEY=sk-ant-...
# GEMINI_API_KEY=AI...

The CLI will automatically load the .env file. See Environment Setup for more details.

Running Example Spells

# Run the async LLM example (demonstrates promises)
./bin/llmspell run examples/spells/async-llm

# Compare multiple LLM providers
./bin/llmspell run examples/spells/provider-compare --param prompt="What is AI?"

# Simple chat assistant demo
./bin/llmspell run examples/spells/chat-assistant

Available Example Spells

  • async-llm: Demonstrates promise-based async patterns with LLMs
  • provider-compare: Compares responses from multiple providers
  • chat-assistant: Interactive chat with conversation history (demo version)
  • hello-llm: Basic spell structure example
  • lua-agent: Comprehensive agent examples showing:
    • Research agent with web_fetch tool integration
    • Code analysis agent with custom Lua tools
    • Planning agent for task decomposition
  • builtin-tools: Demonstrates using built-in tools from go-llms
  • tool-example: Shows how to create and use custom tools

Future CLI (Coming Soon)

# Run a spell
llmspell run my-spell.lua

# List available spells
llmspell list

# Create a new spell
llmspell create my-spell

๐Ÿ›๏ธ Architecture

go-llmspell uses a layered architecture:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚        Spell Scripts (Lua/JS)       โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚         Script Engines              โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚          Bridge Layer               โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚           go-llms                   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Core Components

  • Script Engines: Lua (gopher-lua), JavaScript (goja), Tengo
  • Bridges: LLM, Tools, Agents, Workflows, StdLib
  • Security: Sandboxing, resource limits, filesystem jail
  • Spells: Reusable scripts for common tasks

๐Ÿ”ฎ Example Spells (Coming Soon)

Web Researcher

-- Research a topic using web search and LLM analysis
local researcher = spell.load("web-researcher")
local report = researcher.run({topic = "quantum computing"})

Code Reviewer

// Automated code review with AI
const reviewer = await spell.load("code-reviewer");
const review = await reviewer.run({
    file: "main.go",
    style: "golang"
});

Blog Writer

-- Generate blog posts with research and editing
local writer = spell.load("blog-writer")
local post = writer.run({
    topic = "The Future of AI",
    tone = "professional",
    length = 1000
})

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guidelines (coming soon).

Development Setup

  1. Fork the repository
  2. Create a feature branch
  3. Write tests first (TDD approach)
  4. Implement your feature
  5. Run quality checks: make fmt vet lint test
  6. Submit a pull request

๐Ÿ“ฆ Dependencies

  • go-llms v0.2.6 - LLM provider abstraction
  • gopher-lua v1.1.1 - Lua 5.1 VM (integrated)
  • goja - JavaScript engine (planned)
  • tengo - Embeddable script language (planned)

๐Ÿ“„ License

[License information to be added]

๐ŸŽ‰ Acknowledgments

Built on top of the excellent go-llms library.


Note: This project is under active development. APIs and features may change. Check the documentation for the latest information.

About

Animate your AI golems with enchanted scripts - scripting interface to go-llms library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors