mobile

package
v1.38.1 Latest Latest
Warning

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

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

Documentation

Overview

Package mobile provides gomobile-compatible bindings for zerfoo inference.

All exported types use only gomobile-safe types (no slices, maps, or channels). Token IDs from Tokenize are returned as a JSON-encoded string.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine is an opaque handle to a loaded GGUF model. It wraps inference.Model and exposes a gomobile-safe API.

func NewEngine

func NewEngine(modelPath string) (*Engine, error)

NewEngine loads a GGUF model from the given file path and returns an Engine.

func (*Engine) Close

func (e *Engine) Close() error

Close releases all resources held by the engine.

func (*Engine) Generate

func (e *Engine) Generate(prompt string, maxTokens int) (string, error)

Generate produces text from the given prompt using default sampling parameters.

func (*Engine) GenerateWithConfig

func (e *Engine) GenerateWithConfig(prompt string, config *GenerateConfig) (string, error)

GenerateWithConfig produces text using the provided sampling configuration.

func (*Engine) Tokenize

func (e *Engine) Tokenize(text string) (string, error)

Tokenize encodes the given text into token IDs and returns them as a JSON array string (e.g. "[1,2,3]"). This avoids returning a slice, which is not supported by gomobile.

type GenerateConfig

type GenerateConfig struct {
	Temperature float64
	TopP        float64
	TopK        int
	MaxTokens   int
}

GenerateConfig holds sampling parameters for text generation. All fields use gomobile-compatible types.

Jump to

Keyboard shortcuts

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