Documentation ¶
Index ¶
- Constants
- func Columns(str string, maxLen int) []string
- func Drain[T any](vals <-chan T, errs <-chan error) ([]T, error)
- func JoinStrings[E ~string](elems []E, sep string) E
- func Map[In, Out any](in <-chan In, fn func(In) Out) <-chan Out
- func NopLogger() *slog.Logger
- func OpenAITokenizer(model string) (tokenizer.Codec, error)
- func PrettyLogger(h slog.Handler) slog.Handler
- func RemoveColumns(str string) string
- func Stream[T any](values ...T) <-chan T
- func Walk[T any](vals <-chan T, errs <-chan error, fn func(T) error) error
Constants ¶
const LogLevelNaked = slog.Level(-1)
LogLevelNaked represents a logging level that is not associated with any predefined severity, allowing for custom handling in logging operations. It is used to indicate a log entry that should not be adorned with a standard level icon or prefix when processed by a custom log handler such as PrettyLogger.
Variables ¶
This section is empty.
Functions ¶
func Columns ¶ added in v0.0.4
Columns breaks a string into lines with a maximum given length, ensuring that words are not split across lines and excess whitespace is removed, and returns the resulting slice of strings.
func Drain ¶
Drain collects values from a channel of a specified type until the channel is closed, while also listening for an error on a separate error channel. It returns a slice containing all the collected values and an error if encountered. If the error channel is closed without any errors sent, it returns the collected values and a nil error. If an error is received, it returns the values collected up to that point along with the received error.
func JoinStrings ¶ added in v0.0.4
JoinStrings concatenates the elements of a slice of strings, using the provided separator between adjacent elements, and returns the resulting string. If the slice is empty, it returns an empty string. If the slice has only one element, it returns that element without the separator.
func Map ¶ added in v0.0.4
func Map[In, Out any](in <-chan In, fn func(In) Out) <-chan Out
Map applies a provided function to each element received from a channel and returns a new channel that emits the results.
func NopLogger ¶
NopLogger returns a new logger instance that will ignore all log events, effectively performing no operations when handling logs. It provides a *slog.Logger that can be used where logging is necessary but not desired to have any output or effect.
func OpenAITokenizer ¶ added in v0.1.1
OpenAITokenizer initializes and returns a tokenizer codec based on the specified model. If the model is not supported, it falls back to the default CL100kBase tokenizer. It may return an error if initializing the tokenizer fails for reasons other than an unsupported model. The returned codec can be used to tokenize or detokenize text according to the OpenAI specifications associated with the model.
func PrettyLogger ¶ added in v0.0.4
PrettyLogger wraps a given slog.Handler to enhance logging output with visually distinct icons based on the log level and formats attributes for improved readability. It returns a slog.Handler that can be used to handle log records in a more user-friendly manner.
func RemoveColumns ¶ added in v0.0.9
RemoveColumns cleans up paragraph text by removing newline characters within paragraphs and normalizing the spacing between words. It returns the resulting clean text.
func Stream ¶ added in v0.0.4
func Stream[T any](values ...T) <-chan T
Stream initiates a streaming of the provided values through a channel of the same type, allowing for concurrent processing of the values in a non-blocking manner. It returns a receive-only channel from which the streamed values can be read.
Types ¶
This section is empty.