bonfire

package module
v0.0.0-...-46c65cd Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: MIT Imports: 11 Imported by: 0

README

Bonfire

Soulslike lore graph generator using AI.

Documentation

Index

Constants

View Source
const (
	Character     = "character"
	Item          = "item"
	Relic         = "relic"
	Equipment     = "equipment"
	Location      = "location"
	Faction       = "faction"
	Event         = "event"
	World         = "world"
	EventCatalyst = "event_catalyst"
)

Variables

View Source
var AllNonSingletonEntityTypes = []EntityType{
	Character,
	Item,
	Relic,
	Equipment,
	Location,
	Faction,
	Event,
}
View Source
var ResourcesFS embed.FS

Functions

func IsValidEntityType

func IsValidEntityType(s string) bool

Types

type DataStore

type DataStore interface {
	GetEntityById(id string) (*Entity, error)
	GetEntitiesByType(entityType EntityType) ([]*Entity, error)
	GetReferencedEntities(id string) ([]*Entity, error)
	GetUnknownReferences() ([]*UnknownReference, error)

	AddEntity(e *Entity) error

	Close() error
}

type Entity

type Entity struct {
	Name      string     `json:"name"`
	Id        string     `json:"id"`
	Type      EntityType `json:"type"`
	ShortDesc string     `json:"short_desc"`
	LongDesc  string     `json:"long_desc"`
	CreatedAt time.Time  `json:"created_at"`
}

func (*Entity) ParseReferences

func (e *Entity) ParseReferences(replacer func(fullMatch, id, innerText string) string) string

type EntityReferenceHint

type EntityReferenceHint struct {
	Id        string     `json:"id"`
	Type      EntityType `json:"type"`
	ShortDesc string     `json:"short_desc"`
}

type EntityType

type EntityType string

func RandomNonSingletonEntityType

func RandomNonSingletonEntityType() EntityType

type GenerateResult

type GenerateResult struct {
	Prompts  []string
	Response *Response
}

func Generate

func Generate(promptType PromptType, openAIToken string, dataStore DataStore, opts Options) (GenerateResult, error)

type Options

type Options struct {
	Style string
}

type PromptType

type PromptType int
const (
	PromptWorld PromptType = iota
	PromptCatalyst
	PromptEntity
)

func ParsePromptType

func ParsePromptType(str string) (PromptType, error)

func (PromptType) ToString

func (pt PromptType) ToString() (string, error)

type Response

type Response struct {
	Entity     *Entity                `json:"entity"`
	References []*EntityReferenceHint `json:"references"`
}

type SqliteDataStore

type SqliteDataStore struct {
	// contains filtered or unexported fields
}

func MakeSqliteDataStore

func MakeSqliteDataStore() *SqliteDataStore

func (*SqliteDataStore) AddEntity

func (s *SqliteDataStore) AddEntity(e *Entity) error

func (*SqliteDataStore) Close

func (s *SqliteDataStore) Close() error

func (*SqliteDataStore) GetEntitiesByType

func (s *SqliteDataStore) GetEntitiesByType(entityType EntityType) ([]*Entity, error)

func (*SqliteDataStore) GetEntityById

func (s *SqliteDataStore) GetEntityById(id string) (*Entity, error)

func (*SqliteDataStore) GetReferencedEntities

func (s *SqliteDataStore) GetReferencedEntities(id string) ([]*Entity, error)

func (*SqliteDataStore) GetUnknownReferences

func (s *SqliteDataStore) GetUnknownReferences() ([]*UnknownReference, error)

type UnknownReference

type UnknownReference struct {
	Id                  string
	ReferencingEntityId string
}

Directories

Path Synopsis
cmd
cli
internal
llm

Jump to

Keyboard shortcuts

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