utils

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneParams

func CloneParams(params map[string]interface{}) map[string]interface{}

CloneParams creates a deep copy of a parameter map.

func ConvertJSONToTyped added in v0.0.4

func ConvertJSONToTyped(jsonMap map[string]any, targetType reflect.Type) (reflect.Value, error)

ConvertJSONToTyped converts JSON map → typed struct using reflection.

func ConvertLegacyOutputsToTyped

func ConvertLegacyOutputsToTyped[T any](outputs map[string]any) (T, error)

ConvertLegacyOutputsToTyped converts map[string]any to a typed struct.

func ConvertTypedInputsToLegacy

func ConvertTypedInputsToLegacy(inputs any) (map[string]any, error)

ConvertTypedInputsToLegacy converts a typed struct to map[string]any.

func ConvertTypedOutputsToLegacy added in v0.0.4

func ConvertTypedOutputsToLegacy(output any) (map[string]any, error)

func Max

func Max(a, b int) int

Max returns the maximum of two integers.

func ParseJSONResponse

func ParseJSONResponse(response string) (map[string]interface{}, error)

ParseJSONResponse attempts to parse a string response as JSON. It handles common LLM response formats including: - Raw JSON. - JSON wrapped in markdown code blocks (```json ... ```).

func PopulateStructFromMap

func PopulateStructFromMap(structValue reflect.Value, structType reflect.Type, data map[string]any) error

PopulateStructFromMap fills a struct with values from a map.

func SetFieldValue

func SetFieldValue(fieldValue reflect.Value, value any) error

SetFieldValue sets a struct field value with type conversion.

Types

type Type added in v0.0.5

type Type string
const (
	TypeString  Type = "STRING"
	TypeInteger Type = "INTEGER"
	TypeNumber  Type = "NUMBER"
	TypeBoolean Type = "BOOLEAN"
	TypeObject  Type = "OBJECT"
	TypeArray   Type = "ARRAY"
)

type TypeSchema added in v0.0.5

type TypeSchema struct {
	AnyOf            []*TypeSchema          `json:"anyOf,omitempty"`
	Default          interface{}            `json:"default,omitempty"`
	Description      string                 `json:"description,omitempty"`
	Enum             []string               `json:"enum,omitempty"`
	Example          interface{}            `json:"example,omitempty"`
	Format           string                 `json:"format,omitempty"`
	Items            *TypeSchema            `json:"items,omitempty"`
	MaxItems         *int64                 `json:"maxItems,omitempty"`
	MaxLength        *int64                 `json:"maxLength,omitempty"`
	MaxProperties    *int64                 `json:"maxProperties,omitempty"`
	Maximum          *float64               `json:"maximum,omitempty"`
	MinItems         *int64                 `json:"minItems,omitempty"`
	MinLength        *int64                 `json:"minLength,omitempty"`
	MinProperties    *int64                 `json:"minProperties,omitempty"`
	Minimum          *float64               `json:"minimum,omitempty"`
	Nullable         *bool                  `json:"nullable,omitempty"`
	Pattern          string                 `json:"pattern,omitempty"`
	Properties       map[string]*TypeSchema `json:"properties,omitempty"`
	PropertyOrdering []string               `json:"propertyOrdering,omitempty"`
	Required         []string               `json:"required,omitempty"`
	Title            string                 `json:"title,omitempty"`
	Type             string                 `json:"type,omitempty"`
}

func BuildSchemaFromJson added in v0.0.5

func BuildSchemaFromJson(v []byte) (*TypeSchema, error)

func BuildSchemaFromStruct added in v0.0.5

func BuildSchemaFromStruct[T interface{}](t T) *TypeSchema

Jump to

Keyboard shortcuts

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