Documentation
¶
Index ¶
- func Learn(ctx context.Context, l Interface, tag string, msg *Message) error
- func Recall(ctx context.Context, br Interface, tag string) iter.Seq2[Message, error]
- func ReduceEntropy(w string) string
- func Speak(ctx context.Context, s Interface, tag, prompt string) (string, []string, error)
- type Builder
- type Interface
- type Message
- type Skip
- type Tuple
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReduceEntropy ¶ added in v0.2.0
ReduceEntropy transforms a term in a way which makes it more likely to equal other terms transformed the same way.
Types ¶
type Builder ¶ added in v0.2.0
type Builder struct {
// contains filtered or unexported fields
}
Builder builds a spoken message along with its message trace.
func (*Builder) Reset ¶ added in v0.2.0
func (b *Builder) Reset()
Reset restores the builder to an empty state.
type Interface ¶ added in v0.2.0
type Interface interface { // Learn records a set of tuples. // // One tuple has an empty prefix to denote the start of the message, and // a different tuple has the empty string as its suffix to denote the end // of the message. The positions of each in the argument are not guaranteed. // // Each tuple's prefix has entropy reduction transformations applied. // // Tuples in the argument may share storage for prefixes. Learn(ctx context.Context, tag string, msg *Message, tuples []Tuple) error // Speak generates a full message and appends it to w. // // The prompt is in reverse order and has entropy reduction applied. Speak(ctx context.Context, tag string, prompt []string, w *Builder) error // Forget forgets everything learned from a single given message. // If nothing has been learned from the message, it must prevent anything // from being learned from a message with that ID. Forget(ctx context.Context, tag, id string) error // Recall reads out messages the brain knows. // At minimum, the message ID and text of each message must be retrieved; // other fields may be filled if they are available. // // Repeated calls using the pagination token returned from the previous // must yield every message that the brain had recorded at the time of the // first call exactly once. Messages learned after the first call of an // enumeration are read at most once. // // The first call of an enumeration uses an empty pagination token as input. // If the returned pagination token is empty, it is interpreted as the end // of the enumeration. Recall(ctx context.Context, tag, page string, out []Message) (n int, next string, err error) }
Interface is a store of learned messages which can reproduce them by parts.
It must be safe to call all methods of a brain concurrently with each other.
type Skip ¶ added in v0.2.0
type Skip struct {
// contains filtered or unexported fields
}
Skip computes numbers of elements to skip between samples to draw a single term uniformly from arbitrarily sized sequences.
To draw a sample, create a new Skip, accept the first term of the sequence, skip N(rand(), rand()) terms, accept the next, and repeat N followed by an accept until the sequence is exhausted.
Conceptually, drawing a sample from an arbitrary sequence can be performed by assigning each term a random weight and selecting the term that receives the largest. Skip transforms this procedure into modeling the number of random numbers it would take to find the next larger weight. Using this approach allows uniform sampling with O(log n) random numbers instead of O(n).