Documentation
¶
Overview ¶
Package utils provides general-purpose utilities for JSON handling and panic recovery.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrRecoveredPanic is returned when a panic is recovered and converted to an error. ErrRecoveredPanic = errors.New("recovered panic") // ErrCouldNotRepairJSON is returned when malformed JSON cannot be automatically fixed. ErrCouldNotRepairJSON = errors.New("malformed JSON could not be repaired") )
var ErrInvalidStringSetValue = errors.New("invalid string-set value")
ErrInvalidStringSetValue indicates invalid StringSet definition.
Functions ¶
func JSONFromMarkdown ¶
JSONFromMarkdown extracts JSON content from a given Markdown string. If a JSON block is found, it returns the JSON content as a string. If no JSON block is found, it returns the original content.
func NoPanic ¶
NoPanic executes the provided function and recovers from any panic by converting it to error if that occurs.
func RepairTextJSON ¶
RepairTextJSON attempts to repair common issues with plain-text JSON generated by LLMs. If the input is already valid JSON, it is returned as-is.
Types ¶
type StringSet ¶ added in v0.2.0
type StringSet struct {
// contains filtered or unexported fields
}
StringSet represents a set of unique string values.
func NewStringSet ¶ added in v0.2.0
NewStringSet creates a new StringSet from the given items, discarding duplicates.
func (StringSet) Any ¶ added in v0.2.0
Any returns true if any value in the set satisfies the given condition.
func (StringSet) Map ¶ added in v0.2.0
Map returns a new StringSet with f applied to each value, discarding duplicates.
func (StringSet) MarshalYAML ¶ added in v0.2.0
MarshalYAML implements YAML marshaling for StringSet.
func (*StringSet) UnmarshalYAML ¶ added in v0.2.0
UnmarshalYAML allows StringSet to be loaded from either a string or a list of strings.