Documentation ¶
Index ¶
- func ByteToString(b [][]byte) []string
- func ChunkFile(fs afero.Fs, path string, chunkSize int, maxChunks int, ...) error
- func ChunkFromReader(reader io.Reader, chunkSize int, maxChunks int, ...) error
- func ForEachSubdir(fs afero.Fs, path string, callback func(path string) error) error
- func GetChunks(reader io.Reader, chunkSize int, maxChunks int) ([][]byte, error)
- func GetFileChunks(ctx context.Context, fs afero.Fs, path string, chunkSize int, maxChunks int) ([][]byte, error)
- func HistoryBlocksToString(blocks []HistoryBlock) string
- func IsPipedStdin() bool
- func Min(a, b int) int
- func MultilineLipglossRender(style lipgloss.Style, str string) string
- type CacheWriter
- type ColorWriter
- type CompletionRequest
- type CompletionResponse
- type FunctionDefinition
- type HistoryBlock
- type ReplaceWriter
- type StyledWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteToString ¶
Cast an array of byte arrays to an array of strings
func ChunkFile ¶
func ChunkFile( fs afero.Fs, path string, chunkSize int, maxChunks int, callback func(int, []byte) error) error
Read a file, break into chunks of a given number of bytes, up to a maximum number of chunks, and call the callback for each chunk
func ChunkFromReader ¶
func ForEachSubdir ¶
Call a callback for each subdirectory in a given path
func GetFileChunks ¶
func GetFileChunks(ctx context.Context, fs afero.Fs, path string, chunkSize int, maxChunks int) ([][]byte, error)
Given a filesystem, a path, a chunk size, and maximum number of chunks, return a list of chunks of the file at the given path
func HistoryBlocksToString ¶ added in v0.0.20
func HistoryBlocksToString(blocks []HistoryBlock) string
func IsPipedStdin ¶
func IsPipedStdin() bool
Returns true if there is piped stdin data that can be read
func MultilineLipglossRender ¶
Lipgloss is a little tricky - if you render a string with newlines it turns it into a "block", i.e. each line will be padding to be the same length. This is not what we want, so we split on newlines and render each line separately.
Types ¶
type CacheWriter ¶
type CacheWriter struct {
// contains filtered or unexported fields
}
A io.Writer that caches bytes written and forwards writes to another writer
func NewCacheWriter ¶
func NewCacheWriter(forward io.Writer) *CacheWriter
func (*CacheWriter) GetCache ¶
func (this *CacheWriter) GetCache() []byte
func (*CacheWriter) GetLastN ¶
func (this *CacheWriter) GetLastN(n int) []byte
type ColorWriter ¶ added in v0.0.27
func NewColorWriter ¶ added in v0.0.27
func NewColorWriter(writer io.Writer, color string) *ColorWriter
type CompletionRequest ¶
type CompletionRequest struct { Ctx context.Context Prompt string Model string MaxTokens int Temperature float32 HistoryBlocks []HistoryBlock SystemMessage string Functions []FunctionDefinition Verbose bool }
We define types for calling LLM APIs here because I don't want the internal interfaces to depend on OpenAI-specific types.
type CompletionResponse ¶ added in v0.1.4
type FunctionDefinition ¶ added in v0.1.4
type HistoryBlock ¶ added in v0.0.20
func (HistoryBlock) String ¶ added in v0.0.20
func (this HistoryBlock) String() string
type ReplaceWriter ¶ added in v0.0.20
A Writer implementation that allows you to string replace the content flowing through
func NewReplaceWriter ¶ added in v0.0.20
func NewReplaceWriter(writer io.Writer, from string, to string) *ReplaceWriter
type StyledWriter ¶
type StyledWriter struct { Writer io.Writer Style lipgloss.Style // contains filtered or unexported fields }
An implementation of io.Writer that renders output with a lipgloss style and filters out the special token "NOOP". This is specially handled - we seem to get "NO" as a separate token from GPT.
func NewStyledWriter ¶
func NewStyledWriter(writer io.Writer, style lipgloss.Style) *StyledWriter