Skip to content

connerohnesorge/fantasy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

257 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fantasy

The Charm Fantasy logo
Latest Release GoDoc Build Status

Build AI agents with Go. Multi-provider, multi-model, one API.

  1. Choose a model and provider
  2. Add some tools
  3. Compile to native machine code and let it rip

Note

Fantasy is currently a preview. Expect API changes.

import "charm.land/fantasy" import "charm.land/fantasy/providers/openrouter" // Choose your fave provider. provider, err := openrouter.New(openrouter.WithAPIKey(myHotKey)) if err != nil { fmt.Fprintln(os.Stderr, "Whoops:", err) os.Exit(1) } ctx := context.Background() // Pick your fave model. model, err := provider.LanguageModel(ctx, "moonshotai/kimi-k2") if err != nil { fmt.Fprintln(os.Stderr, "Dang:", err) os.Exit(1) } // Make your own tools. cuteDogTool := fantasy.NewAgentTool( "cute_dog_tool", "Provide up-to-date info on cute dogs.", fetchCuteDogInfoFunc, ) // Equip your agent. agent := fantasy.NewAgent( model, fantasy.WithSystemPrompt("You are a moderately helpful, dog-centric assistant."), fantasy.WithTools(cuteDogTool), ) // Put that agent to work! const prompt = "Find all the cute dogs in Silver Lake, Los Angeles." result, err := agent.Generate(ctx, fantasy.AgentCall{Prompt: prompt}) if err != nil { fmt.Fprintln(os.Stderr, "Oof:", err) os.Exit(1) } fmt.Println(result.Response.Content.Text())

🍔 For the full implementation and more see the examples directory.

MLflow Integration

Fantasy includes built-in support for MLflow tracking and evaluation. A local MLflow server can be started using Docker Compose.

Prerequisites

  • Docker and Docker Compose installed and running

Quick Start

Start the MLflow server (runs on port 5000):

task mlflow:start

View server logs:

task mlflow:logs

Stop the server:

task mlflow:stop

Once running, the MLflow UI will be available at http://localhost:5000.

The MLflow server uses PostgreSQL as the backend store and includes persistent volumes for both the database and artifact storage.

Multi-model? Multi-provider?

Yeah! Fantasy is designed to support a wide variety of providers and models under a single API. While many providers such as Microsoft Azure, Amazon Bedrock, and OpenRouter have dedicated packages in Fantasy, many others work just fine with openaicompat, the generic OpenAI-compatible layer. That said, if you find a provider that’s not compatible and needs special treatment, please let us know in an issue (or open a PR).

Work in Progress

We built Fantasy to power Crush, a hot coding agent for glamourously invincible development. Given that, Fantasy does not yet support things like:

  • Image models
  • Audio models
  • PDF uploads
  • Provider tools (e.g. web_search)

For things you’d like to see supported, PRs are welcome.

Whatcha think?

We’d love to hear your thoughts on this project. Need help? We gotchu. You can find us on:


Part of Charm.

The Charm logo

Charm热爱开源 • Charm loves open source

About

Build AI agents with Go. Multiple providers, multiple models, one API 🧙

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Go 99.4%
  • Other 0.6%