tarot

package module
v0.0.0-...-4626951 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: MIT Imports: 25 Imported by: 0

README

tarot

A naive tarot util.

You can read tarot cards by GPT or other LLM models.

You can also generate result picture.

Tarot Card Divine Results

Documentation

Index

Constants

View Source
const (
	PositionUpright  = "Upright"
	PositionReversed = "Reversed"
)

Variables

This section is empty.

Functions

func DrawStringWrapped

func DrawStringWrapped(dc *gg.Context, ff font.Face, s string, x, y, ax, ay, width, lineSpacing float64, align gg.Align) float64

DrawStringWrapped word-wraps the specified string to the given max width and then draws it at the specified anchor point using the given line spacing and text alignment.

Types

type Assets

type Assets struct {
	Cards         []Card
	BackgroundImg image.Image
	Font          *truetype.Font
	FontFace      font.Face
	AskerImg      image.Image
	ReaderImg     image.Image
}

func GetDefaultAssets

func GetDefaultAssets() Assets

type Card

type Card struct {
	Name     string      `json:"name"`
	ZhName   string      `json:"zh_name"`
	Position Position    `json:"-"`
	Pic      image.Image `json:"-"`
}

func (*Card) ZhString

func (c *Card) ZhString() string

type ChatGPTReader

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

func NewChatGPTReader

func NewChatGPTReader(chatGPTCli *openai.Client) *ChatGPTReader

func (*ChatGPTReader) Chat

func (r *ChatGPTReader) Chat(ctx context.Context, systemMsg, userMsg string) (string, error)

type DivineOption

type DivineOption struct {
	Question  string
	Asker     string
	AskerImg  image.Image
	Reader    string
	ReaderImg image.Image
	Callback  func(result *DivineResult, err error)
}

type DivineResult

type DivineResult struct {
	Cards  [3]Card
	Img    image.Image
	Result string
}

type DumbGPTReader

type DumbGPTReader struct{}

DumbGPTReader never reads.

func (*DumbGPTReader) Chat

func (r *DumbGPTReader) Chat(ctx context.Context, systemMsg, userMsg string) (string, error)

type GPTReader

type GPTReader interface {
	Chat(ctx context.Context, systemMsg, userMsg string) (string, error)
}

type Position

type Position string

func (*Position) ZhName

func (p *Position) ZhName() string

type Reader

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

func NewReader

func NewReader(gptReader GPTReader, userPrompt, systemPrompt string, assets Assets) (*Reader, error)

func (*Reader) Choose

func (r *Reader) Choose() ([3]Card, error)

func (*Reader) DivineWithOption

func (r *Reader) DivineWithOption(ctx context.Context, opt DivineOption) (*DivineResult, error)

func (*Reader) Prompt

func (r *Reader) Prompt(cards [3]Card, thing, template string) string

func (*Reader) Read

func (r *Reader) Read(ctx context.Context, cards [3]Card, thing string) (string, error)

func (*Reader) Render

func (r *Reader) Render(cards [3]Card, Q, A string, opt DivineOption) (image.Image, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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