property

package
v1.0.76 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SystemRole Role = iota
	UserRole
	AssistantRole
	RoleStart   = SystemRole
	RoleEnd     = AssistantRole
	DefaultRole = SystemRole
)

Role constants

View Source
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

func (b *Bool) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Bool to JSON using Sonic

func (*Bool) OnComplex

func (b *Bool) OnComplex(complex any)

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

func (b *Bool) OnValue(value any)

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

func (b *Bool) SetIfPropertyPtr(value *Bool)

SetIfPropertyPtr updates the Bool if the value is not nil

func (*Bool) SetIfPtr

func (b *Bool) SetIfPtr(value *bool)

SetIfPtr updates the Bool if the value is not nil

func (*Bool) UnmarshalJSON

func (b *Bool) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals JSON data into the Bool using Sonic

type Float

type Float float64

Float represents a float value

func (*Float) MarshalJSON

func (f *Float) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Float to JSON using Sonic

func (*Float) OnComplex

func (f *Float) OnComplex(complex any)

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

func (f *Float) OnValue(value any)

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

func (f *Float) SetIfPropertyPtr(value *Float)

SetIfPropertyPtr updates the Float if the value is not nil

func (*Float) SetIfPtr

func (f *Float) SetIfPtr(value *float64)

SetIfPtr updates the Float if the value is not nil

func (*Float) UnmarshalJSON

func (f *Float) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals JSON data into the Float using Sonic

type Integer

type Integer int

Integer represents an integer value

func (*Integer) MarshalJSON

func (i *Integer) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Integer to JSON using Sonic

func (*Integer) OnComplex

func (i *Integer) OnComplex(complex any)

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

func (i *Integer) OnValue(value any)

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

func (i *Integer) SetIfPropertyPtr(value *int)

SetIfPropertyPtr updates the Integer if the value is not nil

func (*Integer) SetIfPtr

func (i *Integer) SetIfPtr(value *int)

SetIfPtr updates the Integer if the value is not nil

func (*Integer) UnmarshalJSON

func (i *Integer) UnmarshalJSON(data []byte) error

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

func (r *Role) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Role to JSON using Sonic

func (*Role) OnArray

func (r *Role) OnArray(arrayValue []any)

OnArray is a no-op for Role, as it is not a complex type (sets default value)

func (*Role) OnBool

func (r *Role) OnBool(boolValue bool)

OnBool converts the bool value to an integer and sets the Role to the corresponding value

func (*Role) OnFloat

func (r *Role) OnFloat(floatValue float64)

OnFloat converts the float value to an integer and sets the Role to the corresponding value

func (*Role) OnNull

func (r *Role) OnNull()

OnNull sets the Role to the default value

func (*Role) OnObject

func (r *Role) OnObject(objectValue map[string]any)

OnObject is a no-op for Role, as it is not a complex type (sets default value)

func (*Role) OnString

func (r *Role) OnString(stringValue string)

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

func (r *Role) SetIfPropertyPtr(value *Role)

SetIfPropertyPtr updates the Role if the value is not blank or nil

func (*Role) SetIfPtr

func (r *Role) SetIfPtr(value *int)

SetIfPtr updates the role if the value is not blank or nil

func (*Role) UnmarshalJSON

func (r *Role) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals JSON data into the Role using Sonic

type RoleParser

type RoleParser interface {
	FromString(value string) Role
	FromInt(value int) Role
}

RoleParser API to parse string/int into a valid Role

func RoleProp

func RoleProp() RoleParser

RoleProp returns the global RoleParser instance

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

func (s *String) MarshalJSON() ([]byte, error)

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

func (s *String) OnComplex(complex any)

OnComplex populates the String with the JSON representation of the complex value

func (*String) OnNull

func (s *String) OnNull()

OnNull populates the String with an empty string

func (*String) OnValue

func (s *String) OnValue(value any)

OnValue populates the String with the value converted to a string

func (*String) SetIf

func (s *String) SetIf(value string)

SetIf updates the String if the value is not blank

func (*String) SetIfProperty

func (s *String) SetIfProperty(value String)

SetIfProperty updates the String if the value is not blank

func (*String) SetIfPropertyPtr

func (s *String) SetIfPropertyPtr(value *String)

SetIfPropertyPtr updates the String if the value is not blank or nil

func (*String) SetIfPtr

func (s *String) SetIfPtr(value *string)

SetIfPtr updates the String if the value is not blank or nil

func (*String) UnmarshalJSON

func (s *String) UnmarshalJSON(data []byte) error

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

type StringMap map[string]any

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

func (m *StringMap) MarshalJSON() ([]byte, error)

MarshalJSON marshals the StringMap to JSON using Sonic

func (*StringMap) OnArray added in v1.0.76

func (m *StringMap) OnArray(arrayValue []any)

OnArray populates the StringMap with an empty map (an array cannot represent a map)

func (*StringMap) OnBool added in v1.0.76

func (m *StringMap) OnBool(boolValue bool)

OnBool populates the StringMap with an empty map (a bool cannot represent a map)

func (*StringMap) OnFloat added in v1.0.76

func (m *StringMap) OnFloat(floatValue float64)

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 a nil map

func (*StringMap) OnObject added in v1.0.76

func (m *StringMap) OnObject(objectValue map[string]any)

OnObject populates the StringMap with the given object value

func (*StringMap) OnString added in v1.0.76

func (m *StringMap) OnString(stringValue string)

OnString populates the StringMap with an empty map (a string cannot represent a map)

func (*StringMap) UnmarshalJSON added in v1.0.76

func (m *StringMap) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals JSON data into the StringMap using Sonic

type Union

type Union struct {
	IntValue    *int
	StringValue *string
}

Union represents a union of integer and string values

func (*Union) MarshalJSON

func (u *Union) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Union to JSON using the provided encoder

func (*Union) OnArray

func (u *Union) OnArray(arrayValue []any)

OnArray populates the Union with a string value from an array

func (*Union) OnBool

func (u *Union) OnBool(boolValue bool)

OnBool populates the Union with an integer value from a bool

func (*Union) OnFloat

func (u *Union) OnFloat(floatValue float64)

OnFloat populates the Union with an integer value from a float64

func (*Union) OnNull

func (u *Union) OnNull()

OnNull populates the Union with a null value (zero value)

func (*Union) OnObject

func (u *Union) OnObject(objectValue map[string]any)

OnObject populates the Union with a string value from an object

func (*Union) OnString

func (u *Union) OnString(stringValue string)

OnString populates the Union with a string value from a string

func (*Union) UnmarshalJSON

func (u *Union) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals JSON data into the Union using the provided decoder

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL