Help us shape the future of Go! Take the 2026 Go Developer Survey

schema

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectRequiredFields

func CollectRequiredFields(properties map[string]*gollem.Parameter) []string

CollectRequiredFields returns a list of required property names in ascending name order. The order must not depend on Go map iteration: the result is emitted verbatim as the JSON Schema "required" array, and Anthropic matches the prompt cache on an exact byte prefix that starts with the tool definitions, so a reordered array invalidates every cache breakpoint.

func ConvertParameterToJSONSchema

func ConvertParameterToJSONSchema(param *gollem.Parameter) map[string]any

ConvertParameterToJSONSchema converts gollem.Parameter to JSON Schema map This is the base conversion without provider-specific modifications

func ConvertParameterToJSONString

func ConvertParameterToJSONString(param *gollem.Parameter) (string, error)

ConvertParameterToJSONString converts Parameter to a JSON Schema string This is used by Claude for embedding schema in system prompt

func FindAdditionalProperties added in v0.30.0

func FindAdditionalProperties(param *gollem.Parameter) (path string, found bool)

FindAdditionalProperties returns the path of the first object that has AdditionalProperties (a map), visiting properties in ascending name order so that the result does not depend on map iteration. The path joins property names with "." and marks array items with "[]", e.g. "items[].attrs"; the root itself is reported as "(root)".

Providers use it to decide how to send a schema: Claude structured outputs and OpenAI strict mode reject a schema that contains a map, and Gemini sends such a schema as JSON Schema because genai.Schema cannot express a map.

Types

This section is empty.

Jump to

Keyboard shortcuts

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