prompt

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: MIT Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReservedKeys added in v0.1.0

func ReservedKeys() []string

Types

type Block

type Block struct {
	Text        string
	RefProvider provider.Privider
}

func (*Block) Parse

func (b *Block) Parse() *ParsedBlock

type BlockToken

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

func TxTokens added in v0.1.0

func TxTokens(tokens []BlockToken, varMoveTx, vatToLiterTx map[string]string) []BlockToken

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 BlockType added in v0.1.0

type BlockType string
const (
	PromptBlock BlockType = "prompt"
	RefBlock    BlockType = "ref"
)

type CompiledPrompt

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

type CompiledPromptC added in v0.1.0

type CompiledPromptC struct {
	SharedInfo
	Fatal        bool
	Prompts      []CompiledPrompt
	CompiledVars map[string]string
	Exceptions   []error
}

func (*CompiledPromptC) OpenAIChatCompletionMessages added in v0.1.0

func (c *CompiledPromptC) OpenAIChatCompletionMessages(ignoreEmptyPrompt bool) []openai.ChatCompletionMessage

type Conf

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

type DriverExtra added in v0.0.2

type DriverExtra struct {
	Temperature *float32 `json:"temperature,omitempty"`
	Stop        []string `json:"stop,omitempty"`
}

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) (compiled string, exceptions []error, fatal bool)

func (*ParsedBlock) Formatted added in v0.1.0

func (p *ParsedBlock) Formatted(prov provider.Privider) []string

func (*ParsedBlock) IsRef added in v0.1.0

func (p *ParsedBlock) IsRef() bool

func (*ParsedBlock) ToJson

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

func (*ParsedBlock) ToMap

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

func (*ParsedBlock) ToReferBlock added in v0.1.0

func (p *ParsedBlock) ToReferBlock(refProvider provider.Privider) (*ReferBlock, error)

func (*ParsedBlock) Type added in v0.1.0

func (p *ParsedBlock) Type() BlockType

type PromptC added in v0.1.0

type PromptC struct {
	SharedInfo
	Vars          map[string]string              `json:"vars"`
	Prompts       []string                       `json:"prompts"`
	VarConstraint map[string]interfaces.Variable `json:"-"`
	ParsedPrompt  []*ParsedBlock                 `json:"-"`
	Exceptions    []error                        `json:"-"`
	RefProvider   provider.Privider              `json:"-"`
}

func ParseBasicPrompt added in v0.1.0

func ParseBasicPrompt(content string) *PromptC

func ParseFile

func ParseFile(content string) *PromptC

ParseFile @deprecated Deprecated: FunctionName is deprecated. Use ParsePromptC instead.

func ParsePromptC added in v0.1.0

func ParsePromptC(content string) *PromptC

func ParseUnstructuredFile added in v0.0.2

func ParseUnstructuredFile(content string) *PromptC

ParseUnstructuredFile @deprecated Deprecated: FunctionName is deprecated. Use ParseBasicPrompt instead.

func (*PromptC) Compile added in v0.1.0

func (f *PromptC) Compile(vars map[string]string) *CompiledPromptC

func (*PromptC) Copy added in v0.1.0

func (f *PromptC) Copy() *PromptC

Copy returns a copy of the promptc file this is not Clone, Copy will still contains the same reference to the variable

func (*PromptC) Formatted added in v0.1.0

func (f *PromptC) Formatted() string

func (*PromptC) GetConf added in v0.1.0

func (f *PromptC) GetConf() Conf

func (*PromptC) OldStyle added in v0.1.0

func (f *PromptC) OldStyle() string

type ReferBlock added in v0.1.0

type ReferBlock struct {
	RefTo       string            `json:"ref"`
	VarMap      map[string]string `json:"vars"`
	RefProvider provider.Privider `json:"-"`
}

func (*ReferBlock) Compile added in v0.1.0

func (r *ReferBlock) Compile(vars map[string]string) ([]CompiledPrompt, []error)

func (*ReferBlock) Formatted added in v0.1.0

func (r *ReferBlock) Formatted(prov provider.Privider) []string

type SharedInfo added in v0.1.0

type SharedInfo struct {
	FileInfo
	Conf *Conf `json:"conf,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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