markup

package
v1.833.376 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package markup lifts a model's tool calls out of assistant text.

A model writes a tool call in its own markup — DeepSeek's DSML or its fenced form, Qwen's and Hermes's <tool_call> JSON. The stack serving the model turns that markup into structured tool_calls, and when it misses (the model wrote prose first, then the block) the markup arrives as content and the caller never sees a call. Lift and Scanner do that parse here.

A call is lifted only when its name is one the request offered, and a block with any invalid invoke is left as the text it arrived as: this never invents a call.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	ID        string
	Name      string
	Arguments string
}

Call is one lifted tool call. Arguments is a JSON object, encoded.

func Lift

func Lift(content string, offered map[string]bool) (string, []Call)

Lift returns content with its tool-call blocks removed and the calls they held. Content with no liftable block is returned as it came.

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner is Lift over a stream of content deltas. Text passes through as soon as it cannot be the start of a block; from the first byte that could begin one, the scanner holds until it can decide. Whitespace beside a lifted block is dropped, so the text a stream yields equals the text Lift returns, whatever the split.

func NewScanner

func NewScanner(offered map[string]bool) *Scanner

NewScanner returns a scanner lifting calls named in offered.

func (*Scanner) Feed

func (s *Scanner) Feed(delta string) (string, []Call)

Feed takes the next delta and returns the text now known to be text, and the calls completed by it.

func (*Scanner) Flush

func (s *Scanner) Flush() string

Flush ends the stream and returns whatever was held that never became a call.

func (*Scanner) Held

func (s *Scanner) Held() bool

Held reports whether the scanner is keeping text back.

Jump to

Keyboard shortcuts

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