Documentation
¶
Index ¶
- Variables
- func BoolPtr(b bool) *bool
- func ExtractCodeBlocks(s string) map[string][]string
- func ExtractJSONBlocks(s string) []map[string]interface{}
- func GenerateSchema[T any]() interface{}
- func Indent(content string, indent int) string
- func JoinWith(delim string, args ...string) string
- func NewID() string
- func NewName() string
- func ParseJSON(s string) map[string]interface{}
- func QuickWrap(tag, content string, indent int) string
- func QuickWrapWithAttributes(tag, content string, indent int, attributes map[string]string) string
- func Reflow(message string) (reflowed string)
- func ReplaceWith(template string, args [][]string) string
- func SplitIntoParagraphs(content string) []string
- func SplitIntoSentences(para string) []string
- func StripXML(message string) string
- func Substitute(message string, fragments map[string]string, indent int) string
- func WrapText(text string, width int) []string
Constants ¶
This section is empty.
Variables ¶
var Blue = lipgloss.NewStyle().TabWidth(2).Foreground(lipgloss.Color("#6E95F7")).Render
var Dark = lipgloss.NewStyle().TabWidth(2).Foreground(lipgloss.Color("#666666")).Render
var Green = lipgloss.NewStyle().TabWidth(2).Foreground(lipgloss.Color("#06C26F")).Render
var Highlight = lipgloss.NewStyle().TabWidth(2).Foreground(lipgloss.Color("#EEEEEE")).Render
var Muted = lipgloss.NewStyle().TabWidth(2).Foreground(lipgloss.Color("#999999")).Render
var Red = lipgloss.NewStyle().TabWidth(2).Foreground(lipgloss.Color("#F7746D")).Render
var Yellow = lipgloss.NewStyle().TabWidth(2).Foreground(lipgloss.Color("#F7B96D")).Render
Functions ¶
func ExtractCodeBlocks ¶
ExtractCodeBlocks parses markdown-style code blocks from a string. Returns a map where keys are language identifiers and values are slices of code blocks for that language.
func ExtractJSONBlocks ¶
ExtractJSONBlocks finds and parses JSON objects from a string. It specifically looks for JSON content within markdown-style code blocks that are marked with the 'json' language identifier. This is particularly useful when processing structured outputs from AI tools.
func GenerateSchema ¶
func GenerateSchema[T any]() interface{}
GenerateSchema creates a JSON schema for any type that implements jsonschema struct tags. It uses the jsonschema reflector to generate a complete schema, with additional properties disabled and direct type definitions (no references).
func Indent ¶
Indent adds a specified number of spaces to the beginning of a string. This is useful for formatting output, especially when dealing with structured data that needs to be visually separated.
func JoinWith ¶
JoinWith concatenates strings with a specified delimiter. It's a convenience wrapper around strings.Join that provides a more readable interface.
func NewID ¶
func NewID() string
NewID generates a new UUID string. It uses Google's UUID implementation to ensure uniqueness.
func NewName ¶
func NewName() string
NewName generates a unique, readable name. It maintains a list of previously generated names to ensure uniqueness within the current session.
func ParseJSON ¶
ParseJSON safely converts a JSON string into a map. Returns nil if the input is not valid JSON, making it safe for parsing potentially invalid input.
func QuickWrap ¶
QuickWrap encapsulates content in XML-style tags for better context separation. This is particularly useful when preparing content for LLM processing, as it helps maintain clear boundaries between different content sections.
func QuickWrapWithAttributes ¶
QuickWrapWithAttributes is a variant of QuickWrap that allows for additional attributes to be added to the tag.
func Reflow ¶
Reflow restructures the sentences in the message, so that each sentence ends with a newline, and each paragraph is separated by an empty line. It also tries to keep each sentence under 80 characters, and if it's longer, it will split it into multiple sentences, using a smart algorithm, to make sure we do not end up with just one or two words on the new line, but a somewhat balanced distribution of words.
func ReplaceWith ¶
ReplaceWith performs template-style string replacement using {placeholder} syntax. Each replacement is defined by a pair of strings where the first element is the placeholder name and the second is its replacement value.
func SplitIntoParagraphs ¶
SplitIntoParagraphs breaks text into logical paragraphs based on blank lines. It trims whitespace and removes empty paragraphs from the result.
func SplitIntoSentences ¶
SplitIntoSentences divides text into individual sentences while preserving punctuation. It uses the neurosnap/sentences package which implements the Punkt algorithm for unsupervised multilingual sentence boundary detection.
func StripXML ¶
StripXML strips all XML tags the agent might have added to the message. It uses a regex to find all the tags and remove them.
func Substitute ¶
Substitute replaces all the placeholders in the message with the actual values.
Types ¶
This section is empty.