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

patch

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperationAdd     = "add"
	OperationReplace = "replace"
	OperationRemove  = "remove"
)
View Source
const DefaultUpdateFormSystemPromptTemplate = `` /* 2466-byte string literal not displayed */

DefaultUpdateFormSystemPromptTemplate is the default system prompt template used by ToolBasedPatchGenerator. The template may contain a single "%s" placeholder for the tool name.

Variables

This section is empty.

Functions

func ApplyRFC6902

func ApplyRFC6902[T any](current T, ops []Operation) (T, error)

Types

type Generator

type Generator[T any] interface {
	GeneratePatch(ctx context.Context, req *types.ToolRequest[T]) (*UpdateFormArgs, error)
}

type GeneratorOption added in v0.0.2

type GeneratorOption[T any] func(*patchGeneratorOptions[T])

func WithPatchPromptBuilder added in v0.0.3

func WithPatchPromptBuilder[T any](promptBuilder PromptBuilder[T]) GeneratorOption[T]

func WithPatchSystemPromptTemplate added in v0.0.2

func WithPatchSystemPromptTemplate[T any](systemPromptTemplate string) GeneratorOption[T]

type Operation

type Operation struct {
	Op          string `json:"op" jsonschema:"enum=add,enum=replace,enum=remove,description=RFC6902 operation type (add, replace, remove)"`
	Path        string `json:"path" jsonschema:"pattern=^/.*$,description=RFC6902 JSON Pointer, must start with '/'"`
	Value       any    `json:"value,omitempty" jsonschema:"description=Value to apply for add/replace operations (optional for remove)"`
	Description string `json:"description,omitempty" jsonschema:"description=Description of the operation, Defaults to empty string"`
}

func FixOperation added in v0.0.3

func FixOperation(currentJSON []byte, ops []Operation) []Operation

type PromptBuilder added in v0.0.3

type PromptBuilder[T any] func(systemPrompt string) func(ctx context.Context, req *types.ToolRequest[T]) ([]*schema.Message, error)

type ToolBasedPatchGenerator

type ToolBasedPatchGenerator[T any] struct {
	Chain *structured.Chain[*types.ToolRequest[T], UpdateFormArgs]
}

func NewToolBasedPatchGenerator

func NewToolBasedPatchGenerator[T any](chatModel model.ToolCallingChatModel, opts ...GeneratorOption[T]) (*ToolBasedPatchGenerator[T], error)

func (*ToolBasedPatchGenerator[T]) GeneratePatch

func (g *ToolBasedPatchGenerator[T]) GeneratePatch(ctx context.Context, req *types.ToolRequest[T]) (*UpdateFormArgs, error)

type UpdateFormArgs

type UpdateFormArgs struct {
	Ops []Operation `json:"ops" jsonschema:"description=Array of RFC6902 JSON Patch operations to update the form"`
}

Jump to

Keyboard shortcuts

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