Fantasy SDK

Use Charm's Fantasy Go library with Hyper.

Fantasy is Charm's Go library for LLM inference. Hyper has first-class support for it.

Installation#

go get charm.land/fantasy

Usage#

package main import (	"context"	"fmt"	"os" 	"charm.land/fantasy"	"charm.land/fantasy/providers/openaicompat") func main() {	provider, _ := openaicompat.New(		openaicompat.WithBaseURL("https://hyper.charm.land/v1"),		openaicompat.WithAPIKey("sk-hyper-xxxxxxxxxxxxxxxxxxxxxxxx"),	) 	ctx := context.Background()	model, _ := provider.LanguageModel(ctx, "prism") 	agent := fantasy.NewAgent(model)	result, err := agent.Generate(ctx, fantasy.AgentCall{Prompt: "Hello!"})	if err != nil {		fmt.Fprintln(os.Stderr, err)		os.Exit(1)	}	fmt.Println(result.Response.Content.Text())}