promptml

package
v0.0.0-...-7b96089 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeFixed

func MakeFixed[T Node](t T) T

func Styled

func Styled[I Node, T Node](n T, opts ...StyleOpt[I]) T

Types

type Bounds

type Bounds struct {
	Position int
	Length   TokenLength
}

type BuildListStreamFunc

type BuildListStreamFunc func(ctx context.Context) iterators.Iterator[Node]

type ChatMessage

type ChatMessage struct {
	ContainerBase

	From obsfx.StringProperty
	Role obsfx.SimpleProperty[msn.Role]
}

func Message

func Message(from string, role msn.Role, content Node) *ChatMessage

func MessageWithData

func MessageWithData(from, to obsfx.ObservableValue[string], role obsfx.ObservableValue[msn.Role], content Node) *ChatMessage

type ContainerBase

type ContainerBase struct {
	NodeBase
	// contains filtered or unexported fields
}

func NewContainer

func NewContainer() *ContainerBase

func (*ContainerBase) AsPmlParent

func (n *ContainerBase) AsPmlParent() Parent

func (*ContainerBase) GetTokenBuffer

func (n *ContainerBase) GetTokenBuffer() *rendering.TokenBuffer

func (*ContainerBase) Layout

func (n *ContainerBase) Layout(ctx context.Context) error

func (*ContainerBase) LayoutChildren

func (n *ContainerBase) LayoutChildren(ctx context.Context) error

func (*ContainerBase) NeedsLayout

func (n *ContainerBase) NeedsLayout() bool

func (*ContainerBase) PmlContainer

func (n *ContainerBase) PmlContainer() *ContainerBase

func (*ContainerBase) RequestLayout

func (n *ContainerBase) RequestLayout()

func (*ContainerBase) Update

func (n *ContainerBase) Update(ctx context.Context) error

type DynamicList

type DynamicList struct {
	ContainerBase
	// contains filtered or unexported fields
}

func NewDynamicList

func NewDynamicList(streamBuilder BuildListStreamFunc) *DynamicList

func (*DynamicList) Update

func (l *DynamicList) Update(ctx context.Context) error

type Leaf

type Leaf interface {
	Node

	Render(ctx context.Context) error

	GetTokenBuffer() *rendering.TokenBuffer
}

type LeafBase

type LeafBase struct {
	NodeBase
}

func (*LeafBase) Init

func (l *LeafBase) Init(self psi.Node, uuid string)

func (*LeafBase) PmlLeaf

func (l *LeafBase) PmlLeaf() Leaf

func (*LeafBase) Render

func (l *LeafBase) Render(ctx context.Context) error

func (*LeafBase) Update

func (l *LeafBase) Update(ctx context.Context) error

type Node

type Node interface {
	psi.Node

	PmlNodeBase() *NodeBase
	PmlNode() Node

	GetLayoutBounds() Bounds
	GetBoundsInLocal() Bounds
	GetBoundsInParent() Bounds

	IsResizable() bool
	SetResizable(resizable bool)

	IsVisible() bool
	SetVisible(visible bool)

	IsMovable() bool
	SetMovable(movable bool)

	GetMinLength() TokenLength
	SetMinLength(length TokenLength)

	GetMaxLength() TokenLength
	SetMaxLength(length TokenLength)

	GetRelevance() float64
	GetBias() float64
	SetBias(bias float64)

	GetTokenLength() int
	GetTokenLengthProperty() obsfx.ObservableValue[int]
}

type NodeBase

type NodeBase struct {
	psi.NodeBase

	LayoutBounds obsfx.Property[*Bounds] `json:"layout_bounds,omitempty"`

	Visible   obsfx.BoolProperty `json:"visible,omitempty"`
	Resizable obsfx.BoolProperty `json:"resizable"`
	Movable   obsfx.BoolProperty `json:"movable"`

	MinLength obsfx.SimpleProperty[TokenLength] `json:"min_length"`
	MaxLength obsfx.SimpleProperty[TokenLength] `json:"max_length"`

	Bias obsfx.DoubleProperty `json:"bias"`
	// contains filtered or unexported fields
}

func (*NodeBase) GetBias

func (n *NodeBase) GetBias() float64

func (*NodeBase) GetBoundsInLocal

func (n *NodeBase) GetBoundsInLocal() Bounds

func (*NodeBase) GetBoundsInParent

func (n *NodeBase) GetBoundsInParent() Bounds

func (*NodeBase) GetEffectiveMaxLength

func (n *NodeBase) GetEffectiveMaxLength() int

func (*NodeBase) GetEffectiveMinLength

func (n *NodeBase) GetEffectiveMinLength() int

func (*NodeBase) GetLayoutBounds

func (n *NodeBase) GetLayoutBounds() Bounds

func (*NodeBase) GetMaxLength

func (n *NodeBase) GetMaxLength() TokenLength

func (*NodeBase) GetMinLength

func (n *NodeBase) GetMinLength() TokenLength

func (*NodeBase) GetRelevance

func (n *NodeBase) GetRelevance() float64

func (*NodeBase) GetStage

func (n *NodeBase) GetStage() *Stage

func (*NodeBase) GetTokenBuffer

func (n *NodeBase) GetTokenBuffer() *rendering.TokenBuffer

func (*NodeBase) GetTokenLength

func (n *NodeBase) GetTokenLength() int

func (*NodeBase) GetTokenLengthProperty

