modelcontract

package
v1.0.0-rc.14 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 9 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

Index

Constants

View Source
const CompletionFormatSchemaFile = "completion_formats.json"

Variables

This section is empty.

Functions

func FIMFingerprint

func FIMFingerprint(name string) (string, error)

func FIMFormats

func FIMFormats() []string

func NextEditFingerprint

func NextEditFingerprint(format string) (string, error)

func NextEditFormats

func NextEditFormats() []string

func TokenizeFIM

func TokenizeFIM(input AutocompleteInput, tokenize func(string, bool) ([]int, error)) ([]int, []int, error)

func TokenizeParts

func TokenizeParts(parts []TextPart, stops []string, tokenize func(string, bool) ([]int, error)) ([]int, []int, error)

func TokenizerCompanionControls

func TokenizerCompanionControls(operation, format string) (int, []string, error)

func ValidateEdits

func ValidateEdits(input NextEditInput, edits []TextEdit) error

Types

type AutocompleteInput

type AutocompleteInput struct {
	Format string `json:"format"`
	Prefix string `json:"prefix"`
	Suffix string `json:"suffix"`
}

type ContextFile

type ContextFile struct {
	Path string `json:"path"`
	Text string `json:"text"`
}

type EditHistory

type EditHistory struct {
	Path   string `json:"path"`
	Before string `json:"before"`
	After  string `json:"after"`
}

type FIMFormat

type FIMFormat struct {
	ID      string
	Version int
	Kind    string
	Prefix  string
	Suffix  string
	Middle  string
	Stops   []string
}

func ResolveFIM

func ResolveFIM(name string) (FIMFormat, error)

func (FIMFormat) Render

func (f FIMFormat) Render(prefix, suffix string) string

type NextEditInput

type NextEditInput struct {
	Path    string        `json:"path"`
	Before  string        `json:"before"`
	Current string        `json:"current"`
	Cursor  int           `json:"cursor"`
	Start   int           `json:"start"`
	End     int           `json:"end"`
	History []EditHistory `json:"history"`
	Context []ContextFile `json:"context"`
}

func (NextEditInput) Validate

func (i NextEditInput) Validate() error

type NextEditProfile

type NextEditProfile struct {
	ID            string
	Version       int
	ContextTokens int
	MaxTokens     int
	Stops         []string
	TextStops     []string
}

func ResolveNextEdit

func ResolveNextEdit(format string) (NextEditProfile, error)

type PreparedEdit

type PreparedEdit struct {
	Parts     []TextPart
	Prefill   string
	Stops     []string
	TextStops []string
	// contains filtered or unexported fields
}

func PrepareNextEdit

func PrepareNextEdit(format string, input NextEditInput) (PreparedEdit, error)

func (PreparedEdit) EndpointStops

func (p PreparedEdit) EndpointStops() []string

func (PreparedEdit) Parse

func (p PreparedEdit) Parse(output, finishReason string) ([]TextEdit, error)

func (PreparedEdit) Render

func (p PreparedEdit) Render() string

type TextDecoder

type TextDecoder struct {
	Stops   []string
	Stopped bool
	// contains filtered or unexported fields
}

func (*TextDecoder) Push

func (d *TextDecoder) Push(piece string, final bool) (string, error)

type TextEdit

type TextEdit struct {
	Start   int    `json:"start"`
	End     int    `json:"end"`
	OldText string `json:"oldText"`
	NewText string `json:"newText"`
}

type TextPart

type TextPart struct {
	Text    string
	Control bool
}

Jump to

Keyboard shortcuts

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