prompt

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Text string
}

func (*Block) Parse

func (b *Block) Parse() *ParsedBlock

type BlockToken

type BlockToken struct {
	Text string         `json:"text"`
	Kind BlockTokenKind `json:"kind"`
}

type BlockTokenKind

type BlockTokenKind string
const BlockTokenKindLiter BlockTokenKind = "liter"
const BlockTokenKindReservedQuota BlockTokenKind = "reserved_quota"
const BlockTokenKindScript BlockTokenKind = "script"
const BlockTokenKindVar BlockTokenKind = "var"

func (BlockTokenKind) String

func (b BlockTokenKind) String() string

type CompiledFile

type CompiledFile struct {
	Info         FileInfo
	Conf         *Conf
	Prompts      []CompiledPrompt
	CompiledVars map[string]string
}

type CompiledPrompt

type CompiledPrompt struct {
	Prompt string
	Extra  map[string]any
}

type Conf

type Conf struct {
	Model    string `json:"model,omitempty,default=gpt-3.5-turbo"`
	Provider string `json:"provider,omitempty,default=openai"`
}

type File

type File struct {
	FileInfo
	Conf         *Conf                          `json:"conf"`
	Prompts      []string                       `json:"prompts"`
	Vars         map[string]string              `json:"vars"`
	ParsedVars   map[string]interfaces.Variable `json:"-"`
	ParsedPrompt []*ParsedBlock                 `json:"-"`
}

func ParseFile

func ParseFile(content string) *File

func (*File) Compile

func (f *File) Compile(vars map[string]string) *CompiledFile

type FileInfo

type FileInfo struct {
	Author  string `json:"author,omitempty"`
	License string `json:"license,omitempty"`
	Project string `json:"project,omitempty"`
	Version string `json:"version,omitempty"`
}

type ParsedBlock

type ParsedBlock struct {
	Text    string         `json:"-"`
	VarList []string       `json:"-"`
	Tokens  []BlockToken   `json:"tokens"`
	Extra   map[string]any `json:"extra"`
}

func (*ParsedBlock) Compile

func (p *ParsedBlock) Compile(varMap map[string]string) string

func (*ParsedBlock) ToJson

func (p *ParsedBlock) ToJson() ([]byte, error)

func (*ParsedBlock) ToMap

func (p *ParsedBlock) ToMap() map[string]any

Jump to

Keyboard shortcuts

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