prompt

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package prompt provides a easy way to format a prompt using the Go template engine. Prompts are defined using a template string and a list of inputs.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFormatting     = errors.New("formatting prompt error")
	ErrDecoding       = errors.New("decoding input error")
	ErrTemplateEngine = errors.New("template engine error")
)

Functions

This section is empty.

Types

type AudioResponseFormat

type AudioResponseFormat string
const (
	AudioResponseFormatText AudioResponseFormat = ""
	AudioResponseFormatJSON AudioResponseFormat = "json"
	AudioResponseFormatSRT  AudioResponseFormat = "srt"
	AudioResponseFormatVTT  AudioResponseFormat = "vtt"
)

type Prompt

type Prompt struct {
	// contains filtered or unexported fields
}

func New

func New(text string) *Prompt

func (*Prompt) Format

func (p *Prompt) Format(input types.M) error

func (*Prompt) String

func (p *Prompt) String() string

type Template

type Template struct {
	// contains filtered or unexported fields
}

func NewPromptTemplate

func NewPromptTemplate(text string) *Template

func (*Template) Format

func (t *Template) Format(input types.M) error

Format formats the prompt using the template engine and the provided inputs.

func (*Template) String

func (t *Template) String() string

func (*Template) WithInputs

func (t *Template) WithInputs(inputs interface{}) *Template

type WhisperPrompt

type WhisperPrompt struct {
	// contains filtered or unexported fields
}

func NewPromptFromAudioFile

func NewPromptFromAudioFile(
	ctx context.Context,
	filePath string,
	audioResponseFormat AudioResponseFormat,
) (*WhisperPrompt, error)

func (*WhisperPrompt) Format

func (p *WhisperPrompt) Format(input types.M) error

func (*WhisperPrompt) String

func (p *WhisperPrompt) String() string

func (*WhisperPrompt) WithClient

func (p *WhisperPrompt) WithClient(client *openai.Client) *WhisperPrompt

Jump to

Keyboard shortcuts

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