toolschema

package
v2.11.2 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package toolschema derives LLM function-calling parameter schemas from DAG parameter definitions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(params []Param) map[string]any

Build assembles a JSON Schema object from tool parameters.

func ForDAG

func ForDAG(dag *core.DAG) (map[string]any, error)

ForDAG returns the JSON Schema describing the parameters a DAG accepts when invoked as a tool. Rich parameter definitions take precedence over the positional default-params string.

func InferTypeFromDefault

func InferTypeFromDefault(value string) (any, string)

InferTypeFromDefault infers a JSON Schema type from a default value literal, returning the decoded value alongside the type name.

func SplitParams

func SplitParams(s string) []string

SplitParams splits a param string on whitespace, respecting quotes.

Types

type Param

type Param struct {
	Name     string
	Type     string // "string", "integer", "number", "boolean", "array", "object"
	Default  any
	Required bool
}

Param is a single tool parameter.

func ParamsForDAG

func ParamsForDAG(dag *core.DAG) ([]Param, error)

ParamsForDAG lists the parameters a DAG accepts, preferring its rich definitions and falling back to its default-params string.

func ParamsFromDefs

func ParamsFromDefs(defs []core.ParamDef) []Param

ParamsFromDefs converts rich parameter definitions into tool parameters.

func ParseParams

func ParseParams(defaultParams string) ([]Param, error)

ParseParams parses a default-params string such as "param1 param2=default2 param3=10" into tool parameters. Parameters without a default are required.

Jump to

Keyboard shortcuts

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