toolcalls

package
v0.32.3 Latest Latest
Warning

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

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

Documentation

Overview

Package toolcalls is the shared, backend-neutral machinery for model-native tool calls: serializing tool definitions for the model's own chat template, and parsing the model's raw output back into structured tool calls per a profile-declared protocol. The protocol is the format the model's OWN chat template emits (model-declared), not a Contenox-invented schema — so the same model behaves identically whether served by the llama or OpenVINO backend.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownProtocol = errors.New("toolcalls: unknown tool-call protocol")

ErrUnknownProtocol is returned for a declared protocol with no registered parser.

Functions

func ParseHermes

func ParseHermes(text string) ([]modelrepo.ToolCall, string, error)

ParseHermes extracts <tool_call>{...}</tool_call> blocks (the Hermes/Qwen model-declared format) into neutral tool calls, returning the remaining visible text as content.

func ProtocolKnown

func ProtocolKnown(protocol string) bool

ProtocolKnown reports whether a protocol name has a registered parser (used by profile validation to reject typos at load time).

func SerializeToolDefs

func SerializeToolDefs(tools []modelrepo.Tool) (string, error)

SerializeToolDefs marshals neutral tool definitions to the JSON array the model's own chat template consumes. The daemon renders them model-natively; the runtime never encodes the model's tool format.

Types

type Parser

type Parser func(text string) (calls []modelrepo.ToolCall, content string, err error)

Parser extracts neutral tool calls from a model's raw output, returning the remaining visible text as content.

func ParserFor

func ParserFor(protocol string) (Parser, error)

ParserFor returns the parser for a declared protocol. A blank protocol returns (nil, nil): the caller must treat that as "tools not supported for this model".

Jump to

Keyboard shortcuts

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