Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseMessage ¶ added in v0.4.1
type BaseMessage struct {
// contains filtered or unexported fields
}
func NewJsonMessage ¶ added in v0.4.1
func NewJsonMessage(role Role, content any) (BaseMessage, error)
NewJsonMessage marshals content and creates new `Message` with text kind and the specified `Role`
func NewMessage ¶ added in v0.4.1
func NewMessage(role Role, kind Kind, content []byte) BaseMessage
NewMessage creates new `Message` with the specified `Role` and `Kind`
func NewTextMessage ¶ added in v0.4.1
func NewTextMessage(role Role, content string) BaseMessage
NewTextMessage creates new `Message` with Text kind and the specified `Role`
func (BaseMessage) Content ¶ added in v0.4.1
func (bm BaseMessage) Content() []byte
func (BaseMessage) Kind ¶ added in v0.4.1
func (bm BaseMessage) Kind() Kind
func (BaseMessage) Role ¶ added in v0.4.1
func (bm BaseMessage) Role() Role
type Interceptor ¶
type Interceptor func(in Message, out Message, cfg *OperationConfig)
Interceptor is a function that is called by Process after one operation finished but before next one is started.
type Operation ¶
type Operation struct {
// contains filtered or unexported fields
}
Operation is basic building block.
func NewOperation ¶
func NewOperation(handler OperationHandler) *Operation
NewOperation allows to create an operation from a function.
func (*Operation) Config ¶
func (p *Operation) Config() *OperationConfig
func (*Operation) Execute ¶
Execute executes operation handler with input message and current configuration.
func (*Operation) SetMessages ¶
type OperationConfig ¶
OperationConfig represents abstract operation configuration for all possible models.
type OperationHandler ¶
OperationHandler is a function that implements operation's logic. It could be thought of as an interface that providers must implement.
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
Process is a chain of operations that can be executed in sequence.
func NewProcess ¶
NewProcess creates a new Process with given operations.
func (*Process) Execute ¶
func (p *Process) Execute(ctx context.Context, input Message, interceptors ...Interceptor) (Message, error)
Execute iterates over Process's operations and sequentially executes them. After first operation is executed it uses its output as an input to the second one and so on until the whole chain is finished. It also executes all given interceptors, if they are provided, so for every N operations and M interceptors it's N x M executions.
Directories
¶
Path | Synopsis |
---|---|
examples
|
|
speech_to_text
To make this example work make sure you have speech.ogg file in the root of directory.
|
To make this example work make sure you have speech.ogg file in the root of directory. |
speech_to_text_multi_model
To make this example work make sure you have speech.ogg file in the root of directory
|
To make this example work make sure you have speech.ogg file in the root of directory |
speech_to_text_to_image
To make this example work make sure you have speech.ogg file in the root of directory
|
To make this example work make sure you have speech.ogg file in the root of directory |
providers
|
|