func (n *NodeBase) GetTokenLengthProperty() obsfx.ObservableValue[int]

func (*NodeBase) Init

func (n *NodeBase) Init(self psi.Node, uuid string)

func (*NodeBase) InvalidateLayout

func (n *NodeBase) InvalidateLayout()

func (*NodeBase) IsContainer

func (n *NodeBase) IsContainer() bool

func (*NodeBase) IsLeaf

func (n *NodeBase) IsLeaf() bool

func (*NodeBase) IsMovable

func (n *NodeBase) IsMovable() bool

func (*NodeBase) IsResizable

func (n *NodeBase) IsResizable() bool

func (*NodeBase) IsVisible

func (n *NodeBase) IsVisible() bool

func (*NodeBase) PmlNode

func (n *NodeBase) PmlNode() Node

func (*NodeBase) PmlNodeBase

func (n *NodeBase) PmlNodeBase() *NodeBase

func (*NodeBase) PmlParent

func (n *NodeBase) PmlParent() Parent

func (*NodeBase) RelevanceProperty

func (n *NodeBase) RelevanceProperty() obsfx.Property[float64]

func (*NodeBase) RequestParentLayout

func (n *NodeBase) RequestParentLayout()

func (*NodeBase) SetBias

func (n *NodeBase) SetBias(bias float64)

func (*NodeBase) SetMaxLength

func (n *NodeBase) SetMaxLength(length TokenLength)

func (*NodeBase) SetMinLength

func (n *NodeBase) SetMinLength(length TokenLength)

func (*NodeBase) SetMovable

func (n *NodeBase) SetMovable(movable bool)

func (*NodeBase) SetResizable

func (n *NodeBase) SetResizable(resizable bool)

func (*NodeBase) SetVisible

func (n *NodeBase) SetVisible(visible bool)

func (*NodeBase) Update

func (n *NodeBase) Update(ctx context.Context) error

type Parent

type Parent interface {
	Node

	PmlParent() Parent
	PmlContainer() *ContainerBase

	GetTokenBuffer() *rendering.TokenBuffer

	NeedsLayout() bool
	RequestLayout()

	Layout(ctx context.Context) error
	LayoutChildren(ctx context.Context) error
}

func Container

func Container(children ...Node) Parent

type Stage

type Stage struct {
	MaxTokens int
	Tokenizer tokenizers.BasicTokenizer
	// contains filtered or unexported fields
}

func NewStage

func NewStage(root Parent, tokenizer tokenizers.BasicTokenizer) *Stage

func (*Stage) Render

func (s *Stage) Render(ctx context.Context, writer io.Writer) error

func (*Stage) RenderToString

func (s *Stage) RenderToString(ctx context.Context) (string, error)

type StyleOpt

type StyleOpt[T Node] func(v T)

func Fixed

func Fixed() StyleOpt[Node]

type TextNode

type TextNode struct {
	LeafBase

	Text obsfx.StringProperty `json:"text"`
}

func Text

func Text(content string) *TextNode

func TextWithData

func TextWithData(binding obsfx.ObservableValue[string]) *TextNode

func (*TextNode) Init

func (l *TextNode) Init(self psi.Node, uuid string)

func (*TextNode) Render

func (l *TextNode) Render(ctx context.Context) error

type TokenLength

type TokenLength struct {
	Amount float64
	Unit   TokenUnit
}

func NewTokenLength

func NewTokenLength(amount float64, unit TokenUnit) TokenLength

func (TokenLength) Add

func (s TokenLength) Add(other TokenLength) TokenLength

func (TokenLength) Div

func (s TokenLength) Div(other TokenLength) TokenLength

func (TokenLength) GetEffectiveLength

func (s TokenLength) GetEffectiveLength(relFn func(float64) int, undefFn func() int) int

func (TokenLength) IsNegative

func (s TokenLength) IsNegative() bool

func (TokenLength) IsNonNegative

func (s TokenLength) IsNonNegative() bool

func (TokenLength) IsNonPositive

func (s TokenLength) IsNonPositive() bool

func (TokenLength) IsPositive

func (s TokenLength) IsPositive() bool

func (TokenLength) IsReal

func (s TokenLength) IsReal() bool

func (TokenLength) IsUnbounded

func (s TokenLength) IsUnbounded() bool

func (TokenLength) IsZero

func (s TokenLength) IsZero() bool

func (TokenLength) Mod

func (s TokenLength) Mod(other TokenLength) TokenLength

func (TokenLength) Mul

func (s TokenLength) Mul(other TokenLength) TokenLength

func (TokenLength) MulInt

func (s TokenLength) MulInt(scalar int) TokenLength

func (TokenLength) MulScalar

func (s TokenLength) MulScalar(scalar float64) TokenLength

func (TokenLength) String

func (s TokenLength) String() string

func (TokenLength) Sub

func (s TokenLength) Sub(other TokenLength) TokenLength

func (TokenLength) TokenCount

func (s TokenLength) TokenCount() int

type TokenUnit

type TokenUnit string
const (
	TokenUnitUndefined TokenUnit = ""
	TokenUnitChar      TokenUnit = "c"
	TokenUnitWord      TokenUnit = "w"
	TokenUnitLine      TokenUnit = "l"
	TokenUnitToken     TokenUnit = "t"
	TokenUnitPercent   TokenUnit = "p"
)

Jump to

Keyboard shortcuts

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