Documentation
¶
Index ¶
- Constants
- type Bool
- type Float
- type Integer
- type LorePosition
- func (l *LorePosition) MarshalJSON() ([]byte, error)
- func (l *LorePosition) OnArray(arrayValue []any)
- func (l *LorePosition) OnBool(boolValue bool)
- func (l *LorePosition) OnFloat(floatValue float64)
- func (l *LorePosition) OnNull()
- func (l *LorePosition) OnObject(objectValue map[string]any)
- func (l *LorePosition) OnString(stringValue string)
- func (l *LorePosition) SetIfPropertyPtr(value *LorePosition)
- func (l *LorePosition) SetIfPtr(value *int)
- func (l *LorePosition) UnmarshalJSON(data []byte) error
- type LorePositionParser
- type Role
- func (r *Role) MarshalJSON() ([]byte, error)
- func (r *Role) OnArray(arrayValue []any)
- func (r *Role) OnBool(boolValue bool)
- func (r *Role) OnFloat(floatValue float64)
- func (r *Role) OnNull()
- func (r *Role) OnObject(objectValue map[string]any)
- func (r *Role) OnString(stringValue string)
- func (r *Role) SetIfPropertyPtr(value *Role)
- func (r *Role) SetIfPtr(value *int)
- func (r *Role) UnmarshalJSON(data []byte) error
- type RoleParser
- type SelectiveLogic
- func (s *SelectiveLogic) MarshalJSON() ([]byte, error)
- func (s *SelectiveLogic) OnArray(arrayValue []any)
- func (s *SelectiveLogic) OnBool(boolValue bool)
- func (s *SelectiveLogic) OnFloat(floatValue float64)
- func (s *SelectiveLogic) OnNull()
- func (s *SelectiveLogic) OnObject(objectValue map[string]any)
- func (s *SelectiveLogic) OnString(stringValue string)
- func (s *SelectiveLogic) SetIfPropertyPtr(value *SelectiveLogic)
- func (s *SelectiveLogic) SetIfPtr(value *int)
- func (s *SelectiveLogic) UnmarshalJSON(data []byte) error
- type SelectiveLogicParser
- type String
- func (s *String) MarshalJSON() ([]byte, error)
- func (s *String) NormalizeSymbols()
- func (s *String) OnComplex(complex any)
- func (s *String) OnNull()
- func (s *String) OnValue(value any)
- func (s *String) SetIf(value string)
- func (s *String) SetIfProperty(value String)
- func (s *String) SetIfPropertyPtr(value *String)
- func (s *String) SetIfPtr(value *string)
- func (s *String) UnmarshalJSON(data []byte) error
- type StringArray
- func (s *StringArray) MarshalJSON() ([]byte, error)
- func (s *StringArray) OnArray(arrayValue []any)
- func (s *StringArray) OnBool(boolValue bool)
- func (s *StringArray) OnFloat(floatValue float64)
- func (s *StringArray) OnNull()
- func (s *StringArray) OnObject(objectValue map[string]any)
- func (s *StringArray) OnString(stringValue string)
- func (s *StringArray) UnmarshalJSON(data []byte) error
- type StringMap
- func (m *StringMap) MarshalJSON() ([]byte, error)
- func (m *StringMap) OnArray(arrayValue []any)
- func (m *StringMap) OnBool(boolValue bool)
- func (m *StringMap) OnFloat(floatValue float64)
- func (m *StringMap) OnNull()
- func (m *StringMap) OnObject(objectValue map[string]any)
- func (m *StringMap) OnString(stringValue string)
- func (m *StringMap) UnmarshalJSON(data []byte) error
- type Union
- func (u *Union) MarshalJSON() ([]byte, error)
- func (u *Union) OnArray(arrayValue []any)
- func (u *Union) OnBool(boolValue bool)
- func (u *Union) OnFloat(floatValue float64)
- func (u *Union) OnNull()
- func (u *Union) OnObject(objectValue map[string]any)
- func (u *Union) OnString(stringValue string)
- func (u *Union) UnmarshalJSON(data []byte) error
Constants ¶
const ( SystemRole Role = iota UserRole AssistantRole RoleStart = SystemRole RoleEnd = AssistantRole DefaultRole = SystemRole )
Role constants
const ( SelectiveAndAny SelectiveLogic = iota // Starts at 0 SelectiveNotAll SelectiveNotAny SelectiveAndAll SelectiveLogicStart = SelectiveAndAny // SelectiveLogicStart - Start Value for SelectiveLogic (inclusive) SelectiveLogicEnd = SelectiveAndAll // SelectiveLogicEnd - End Value for SelectiveLogic (inclusive) DefaultSelectiveLogic = SelectiveAndAny // DefaultSelectiveLogic is SelectiveAndAny )
SelectiveLogic values
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bool ¶
type Bool bool
Bool represents a boolean value
func (*Bool) MarshalJSON ¶
MarshalJSON marshals the Bool to JSON using Sonic
func (*Bool) OnComplex ¶
OnComplex is a no-op for Bool, as it is not a complex type NOTE: The original value is preserved
func (*Bool) OnNull ¶
func (b *Bool) OnNull()
OnNull no-op for Bool, as it cannot be null NOTE: The original value is preserved
func (*Bool) OnValue ¶
OnValue populates the Bool with the given value (converts to bool if possible) NOTE: The original value is preserved, if input cannot be converted to bool
func (*Bool) SetIfPropertyPtr ¶
SetIfPropertyPtr updates the Bool if the value is not nil
func (*Bool) UnmarshalJSON ¶
UnmarshalJSON unmarshals JSON data into the Bool using Sonic
type Float ¶
type Float float64
Float represents a float value
func (*Float) MarshalJSON ¶
MarshalJSON marshals the Float to JSON using Sonic
func (*Float) OnComplex ¶
OnComplex is a no-op for Float, as it is not a complex type NOTE: The original value is preserved
func (*Float) OnNull ¶
func (f *Float) OnNull()
OnNull no-op for Float, as it cannot be null NOTE: The original value is preserved
func (*Float) OnValue ¶
OnValue populates the Float with the given value (converts to float64 if possible) NOTE: The original value is preserved, if input cannot be converted to float64
func (*Float) SetIfPropertyPtr ¶
SetIfPropertyPtr updates the Float if the value is not nil
func (*Float) UnmarshalJSON ¶
UnmarshalJSON unmarshals JSON data into the Float using Sonic
type Integer ¶
type Integer int
Integer represents an integer value
func (*Integer) MarshalJSON ¶
MarshalJSON marshals the Integer to JSON using Sonic
func (*Integer) OnComplex ¶
OnComplex is a no-op for Integer, as it is not a complex type NOTE: The original value is preserved
func (*Integer) OnNull ¶
func (i *Integer) OnNull()
OnNull no-op for Integer, as it cannot be null NOTE: The original value is preserved
func (*Integer) OnValue ¶
OnValue populates the Integer with the given value (converts to int if possible) NOTE: The original value is preserved, if input cannot be converted to int
func (*Integer) SetIfPropertyPtr ¶
SetIfPropertyPtr updates the Integer if the value is not nil
func (*Integer) UnmarshalJSON ¶
UnmarshalJSON unmarshals JSON data into the Integer using Sonic
type LorePosition ¶
type LorePosition int
LorePosition represents the position of a book entry in the Lorebook
const ( BeforeCharPosition LorePosition = iota AfterCharPosition BeforeAuthorNotes AfterAuthorNotes AtDepth BeforeExampleMessages AfterExampleMessages LorePositionStart = BeforeCharPosition LorePositionEnd = AfterExampleMessages DefaultLorePosition = BeforeCharPosition // DefaultLorePosition is BeforeCharPosition )
LorePosition constants
func (*LorePosition) MarshalJSON ¶
func (l *LorePosition) MarshalJSON() ([]byte, error)
MarshalJSON marshals the LorePosition to JSON using Sonic
func (*LorePosition) OnArray ¶
func (l *LorePosition) OnArray(arrayValue []any)
OnArray is a no-op for LorePosition, as it is not a complex type (sets default value)
func (*LorePosition) OnBool ¶
func (l *LorePosition) OnBool(boolValue bool)
OnBool converts the bool value to an integer and sets the LorePosition to the corresponding value
func (*LorePosition) OnFloat ¶
func (l *LorePosition) OnFloat(floatValue float64)
OnFloat converts the float value to an integer and sets the LorePosition to the corresponding value
func (*LorePosition) OnNull ¶
func (l *LorePosition) OnNull()
OnNull sets the LorePosition to the default value
func (*LorePosition) OnObject ¶
func (l *LorePosition) OnObject(objectValue map[string]any)
OnObject is a no-op for LorePosition, as it is not a complex type (sets default value)
func (*LorePosition) OnString ¶
func (l *LorePosition) OnString(stringValue string)
OnString converts the string value to an integer and sets the LorePosition to the corresponding value If the conversion fails, the LorePosition is set to the parsed string value (numeric values have priority over string values)
func (*LorePosition) SetIfPropertyPtr ¶
func (l *LorePosition) SetIfPropertyPtr(value *LorePosition)
SetIfPropertyPtr updates the LorePosition if the value is not nil
func (*LorePosition) SetIfPtr ¶
func (l *LorePosition) SetIfPtr(value *int)
SetIfPtr updates the LorePosition if the value is not nil
func (*LorePosition) UnmarshalJSON ¶
func (l *LorePosition) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals JSON data into the LorePosition using Sonic
type LorePositionParser ¶
type LorePositionParser interface {
FromString(value string) LorePosition
FromInt(value int) LorePosition
}
LorePositionParser API to parse string/int into a valid LorePosition
func LorePositionProp ¶
func LorePositionProp() LorePositionParser
LorePositionProp returns the global LorePositionParser instance
type Role ¶
type Role int
Role represents the role of a character in a book
func (*Role) MarshalJSON ¶
MarshalJSON marshals the Role to JSON using Sonic
func (*Role) OnArray ¶
OnArray is a no-op for Role, as it is not a complex type (sets default value)
func (*Role) OnBool ¶
OnBool converts the bool value to an integer and sets the Role to the corresponding value
func (*Role) OnFloat ¶
OnFloat converts the float value to an integer and sets the Role to the corresponding value
func (*Role) OnObject ¶
OnObject is a no-op for Role, as it is not a complex type (sets default value)
func (*Role) OnString ¶
OnString converts the string value to an integer and sets the Role to the corresponding value If the conversion fails, the Role is set to the parsed string value (numeric values have priority over string values)
func (*Role) SetIfPropertyPtr ¶
SetIfPropertyPtr updates the Role if the value is not blank or nil
func (*Role) UnmarshalJSON ¶
UnmarshalJSON unmarshals JSON data into the Role using Sonic
type RoleParser ¶
RoleParser API to parse string/int into a valid Role
type SelectiveLogic ¶
type SelectiveLogic int
SelectiveLogic represents the selective logic of a book entry
func (*SelectiveLogic) MarshalJSON ¶
func (s *SelectiveLogic) MarshalJSON() ([]byte, error)
MarshalJSON marshals the SelectiveLogic to JSON using Sonic
func (*SelectiveLogic) OnArray ¶
func (s *SelectiveLogic) OnArray(arrayValue []any)
OnArray is a no-op for SelectiveLogic, as it is not a complex type (sets default value)
func (*SelectiveLogic) OnBool ¶
func (s *SelectiveLogic) OnBool(boolValue bool)
OnBool converts the bool value to an integer and sets the SelectiveLogic to the corresponding value
func (*SelectiveLogic) OnFloat ¶
func (s *SelectiveLogic) OnFloat(floatValue float64)
OnFloat converts the float value to an integer and sets the SelectiveLogic to the corresponding value
func (*SelectiveLogic) OnNull ¶
func (s *SelectiveLogic) OnNull()
OnNull sets the SelectiveLogic to the default value
func (*SelectiveLogic) OnObject ¶
func (s *SelectiveLogic) OnObject(objectValue map[string]any)
OnObject is a no-op for SelectiveLogic, as it is not a complex type (sets default value)
func (*SelectiveLogic) OnString ¶
func (s *SelectiveLogic) OnString(stringValue string)
OnString converts the string value to an integer and sets the SelectiveLogic to the corresponding value If the conversion fails, the SelectiveLogic is set to the parsed string value (numeric values have priority over string values)
func (*SelectiveLogic) SetIfPropertyPtr ¶
func (s *SelectiveLogic) SetIfPropertyPtr(value *SelectiveLogic)
SetIfPropertyPtr updates the SelectiveLogic if the value is not blank or nil
func (*SelectiveLogic) SetIfPtr ¶
func (s *SelectiveLogic) SetIfPtr(value *int)
SetIfPtr updates the selectivr logic if the value is not blank or nil
func (*SelectiveLogic) UnmarshalJSON ¶
func (s *SelectiveLogic) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals JSON data into the SelectiveLogic using Sonic
type SelectiveLogicParser ¶
type SelectiveLogicParser interface {
FromString(value string) SelectiveLogic
FromInt(value int) SelectiveLogic
}
SelectiveLogicParser API to parse string/int into a valid SelectiveLogic
func SelectiveLogicProp ¶
func SelectiveLogicProp() SelectiveLogicParser
SelectiveLogicProp returns the global SelectiveLogicParser instance
type String ¶
type String string
String represents a string value
func (*String) MarshalJSON ¶
MarshalJSON marshals the String to JSON using Sonic
func (*String) NormalizeSymbols ¶
func (s *String) NormalizeSymbols()
NormalizeSymbols normalizes the symbols in the String
func (*String) OnComplex ¶
OnComplex populates the String with the JSON representation of the complex value
func (*String) SetIfProperty ¶
SetIfProperty updates the String if the value is not blank
func (*String) SetIfPropertyPtr ¶
SetIfPropertyPtr updates the String if the value is not blank or nil
func (*String) UnmarshalJSON ¶
UnmarshalJSON unmarshals JSON data into the String using Sonic
type StringArray ¶
type StringArray []string
StringArray represents an array of strings
func (*StringArray) MarshalJSON ¶
func (s *StringArray) MarshalJSON() ([]byte, error)
MarshalJSON marshals the StringArray to JSON using Sonic
func (*StringArray) OnArray ¶
func (s *StringArray) OnArray(arrayValue []any)
OnArray populates the StringArray with the array values converted to strings
func (*StringArray) OnBool ¶
func (s *StringArray) OnBool(boolValue bool)
OnBool populates the StringArray with a single string containing the bool value
func (*StringArray) OnFloat ¶
func (s *StringArray) OnFloat(floatValue float64)
OnFloat populates the StringArray with a single string containing the float value
func (*StringArray) OnNull ¶
func (s *StringArray) OnNull()
OnNull populates the StringArray with a nil array
func (*StringArray) OnObject ¶
func (s *StringArray) OnObject(objectValue map[string]any)
OnObject populates the StringArray with a single string containing the JSON representation of the object
func (*StringArray) OnString ¶
func (s *StringArray) OnString(stringValue string)
OnString populates the StringArray with a single string containing the string value
func (*StringArray) UnmarshalJSON ¶
func (s *StringArray) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals JSON data into the StringArray using Sonic
type StringMap ¶ added in v1.0.76
StringMap represents a string-keyed map of arbitrary values.
Some legacy SillyTavern card exporters serialize empty maps as the literal string "", as null, or as an empty array [] instead of the canonical {}. Sonic's strict struct decoder rejects those — this type implements a lenient Entity that accepts any of those shapes and falls back to an empty map.
func (*StringMap) MarshalJSON ¶ added in v1.0.76
MarshalJSON marshals the StringMap to JSON using Sonic
func (*StringMap) OnArray ¶ added in v1.0.76
OnArray populates the StringMap with an empty map (an array cannot represent a map)
func (*StringMap) OnBool ¶ added in v1.0.76
OnBool populates the StringMap with an empty map (a bool cannot represent a map)
func (*StringMap) OnFloat ¶ added in v1.0.76
OnFloat populates the StringMap with an empty map (a number cannot represent a map)
func (*StringMap) OnNull ¶ added in v1.0.76
func (m *StringMap) OnNull()
OnNull populates the StringMap with an empty map (consistent with other On* handlers — keeps the unmarshal→marshal round trip stable so a nil/null/""/[] always serializes back as the canonical {})
func (*StringMap) OnObject ¶ added in v1.0.76
OnObject populates the StringMap with the given object value
func (*StringMap) OnString ¶ added in v1.0.76
OnString populates the StringMap with an empty map (a string cannot represent a map)
func (*StringMap) UnmarshalJSON ¶ added in v1.0.76
UnmarshalJSON unmarshals JSON data into the StringMap using Sonic
type Union ¶
Union represents a union of integer and string values
func (*Union) MarshalJSON ¶
MarshalJSON marshals the Union to JSON using the provided encoder
func (*Union) OnNull ¶
func (u *Union) OnNull()
OnNull populates the Union with a null value (zero value)
func (*Union) UnmarshalJSON ¶
UnmarshalJSON unmarshals JSON data into the Union using the provided decoder