Documentation
¶
Overview ¶
Package ds4 provides Go-native conveniences for the ds4 inference engine.
The lower-level github.com/NimbleMarkets/ds4go/ds4api package is the strict purego wrapper around ds4.h. This package owns runtime policy such as default paths, friendly diagnostics, and small convenience entry points.
Index ¶
- Constants
- Variables
- func AppendPromptPrefix(engine *Engine, tokens *Tokens, turns []PromptPrefixTurn) error
- func ApplyMTPDefaults(opts *EngineOptions)
- func ApplyVisionDefaults(opts *EngineOptions)
- func CheckBackend(lib *ds4api.Library, backend Backend) error
- func CheckGPUArch(path string) error
- func DSparkSupportPath(modelPath string) (path string, required bool)
- func DefaultDir() string
- func DefaultLibraryDir() string
- func DefaultLibraryPath() string
- func DefaultMTPPath() string
- func DefaultModelPath() string
- func DefaultModelsDir() string
- func DefaultVisionPath(modelPath string) string
- func DiscardLogs() error
- func EngineHolders(modelsDir string) (map[int][]string, error)
- func EnrichEngineOpenError(err error) error
- func IsVisionEncoderMissing(err error) bool
- func Load(path string) (*ds4api.Library, error)
- func NewEngine(opts ds4api.EngineOptions) (*ds4api.Engine, error)
- func ResolveModelPath(value string) string
- func SetAbortFunc(fn AbortFunc) error
- func SetDefaultLibrary(lib *ds4api.Library)
- func SetStderr(f *os.File) error
- func SetStderrFd(fd int) error
- func ToolSyntax(engine *Engine) dsml.Syntax
- type AbortFunc
- type ArgmaxGenerateOptions
- type Backend
- type BackendMismatchError
- type CancelFunc
- type ChatMessage
- type ContentPart
- type ContextMemory
- type DecodeItem
- type Engine
- type EngineOptions
- type GPUArchError
- type GPUFlavor
- type GenerateOptions
- type GenerationDoneFunc
- type Generator
- func (g Generator) Continue(opts GenerateOptions) ([]int, error)
- func (g Generator) Generate(prompt []int, opts GenerateOptions) ([]int, error)
- func (g Generator) GeneratePrompt(p *Prompt, opts GenerateOptions) ([]int, error)
- func (g Generator) GenerateString(prompt string, opts GenerateOptions) (string, error)
- func (g Generator) GenerateTokens(prompt *ds4api.Tokens, opts GenerateOptions) ([]int, error)
- type ImageEncoder
- type ImageInput
- type Library
- type LogType
- type ModelInfo
- type MultimodalTool
- type MultimodalToolHandler
- type ProcessInfo
- type ProgressFunc
- type Prompt
- type PromptPrefixTurn
- type Session
- type SessionRewriteResult
- type StderrCapture
- type ThinkMode
- type TokenEmitFunc
- type TokenScore
- type Tokens
- type Tool
- type ToolCall
- type ToolFunc
- type ToolHandler
- type ToolLoop
- func (l ToolLoop) CompletePrompt(prompt *Prompt, opts GenerateOptions, onEvent func(dsml.StreamEvent)) (string, error)
- func (l ToolLoop) CompleteTurn(prompt *Tokens, opts GenerateOptions, onEvent func(dsml.StreamEvent)) (string, error)
- func (l ToolLoop) Run(opts ToolLoopOptions) (ToolLoopResult, error)
- type ToolLoopOptions
- type ToolLoopResult
- type ToolRegistry
- func (r *ToolRegistry) BuildPrompt(engine *Engine, system string, history []ChatMessage, think ThinkMode) (*Tokens, error)
- func (r *ToolRegistry) BuildPromptMultimodal(engine *Engine, images *ImageEncoder, system string, history []ChatMessage, ...) (*Prompt, error)
- func (r *ToolRegistry) ExecuteToolCalls(ctx context.Context, calls []ToolCall) ([]ChatMessage, error)
- func (r *ToolRegistry) MustRegister(handler ToolHandler)
- func (r *ToolRegistry) ParseAssistant(text string, thinking bool) (ChatMessage, error)
- func (r *ToolRegistry) ParseAssistantSyntax(syntax dsml.Syntax, text string, thinking bool) (ChatMessage, error)
- func (r *ToolRegistry) Register(handler ToolHandler) error
- func (r *ToolRegistry) RegisterFunc(schema ToolSchema, fn ToolFunc) error
- func (r *ToolRegistry) RenderToolsSection() (string, error)
- func (r *ToolRegistry) RenderToolsSectionSyntax(syntax dsml.Syntax) (string, error)
- func (r *ToolRegistry) ReplayStore() *dsml.ReplayStore
- func (r *ToolRegistry) Schemas() []ToolSchema
- func (r *ToolRegistry) SetReplayStore(store *dsml.ReplayStore)
- type ToolResult
- type ToolSchema
Examples ¶
Constants ¶
const ( // DefaultTemperature is ds4's default sampling temperature. DefaultTemperature = ds4api.DefaultTemperature // DefaultTopP is ds4's default nucleus sampling probability. DefaultTopP = ds4api.DefaultTopP // DefaultMinP is ds4's default minimum relative-probability filter. DefaultMinP = ds4api.DefaultMinP // BackendMetal selects the Metal backend. BackendMetal = ds4api.BackendMetal // BackendCUDA selects the CUDA backend. BackendCUDA = ds4api.BackendCUDA // BackendROCm selects a ROCm build of libds4. It is a Go-only value that // crosses the ABI as DS4_BACKEND_CUDA, which ROCm builds serve; engine // open rejects it on a library that is not ROCm. BackendROCm = ds4api.BackendROCm // BackendCPU selects the CPU reference backend. BackendCPU = ds4api.BackendCPU // GPUFlavorUnknown means the library's GPU slot name was not recognized. GPUFlavorUnknown = ds4api.GPUFlavorUnknown // GPUFlavorCUDA means the library is not a ROCm build. GPUFlavorCUDA = ds4api.GPUFlavorCUDA // GPUFlavorROCm means the library is a ROCm build. GPUFlavorROCm = ds4api.GPUFlavorROCm // ThinkNone disables thinking markers in chat prompts. ThinkNone = ds4api.ThinkNone // ThinkHigh enables ordinary high-effort thinking. ThinkHigh = ds4api.ThinkHigh // ThinkMax requests maximum-effort thinking. ds4 may downgrade it to // ThinkHigh when the context is below ThinkMaxMinContext. ThinkMax = ds4api.ThinkMax // ThinkLow is the OpenAI "low" / "minimal" effort (Qwen3.8's brief // thinking; High elsewhere). ThinkLow = ds4api.ThinkLow // ThinkMedium is the OpenAI "medium" effort (no instruction on Qwen3.8). ThinkMedium = ds4api.ThinkMedium // ThinkLevelBase offsets explicit V4.1 reasoning effort (ThinkLevel). ThinkLevelBase = ds4api.ThinkLevelBase // SessionRewriteError means the rewrite failed. SessionRewriteError = ds4api.SessionRewriteError // SessionRewriteOK means the rewrite completed in place. SessionRewriteOK = ds4api.SessionRewriteOK // SessionRewriteRebuildNeeded means the caller should restore or rebuild // the session state. SessionRewriteRebuildNeeded = ds4api.SessionRewriteRebuildNeeded // LogDefault is the default ds4 log style. LogDefault = ds4api.LogDefault // LogPrefill marks prefill messages. LogPrefill = ds4api.LogPrefill // LogGeneration marks generation messages. LogGeneration = ds4api.LogGeneration // LogKVCache marks KV-cache messages. LogKVCache = ds4api.LogKVCache // LogTool marks tool-calling messages. LogTool = ds4api.LogTool // LogWarning marks warnings. LogWarning = ds4api.LogWarning // LogTiming marks timing messages. LogTiming = ds4api.LogTiming // LogOK marks successful status messages. LogOK = ds4api.LogOK // LogError marks errors. LogError = ds4api.LogError // DefaultMTPDraftTokens is the default number of draft tokens speculative // decoding generates per step when MTP is enabled. A value of 0 disables // speculative decoding; set it explicitly to enable MTP. DefaultMTPDraftTokens = 0 // DefaultMTPMargin is the default minimum margin (in tokens) between the // draft model's accepted sequence and the full target model output. DefaultMTPMargin = 3 )
const ( DefaultImageCacheEntries = 32 DefaultImageCacheBytes = int64(128 << 20) )
Cache defaults, matching upstream ds4-server's image cache.
const MaxHTTPImages = 256
MaxHTTPImages is the per-request image cap upstream ds4-server applies to its HTTP APIs. Servers built on ds4go enforce it over the whole message list; ParseOpenAIContent only parses one message.
Variables ¶
var ( // ErrCancelNotSupported is returned when session cancellation is unavailable. ErrCancelNotSupported = ds4api.ErrCancelNotSupported // ErrSessionSyncInterrupted is returned when session sync is cooperatively interrupted. ErrSessionSyncInterrupted = ds4api.ErrSessionSyncInterrupted )
var ErrCompleteFuncCannotCarryImages = errors.New("ds4go: CompleteFunc takes a token prompt and cannot carry images")
ErrCompleteFuncCannotCarryImages is returned when CompleteFunc is set and the history has image parts: the override takes tokens only, and silently dropping the images would change the model's input.
var ErrContextFull = errors.New("ds4go: session context full")
ErrContextFull is returned when a session has no room left in its context window. When generation is capped by the remaining room, it is returned alongside the tokens produced before the limit was reached.
var ErrImagesNeedMultimodalPrompt = errors.New("ds4go: history contains images; build the prompt with BuildChatPromptMultimodal")
ErrImagesNeedMultimodalPrompt is returned by the text-only prompt builders when a message carries image parts; use BuildChatPromptMultimodal.
Functions ¶
func AppendPromptPrefix ¶ added in v0.7.0
func AppendPromptPrefix(engine *Engine, tokens *Tokens, turns []PromptPrefixTurn) error
AppendPromptPrefix renders turns into tokens the way upstream's inline ds4_prompt_prefix_append does: each turn through ChatAppendMessage, and a DeepSeek assistant turn closed with EOS (GLM's template closes its own).
func ApplyMTPDefaults ¶ added in v0.2.2
func ApplyMTPDefaults(opts *EngineOptions)
ApplyMTPDefaults populates MTPPath, MTPDraftTokens, and MTPMargin with sensible defaults when an MTP model is installed. GLM models suppress the external MTP path because their optional predictor is embedded in the base GGUF, and Qwen3.8 for the same reason. DeepSeek V4.1 models keep an explicit MTPPath (their own DSpark support GGUF) but never receive the installed default, which libds4 rejects for them. A model that pins its own DSpark drafter (see DSparkSupportPath) gets that drafter or none at all, never the standard MTP model. For other model families, only empty or zero fields are filled, so explicit caller settings are respected.
func ApplyVisionDefaults ¶ added in v0.7.0
func ApplyVisionDefaults(opts *EngineOptions)
ApplyVisionDefaults fills EngineOptions.VisionPath with the installed encoder paired to a catalog vision model. An explicit VisionPath wins.
func CheckBackend ¶ added in v0.9.0
CheckBackend reports whether lib can serve backend before any model is loaded. BackendROCm on a library that is not ROCm returns a *BackendMismatchError; BackendCUDA on a ROCm library is still accepted for one transition release with a deprecation warning (see ds4api.Library.CheckBackend). For a ROCm library it also runs CheckGPUArch, so a ROCm request gets both the flavor and the GPU architecture check. Library.NewEngine repeats the flavor check, and Load the architecture check; this is the early, combined form for callers that want to fail before opening an engine.
func CheckGPUArch ¶ added in v0.9.0
CheckGPUArch returns a *GPUArchError when the library at path is a ROCm build and none of the host's AMD GPUs is among the architectures it was compiled for. Without the check, the mismatch only surfaces as an "invalid device function" error on the first kernel launch.
The library's list is read from the file itself (the ds4_rocm_offload_archs symbol, else the HIP fat binary), falling back to the rocm_archs field of a ds4go-install.json beside it. Host GPUs come from HSA_OVERRIDE_GFX_VERSION, rocminfo, or the KFD sysfs topology. The check never blocks when either list is unknown, for non-ROCm libraries, or when DS4_SKIP_GPU_ARCH_CHECK is set. The file is only read, never loaded.
func DSparkSupportPath ¶ added in v0.7.0
DSparkSupportPath reports the DSpark drafter a catalog-recognized model pins. required is true when the catalog entry names its own DSpark support model (the Vision-Exp checkpoints do); libds4 rejects every other drafter for such a model, including the standard 0731 one. path is that drafter's installed file under the models dir, or "" when it is not installed. Text-only, GLM, and unrecognized models return ("", false).
func DefaultDir ¶
func DefaultDir() string
DefaultDir returns the ds4go data directory.
DS4_DIR overrides the default. When DS4_DIR is unset, DefaultDir returns "$HOME/.ds4" when the user home directory can be determined, otherwise ".ds4".
The ".ds4" fallback is relative to the working directory and is used only for data (models, config, scratch). It is never used to locate libds4: DefaultLibraryDir returns "" and DefaultLibraryPath skips the DS4_DIR/lib candidate in that case, because loading a shared library from a working-directory-relative path is the binary-planting vector described at DefaultLibraryPath. A shared location such as os.TempDir would be no better, since another local user can pre-create it. Set DS4_DIR to load a library when no home directory is available.
func DefaultLibraryDir ¶
func DefaultLibraryDir() string
DefaultLibraryDir returns the directory where libds4 is installed by default: the "lib" subdirectory of DefaultDir.
It returns "" when neither DS4_DIR nor a home directory is available, since the library is never searched relative to the working directory (see DefaultDir and DefaultLibraryPath).
func DefaultLibraryPath ¶
func DefaultLibraryPath() string
DefaultLibraryPath returns the preferred libds4 shared-library path, or "" when none is installed.
Search order is DS4_LIB, DS4_DIR/lib, then executable-local paths.
The current working directory is deliberately NOT searched: loading a shared library from the CWD would let an attacker who can write a file into a directory the user happens to run ds4go from plant a malicious libds4 and gain code execution (binary planting). For the same reason a bare library name is never returned for the OS loader to resolve: dyld and Windows LoadLibrary both search the working directory for a leaf name, and the DS4_DIR/lib candidate is skipped when DefaultDir would fall back to the working-directory-relative ".ds4" (no DS4_DIR and no home directory). Use DS4_LIB or DS4_DIR to load a library from a non-default location.
func DefaultMTPPath ¶ added in v0.2.2
func DefaultMTPPath() string
DefaultMTPPath returns the path to the installed MTP companion model, or empty string if it is not present.
func DefaultModelPath ¶
func DefaultModelPath() string
DefaultModelPath returns the path to the default model symlink.
The default model is a symlink at $DS4_DIR/models/<DefaultModelSymlink> that points to the active downloaded model. Use ds4go model set to switch it.
func DefaultModelsDir ¶ added in v0.4.0
func DefaultModelsDir() string
DefaultModelsDir returns the directory where downloaded models are stored: the "models" subdirectory of DefaultDir.
func DefaultVisionPath ¶ added in v0.7.0
DefaultVisionPath returns the installed encoder for a catalog-recognized vision model, or "" when the model is text-only or its encoder is absent.
func DiscardLogs ¶ added in v0.3.0
func DiscardLogs() error
DiscardLogs redirects libds4's diagnostic output to the null device for the default library. The native stderr is restored by SetStderr(nil).
Not supported on Windows; see SetStderrFd.
func EngineHolders ¶ added in v0.4.0
EngineHolders returns a map of process PIDs to the list of model files they are currently running. If modelsDir is empty, it uses the default models directory. To ensure security, queries are restricted to paths within authorized directories (DefaultDir or executable directory).
func EnrichEngineOpenError ¶
EnrichEngineOpenError adds process names to ds4 engine-open errors that mention lock-holder PIDs.
func IsVisionEncoderMissing ¶ added in v0.7.0
IsVisionEncoderMissing reports whether err is libds4 refusing images because no encoder is available: "vision encoder is not loaded" (the model was opened without EngineOptions.VisionPath, i.e. CLI --vision) or "model does not support image messages", its other image refusal. Both mean the same thing to a caller: the prompt carries images this engine cannot see.
func Load ¶
Load loads libds4 using ds4go's runtime path policy.
Passing an empty path searches DS4_LIB, DS4_DIR/lib, and executable-local library locations. The current working directory is not searched and a bare name is never handed to the OS loader; see DefaultLibraryPath.
For a ROCm build, Load first compares the GPU architectures the library was compiled for with the host's AMD GPUs and returns a *GPUArchError when none matches; see CheckGPUArch.
func NewEngine ¶
func NewEngine(opts ds4api.EngineOptions) (*ds4api.Engine, error)
NewEngine loads the default libds4 shared library and opens a ds4 engine.
func ResolveModelPath ¶ added in v0.8.0
ResolveModelPath maps an installed catalog alias (for example "vision-q2") to its GGUF file under DefaultModelsDir. File paths, unknown aliases, and aliases that are not installed are returned unchanged so callers can validate them and report an appropriate error. It never downloads models.
func SetAbortFunc ¶ added in v0.3.0
SetAbortFunc installs a last-chance libds4 fatal-invariant callback.
libds4 invokes the callback after logging the fatal message and immediately before native abort(). Passing nil restores the default behavior. This hook is process-global inside libds4 and is intended for crash telemetry, flushing logs, or deliberate process termination; returning from the callback does not recover the engine.
func SetDefaultLibrary ¶
SetDefaultLibrary makes lib the low-level package default library.
ds4api owns the one authoritative default; this package keeps no copy, so setting it here or through ds4api.SetDefaultLibrary is equivalent.
func SetStderr ¶ added in v0.5.0
SetStderr redirects libds4's diagnostic output to f for the default library. Passing nil restores the native stderr.
libds4 dups the descriptor internally and writes its diagnostics there unbuffered, so f may be closed once it is no longer the active target. The redirect target is process-global inside libds4; install it once at startup, before generation is active. Calling Fd on f detaches it from the Go runtime poller and puts it in blocking mode, so do not pass a file you also use for asynchronous I/O.
Not supported on Windows; see SetStderrFd.
func SetStderrFd ¶ added in v0.5.0
SetStderrFd redirects libds4's diagnostic output to the file descriptor fd for the default library. Pass -1 to restore the native stderr.
libds4 dups fd internally and writes its diagnostics there unbuffered, so the caller may close its own descriptor after this call. The redirect target is process-global inside libds4; install it once at startup, before generation.
func ToolSyntax ¶ added in v0.6.0
ToolSyntax reports the tool-call markup grammar an engine's model uses, mirroring upstream ds4's agent_tool_syntax_for_engine: GLM DSA emits its <tool_call> markup, Qwen3.8 its <tool_call><function=...> XML, V4.1 the spaced DSML dialect, and everything else DeepSeek DSML.
Types ¶
type AbortFunc ¶ added in v0.3.0
AbortFunc receives a libds4 fatal-invariant message immediately before abort.
type ArgmaxGenerateOptions ¶ added in v0.3.0
type ArgmaxGenerateOptions = ds4api.ArgmaxGenerateOptions
ArgmaxGenerateOptions controls ds4_engine_generate_argmax.
type Backend ¶
Backend selects the accelerator implementation compiled into libds4.
func DetectDefaultBackend ¶ added in v0.5.0
DetectDefaultBackend probes the environment and installation metadata to determine the preferred backend for the shared library at libPath.
Passing an empty string probes using the default library path. When the result is a GPU backend and the process default library is the one at that path, the library's own GPUFlavor decides between BackendCUDA and BackendROCm instead of the host guess; see DetectLibraryBackend.
func DetectLibraryBackend ¶ added in v0.9.0
DetectLibraryBackend returns the preferred backend for a loaded library: the DetectDefaultBackend guess for its path, with a GPU guess replaced by what the library actually serves (BackendROCm for a ROCm build, otherwise BackendCUDA). Metal and CPU guesses are kept.
type BackendMismatchError ¶ added in v0.9.0
type BackendMismatchError = ds4api.BackendMismatchError
BackendMismatchError reports a CUDA/ROCm request the library cannot serve.
type CancelFunc ¶ added in v0.5.1
type CancelFunc = ds4api.CancelFunc
CancelFunc is polled by ds4 at cooperative cancellation points.
type ChatMessage ¶ added in v0.3.0
type ChatMessage struct {
// Role is "system", "user", "assistant", or "tool".
Role string
// Content is the plain text content for the message.
Content string
// Parts is the ordered multimodal content of a user or tool message:
// text and images interleaved. When non-empty it replaces Content for
// prompt rendering. Only user and tool messages may carry images.
Parts []ContentPart
// ReasoningContent is the assistant reasoning block when thinking mode is enabled.
ReasoningContent string
// ToolCalls is the assistant's requested tool calls for this turn.
ToolCalls []ToolCall
// ToolCallID associates a tool result message with the call it answers.
// DSML does not render this ID into <tool_result>; prompt builders expect
// tool result messages to be ordered to match the assistant's ToolCalls.
ToolCallID string
// MalformedReason is the parse failure that degraded an assistant tool
// stanza to plain content, and is empty for clean turns. ToolLoop uses it
// to send the model a syntax-error retry turn.
MalformedReason string
}
ChatMessage is one tool-aware chat turn.
type ContentPart ¶ added in v0.7.0
type ContentPart struct {
Text string
Image *ImageInput
}
ContentPart is one segment of a multimodal message: text or an image.
func ParseOpenAIContent ¶ added in v0.7.0
func ParseOpenAIContent(raw json.RawMessage) (text string, parts []ContentPart, err error)
ParseOpenAIContent decodes an OpenAI chat message's "content" field. A JSON string (or null/absent) is returned as text. An array of parts yields text when every part is text (joined by newlines), or ordered ContentParts when any part is an image. As in upstream ds4-server, images must be inline PNG or JPEG data URIs; remote URLs and file paths are rejected.
type ContextMemory ¶ added in v0.3.0
type ContextMemory = ds4api.ContextMemory
ContextMemory is ds4_context_memory.
type DecodeItem ¶ added in v0.12.0
type DecodeItem = ds4api.DecodeItem
DecodeItem advances an independent session in Engine.EvalBatch.
type EngineOptions ¶
type EngineOptions = ds4api.EngineOptions
EngineOptions configures ds4_engine_open.
type GPUArchError ¶ added in v0.9.0
type GPUArchError = rocmarch.MismatchError
GPUArchError reports that a ROCm libds4 was not compiled for any AMD GPU architecture present on this host. Its message names both lists and the rebuild command.
type GPUFlavor ¶ added in v0.9.0
GPUFlavor names what a libds4 build serves behind DS4_BACKEND_CUDA.
type GenerateOptions ¶
type GenerateOptions struct {
// MaxTokens is the maximum number of tokens to generate.
MaxTokens int
// Temperature controls sampling. Values <= 0 use argmax.
Temperature float32
// TopK limits sampling to the best k tokens when Temperature > 0.
TopK int
// TopP applies nucleus sampling when Temperature > 0.
TopP float32
// MinP applies minimum probability sampling when Temperature > 0.
MinP float32
// Seed seeds ds4's sampler. A zero seed is valid and deterministic.
Seed uint64
// StopOnEOS stops generation when ds4 emits a generation stop token. For
// DeepSeek shapes that is the engine EOS token; GLM DSA shapes also stop on
// the system, user, assistant, and observation role tokens.
StopOnEOS bool
// ThinkMode refines stop detection when StopOnEOS is set: with thinking
// disabled, a <think> or </think> marker is a protocol control token rather
// than assistant content and ends the completion. It does not otherwise
// affect generation; prompt rendering takes its own think mode.
ThinkMode ThinkMode
// ExcludeToken asks argmax generation to skip a specific token id.
ExcludeToken int
// OnToken streams generated tokens. Returning normally continues generation.
OnToken ds4api.TokenEmitFunc
// Context, when non-nil, can be cancelled to stop generation gracefully
// before the next token is sampled.
Context context.Context
// SampleControl, when non-nil, is consulted before each token is sampled.
// Returning true forces argmax (greedy) sampling for that token regardless
// of Temperature; configured Temperature>0 sampling applies otherwise. It is
// a no-op when Temperature<=0 (already argmax). Speculative decoding honours
// it too: a token it forces greedy is verified by the argmax speculative
// path, so markup structure is never sampled through.
SampleControl func() bool
// Images are the image spans of the prompt the session was synced with.
// Continue passes them to span-aware rewinds so an image-bearing session
// rebuilds through the multimodal sync. GeneratePrompt sets it from the
// prompt; callers resuming an image session through Continue set it.
Images []ds4api.VisionSpan
}
GenerateOptions controls Go-native session generation helpers.
type GenerationDoneFunc ¶ added in v0.3.0
type GenerationDoneFunc = ds4api.GenerationDoneFunc
GenerationDoneFunc is called after ds4 completes generation.
type Generator ¶
Generator binds a ds4 engine and session for Go-native generation helpers.
func (Generator) Continue ¶
func (g Generator) Continue(opts GenerateOptions) ([]int, error)
Continue generates tokens from the current session logits.
func (Generator) Generate ¶
func (g Generator) Generate(prompt []int, opts GenerateOptions) ([]int, error)
Generate synchronizes to prompt and generates tokens from the session.
func (Generator) GeneratePrompt ¶ added in v0.7.0
func (g Generator) GeneratePrompt(p *Prompt, opts GenerateOptions) ([]int, error)
GeneratePrompt synchronizes to a rendered Prompt and generates tokens from the session. With no image spans it is GenerateTokens; with spans it syncs through the multimodal path.
func (Generator) GenerateString ¶
func (g Generator) GenerateString(prompt string, opts GenerateOptions) (string, error)
GenerateString tokenizes prompt, generates, and decodes the generated text.
func (Generator) GenerateTokens ¶
GenerateTokens synchronizes to prompt and generates tokens from the session.
type ImageEncoder ¶ added in v0.7.0
type ImageEncoder struct {
// contains filtered or unexported fields
}
ImageEncoder encodes images through an engine's vision encoder and keeps an LRU cache of embeddings keyed by the image bytes. Encoding is a GPU pass, and the tool loop re-renders the prompt every round, so repeated images must not be re-encoded. Every Encode returns an independent clone; the caller frees it (or the Prompt that absorbs it).
func NewImageEncoder ¶ added in v0.7.0
func NewImageEncoder(engine *Engine) *ImageEncoder
NewImageEncoder returns an encoder over engine with the default limits.
func (*ImageEncoder) Encode ¶ added in v0.7.0
func (c *ImageEncoder) Encode(img ImageInput) (*ds4api.VisionEmbedding, error)
Encode returns an embedding for img, from the cache when the same bytes were encoded before. The result is a clone the caller owns.
func (*ImageEncoder) SetLimits ¶ added in v0.7.0
func (c *ImageEncoder) SetLimits(entries int, bytes int64)
SetLimits changes the cache bounds and evicts down to them.
func (*ImageEncoder) Stats ¶ added in v0.7.0
func (c *ImageEncoder) Stats() (entries int, bytes int64)
Stats reports the cache occupancy.
type ImageInput ¶ added in v0.7.0
ImageInput is one image for a multimodal message: encoded PNG or JPEG bytes, or a path to such a file. Exactly one of Data or Path is set.
func ImageInputJPEG ¶ added in v0.7.0
func ImageInputJPEG(img image.Image, quality int) (ImageInput, error)
ImageInputJPEG encodes img as JPEG into an ImageInput's Data. quality is 1..100; 0 selects the encoder's default (jpeg.DefaultQuality). JPEG drops alpha and fine detail, so prefer ImageInputPNG for anything with text.
func ImageInputPNG ¶ added in v0.7.0
func ImageInputPNG(img image.Image) (ImageInput, error)
ImageInputPNG encodes img as PNG into an ImageInput's Data. PNG is lossless, so it suits screenshots, diagrams, and rendered text; for large photographs ImageInputJPEG produces far fewer bytes. This is a ds4go convenience: libds4 only ingests encoded PNG or JPEG bytes.
type ModelInfo ¶ added in v0.5.1
type ModelInfo struct {
// Alias is the catalog moniker (e.g. "vision-q2").
Alias string
// Family groups catalog quantizations of the same checkpoint, for example
// "deepseek-v4-flash". Empty for companion files. Use this for selector
// grouping, not runtime capability checks.
Family string
// FileName is the real GGUF file name the entry installs as.
FileName string
// Path is the model's destination under DefaultModelsDir, even if absent.
// Check Installed before offering it as a locally available model.
Path string
// SHA256 is the pinned (or verified-at-download) content hash.
SHA256 string
// SizeGB is the curated download size.
SizeGB float64
// RecommendedRAM is the catalog's human-readable memory guidance.
RecommendedRAM string
// Imatrix reports whether this is an imatrix-tuned quant.
Imatrix bool
// Notes is the curated one-line description.
Notes string
// Installed reports a nonempty model file on disk; it does not verify its hash.
Installed bool
// Partial reports whether unfinished download data exists on disk.
Partial bool
// PartialBytes is the size of unfinished download data, including split parts.
PartialBytes int64
// Default reports whether this installed entry is the configured default chat model.
Default bool
// Legacy marks an older catalog variant.
Legacy bool
// Optional marks a companion file, such as an encoder or speculative drafter.
Optional bool
// Distributed marks a model piece requiring distributed inference.
Distributed bool
// DistributedRole is "coordinator" or "worker" for distributed pieces.
DistributedRole string
// LayerRange describes a distributed piece's layers in ds4 --layers syntax.
LayerRange string
// Vision reports image support when the matching encoder is loaded.
// It does not imply that the encoder is installed.
Vision bool
// Encoder is the matching vision encoder's catalog alias, or empty.
// Find that alias in ListModels to inspect its Path and Installed state.
Encoder string
// DSpark is a checkpoint-specific DSpark companion alias, or empty when
// there is no override. Empty does not imply DSpark support; use ApplyMTPDefaults
// to resolve companion policy for engine options.
DSpark string
// GLM identifies the GLM DSA family.
GLM bool
// DeepSeek41 identifies the DeepSeek V4.1 family.
DeepSeek41 bool
// Qwen identifies the Qwen3.8 Flash Next family (checkpoint or encoder):
// ChatML history, reasoning effort as a system-turn instruction, built-in
// speculation, and a tool-call dialect the dsml package does not yet speak.
Qwen bool
}
ModelInfo describes a curated model and its local installation state. Capability fields describe catalog metadata, not hardware compatibility or capabilities probed from a loaded engine.
func ListModels ¶ added in v0.8.0
ListModels returns a fresh snapshot of the curated catalog in catalog order, including models that are not installed. It uses DS4_DIR (default ~/.ds4), reads local configuration and file metadata, and does not load libds4, download files, or change the default model. Custom GGUFs outside the catalog are not included; applications can offer a separate file picker. A missing installation is valid; unreadable or malformed configuration is an error.
Example ¶
package main
import (
"fmt"
"log"
ds4 "github.com/NimbleMarkets/ds4go"
)
func main() {
catalog, err := ds4.ListModels()
if err != nil {
log.Print(err)
return
}
byAlias := make(map[string]ds4.ModelInfo, len(catalog))
for _, model := range catalog {
byAlias[model.Alias] = model
}
for _, model := range catalog {
if !model.Installed || !model.IsChatModel() {
continue
}
// Use Alias and Notes as labels; keep Path as the selection's value.
visionReady := model.Vision && byAlias[model.Encoder].Installed
fmt.Printf("%s: %s (default=%t, vision=%t)\n",
model.Alias, model.Notes, model.Default, visionReady)
// After selection: opts.ModelPath = model.Path; ds4.ApplyVisionDefaults(&opts).
}
}
Output:
func ResolveModelInfo ¶ added in v0.5.1
ResolveModelInfo maps a model file path back to its ds4 catalog entry. The path is matched against installed catalog models by file identity (os.SameFile), so the models/ds4flash.gguf default link — maintained as a hard link by the installer — resolves to the entry it points at, as does a direct path to the GGUF. Returns false for paths that do not stat or are not catalog-managed, or if local model configuration cannot be read.
func (ModelInfo) IsChatModel ¶ added in v0.8.0
IsChatModel reports whether this is a standalone chat checkpoint rather than a companion file or distributed piece. It does not require installation or check hardware compatibility. For a local chat selector, also check Installed.
type MultimodalTool ¶ added in v0.7.0
type MultimodalTool struct {
ToolSchema
Handler func(ctx context.Context, args json.RawMessage) (ToolResult, error)
}
MultimodalTool binds a schema to a function returning a ToolResult.
func (MultimodalTool) Invoke ¶ added in v0.7.0
func (t MultimodalTool) Invoke(ctx context.Context, args json.RawMessage) (string, error)
Invoke runs the handler and returns its text; results with images error.
func (MultimodalTool) InvokeParts ¶ added in v0.7.0
func (t MultimodalTool) InvokeParts(ctx context.Context, args json.RawMessage) (ToolResult, error)
InvokeParts runs the handler.
func (MultimodalTool) Schema ¶ added in v0.7.0
func (t MultimodalTool) Schema() ToolSchema
Schema returns the tool schema.
type MultimodalToolHandler ¶ added in v0.7.0
type MultimodalToolHandler interface {
ToolHandler
InvokeParts(ctx context.Context, args json.RawMessage) (ToolResult, error)
}
MultimodalToolHandler is a ToolHandler whose results may include images. The registry prefers InvokeParts when a handler implements it.
type ProcessInfo ¶ added in v0.4.0
ProcessInfo represents a process holding or using a ds4 resource.
func LibraryHolders ¶ added in v0.4.0
func LibraryHolders(libPath string) ([]ProcessInfo, error)
LibraryHolders returns a list of processes currently holding onto the libds4 shared library. If libPath is empty, it uses the default library path. To ensure security, queries are restricted to paths within authorized directories (DefaultDir, executable directory, or explicit DS4_LIB).
type ProgressFunc ¶ added in v0.3.0
type ProgressFunc = ds4api.ProgressFunc
ProgressFunc receives ds4 progress events.
type Prompt ¶ added in v0.7.0
type Prompt struct {
Tokens *Tokens
Images []ds4api.VisionSpan
}
Prompt is a rendered prompt: its tokens plus the image spans libds4 produced while rendering. Sync it with Generator.GeneratePrompt (or Session.SyncMultimodal). Free releases both; libds4 keeps only image identities after a sync, so a Prompt may be freed once it has been synced.
func BuildChatPromptMultimodal ¶ added in v0.7.0
func BuildChatPromptMultimodal(engine *Engine, images *ImageEncoder, system string, tools []dsml.Tool, history []ChatMessage, think ThinkMode) (*Prompt, error)
BuildChatPromptMultimodal is BuildChatPrompt for histories that may carry image parts. images encodes them (nil is allowed only when no message has images). The returned Prompt owns the tokens and spans; free it after the session has been synced.
type PromptPrefixTurn ¶ added in v0.7.0
PromptPrefixTurn is one preloaded conversation turn from a --prefix-file: Role is "user" or "assistant".
func LoadPromptPrefix ¶ added in v0.7.0
func LoadPromptPrefix(path string) ([]PromptPrefixTurn, error)
LoadPromptPrefix reads and parses a prefix file; errors name the path.
func ParsePromptPrefix ¶ added in v0.7.0
func ParsePromptPrefix(data []byte) ([]PromptPrefixTurn, error)
ParsePromptPrefix parses upstream ds4's prefix-file format (ds4_prompt_prefix.c): lines starting with "USER:" or "ASSISTANT:" open a turn, turns strictly alternate starting with USER, a turn's content runs until the next marker line, and the file must end with an ASSISTANT turn. A leading UTF-8 BOM is skipped; CRLF line ends are accepted.
type SessionRewriteResult ¶ added in v0.3.0
type SessionRewriteResult = ds4api.SessionRewriteResult
SessionRewriteResult is returned by session rewrite helpers.
type StderrCapture ¶ added in v0.5.0
type StderrCapture struct {
// contains filtered or unexported fields
}
StderrCapture pumps libds4's redirected diagnostic stream into an io.Writer until Close restores the native stderr. It is created by CaptureStderr.
func CaptureStderr ¶ added in v0.5.0
func CaptureStderr(dst io.Writer) (*StderrCapture, error)
CaptureStderr redirects libds4's diagnostic output into dst and returns a handle that restores the native stderr when closed.
dst receives the raw bytes libds4 writes — line splitting and any leveling are the caller's concern. This is the io.Writer counterpart to SetStderr, implemented with an os.Pipe and a background pump; use SetStderr directly when the sink is already a file or the null device. The redirect target is process-global inside libds4, so only one capture (or SetStderr target) is active at a time; install it once during startup, before generation. The capture retains the library it redirects, so clearing or replacing the default library does not change which library Close restores.
Not supported on Windows; see SetStderrFd. On failure no redirect is installed and the pipe is released.
func (*StderrCapture) Close ¶ added in v0.5.0
func (c *StderrCapture) Close() error
Close restores the native stderr and waits for the pump to drain. Diagnostics libds4 already wrote are flushed to dst before Close returns. Close is idempotent only in the sense that the underlying files tolerate a double close; call it exactly once per CaptureStderr.
Close restores the library captured at creation, even if the default library has since been cleared or replaced.
type ThinkMode ¶
ThinkMode controls ds4's rendered chat thinking mode.
func ParseThinkLevel ¶ added in v0.7.0
ParseThinkLevel parses --think-level text (0 to 100). See ds4api.ParseThinkLevel.
func ThinkLevel ¶ added in v0.7.0
ThinkLevel returns the ThinkMode for an explicit DeepSeek V4.1 reasoning effort, 0 (thinking off) to 100. See ds4api.ThinkLevel.
type TokenEmitFunc ¶
type TokenEmitFunc = ds4api.TokenEmitFunc
TokenEmitFunc is called when ds4 emits a generated token.
type TokenScore ¶ added in v0.3.0
type TokenScore = ds4api.TokenScore
TokenScore is ds4_token_score.
type Tokens ¶
Tokens owns a ds4_tokens value allocated by libds4.
func BuildChatPrompt ¶ added in v0.3.0
func BuildChatPrompt(engine *Engine, system string, tools []dsml.Tool, history []ChatMessage, think ThinkMode) (*Tokens, error)
BuildChatPrompt renders a tool-aware chat prompt using ds4's chat helpers.
The tools section is prepended to the system message. If system is empty and tools is non-empty, BuildChatPrompt creates a system turn containing only the rendered tools section. Tool result messages are rendered as user turns containing DSML <tool_result> blocks.
BuildChatPrompt returns ErrImagesNeedMultimodalPrompt if any message in history carries image parts; use BuildChatPromptMultimodal instead.
type Tool ¶ added in v0.3.0
type Tool struct {
ToolSchema
Handler ToolFunc
}
Tool binds a schema to a Go function.
func (Tool) Schema ¶ added in v0.3.0
func (t Tool) Schema() ToolSchema
Schema returns the tool schema.
type ToolCall ¶ added in v0.3.0
type ToolCall struct {
// ID is the stable tool-call identifier used for exact replay.
ID string
// Name is the called tool name.
Name string
// Arguments is the JSON argument object string.
Arguments string
}
ToolCall is one tool request emitted by the assistant.
type ToolHandler ¶ added in v0.3.0
type ToolHandler interface {
// Schema returns the public tool schema shown to the model.
Schema() ToolSchema
// Invoke executes the tool with the JSON arguments requested by the model.
Invoke(ctx context.Context, args json.RawMessage) (string, error)
}
ToolHandler exposes a Go tool to the model.
type ToolLoop ¶ added in v0.3.0
type ToolLoop struct {
// Engine owns token decoding and prompt rendering.
Engine *Engine
// Session is the live ds4 session used for generation.
Session *Session
// Tools stores the tool schemas, handlers, and replay state.
Tools *ToolRegistry
// ThinkMode controls ds4's assistant prefix rendering.
ThinkMode ThinkMode
// Thinking tells ParseAssistant whether to require and extract a reasoning block.
Thinking bool
// DisableThinkRecovery turns off the live recovery for tool calls started
// inside an unclosed <think> block. When recovery is active (the default
// in thinking mode), a complete stanza opening inside thinking force-feeds
// "</think>\n\n" into the session and generation resumes, letting the
// model restart the call on the executable side instead of running to the
// token limit with the call dropped at parse time.
DisableThinkRecovery bool
// CompleteFunc overrides the default generator-backed completion path.
// When nil, Run uses Generator.GenerateTokens and Engine.TokenText.
CompleteFunc func(prompt *Tokens, opts GenerateOptions) (string, error)
// Images encodes image parts in the history and tool results. When nil,
// a history containing images is an error.
Images *ImageEncoder
}
ToolLoop drives multi-turn tool calling on top of Generator and ToolRegistry.
func (ToolLoop) CompletePrompt ¶ added in v0.7.0
func (l ToolLoop) CompletePrompt(prompt *Prompt, opts GenerateOptions, onEvent func(dsml.StreamEvent)) (string, error)
CompletePrompt is CompleteTurn for a rendered Prompt. With no image spans it behaves exactly like CompleteTurn; with spans it syncs through the multimodal path. CompleteFunc cannot be used with an image prompt.
func (ToolLoop) CompleteTurn ¶ added in v0.5.1
func (l ToolLoop) CompleteTurn(prompt *Tokens, opts GenerateOptions, onEvent func(dsml.StreamEvent)) (string, error)
CompleteTurn runs one streaming assistant turn: generation is fed through a dsml.StreamDecoder, stops early once the tool block closes or the end-of-sentence marker appears, applies live think-tool recovery (unless DisableThinkRecovery), and forwards live stream events to onEvent (which may be nil). It returns the accumulated completion text. CompleteFunc, when set, overrides the generation path exactly as in Run.
This is the single-turn building block behind Run, exported for hosts that drive their own tool loop (custom execution, per-round UI events) but want the library's stream-driven recovery behaviors.
func (ToolLoop) Run ¶ added in v0.3.0
func (l ToolLoop) Run(opts ToolLoopOptions) (ToolLoopResult, error)
Run executes assistant generation, dispatches requested tools, and continues until the assistant returns a plain answer or MaxRounds is reached. A cancelled GenerateOptions.Context, a tool handler error, or a call to an unregistered tool aborts the run and is returned as an error.
type ToolLoopOptions ¶ added in v0.3.0
type ToolLoopOptions struct {
// System is the system prompt content.
System string
// History is the existing chat transcript excluding the generated assistant turn.
History []ChatMessage
// Generate controls model generation for each assistant turn.
Generate GenerateOptions
// MaxRounds bounds the total number of assistant turns — tool-calling
// rounds, malformed-tool-call retry turns, and the final answer. Values
// <= 0 default to 8.
MaxRounds int
// OnStreamEvent, when non-nil, receives live stream events (reasoning,
// content, and tool-call deltas) during each assistant turn. Tool-call
// events are delivered once the enclosing block is validated. It is not
// called when CompleteFunc overrides the generation path.
OnStreamEvent func(dsml.StreamEvent)
}
ToolLoopOptions configures one tool loop run.
type ToolLoopResult ¶ added in v0.3.0
type ToolLoopResult struct {
// History is the full updated transcript, including the final assistant turn.
History []ChatMessage
// Assistant is the final assistant message with no further tool calls.
Assistant ChatMessage
// ToolRounds is the number of assistant turns that requested tools.
ToolRounds int
}
ToolLoopResult is the final result of one tool loop run.
type ToolRegistry ¶ added in v0.3.0
type ToolRegistry struct {
// contains filtered or unexported fields
}
ToolRegistry stores Go-exposed tools and exact sampled DSML replay state.
func NewToolRegistry ¶ added in v0.3.0
func NewToolRegistry() *ToolRegistry
NewToolRegistry creates an empty tool registry with exact DSML replay enabled.
func (*ToolRegistry) BuildPrompt ¶ added in v0.3.0
func (r *ToolRegistry) BuildPrompt(engine *Engine, system string, history []ChatMessage, think ThinkMode) (*Tokens, error)
BuildPrompt renders a tool-aware chat prompt using ds4's chat helpers.
BuildPrompt returns ErrImagesNeedMultimodalPrompt if any message in history carries image parts; use BuildPromptMultimodal instead.
func (*ToolRegistry) BuildPromptMultimodal ¶ added in v0.7.0
func (r *ToolRegistry) BuildPromptMultimodal(engine *Engine, images *ImageEncoder, system string, history []ChatMessage, think ThinkMode) (*Prompt, error)
BuildPromptMultimodal is BuildPrompt for histories that may carry image parts.
func (*ToolRegistry) ExecuteToolCalls ¶ added in v0.3.0
func (r *ToolRegistry) ExecuteToolCalls(ctx context.Context, calls []ToolCall) ([]ChatMessage, error)
ExecuteToolCalls invokes the registered Go handlers for the given tool calls. It stops and returns an error if ctx is cancelled, if a call names an unregistered tool, or if a handler returns an error.
func (*ToolRegistry) MustRegister ¶ added in v0.3.0
func (r *ToolRegistry) MustRegister(handler ToolHandler)
MustRegister adds one tool handler and panics on error.
func (*ToolRegistry) ParseAssistant ¶ added in v0.3.0
func (r *ToolRegistry) ParseAssistant(text string, thinking bool) (ChatMessage, error)
ParseAssistant parses one assistant completion and assigns stable tool-call IDs.
func (*ToolRegistry) ParseAssistantSyntax ¶ added in v0.6.0
func (r *ToolRegistry) ParseAssistantSyntax(syntax dsml.Syntax, text string, thinking bool) (ChatMessage, error)
ParseAssistantSyntax is ToolRegistry.ParseAssistant for an explicit tool-call markup syntax; see ToolSyntax.
func (*ToolRegistry) Register ¶ added in v0.3.0
func (r *ToolRegistry) Register(handler ToolHandler) error
Register adds one tool handler to the registry.
func (*ToolRegistry) RegisterFunc ¶ added in v0.3.0
func (r *ToolRegistry) RegisterFunc(schema ToolSchema, fn ToolFunc) error
RegisterFunc adds one function-backed tool to the registry.
func (*ToolRegistry) RenderToolsSection ¶ added in v0.3.0
func (r *ToolRegistry) RenderToolsSection() (string, error)
RenderToolsSection renders the DSML tools section for the registered tools.
func (*ToolRegistry) RenderToolsSectionSyntax ¶ added in v0.6.0
func (r *ToolRegistry) RenderToolsSectionSyntax(syntax dsml.Syntax) (string, error)
RenderToolsSectionSyntax renders the tools section in an explicit tool-call markup syntax; see ToolSyntax.
func (*ToolRegistry) ReplayStore ¶ added in v0.3.0
func (r *ToolRegistry) ReplayStore() *dsml.ReplayStore
ReplayStore returns the exact sampled DSML replay store.
func (*ToolRegistry) Schemas ¶ added in v0.3.0
func (r *ToolRegistry) Schemas() []ToolSchema
Schemas returns the registered tool schemas in registration order.
func (*ToolRegistry) SetReplayStore ¶ added in v0.3.0
func (r *ToolRegistry) SetReplayStore(store *dsml.ReplayStore)
SetReplayStore replaces the exact sampled DSML replay store. Passing nil disables replay.
type ToolResult ¶ added in v0.7.0
type ToolResult struct {
Parts []ContentPart
}
ToolResult is a tool's multimodal output: text and image parts in order.
func (ToolResult) Text ¶ added in v0.7.0
func (r ToolResult) Text() (string, error)
Text joins the text parts; it errors if any image part is present.
type ToolSchema ¶ added in v0.3.0
type ToolSchema struct {
// Name is the tool's callable name.
Name string
// Description explains what the tool does.
Description string
// Parameters is the JSON Schema object for the tool's arguments.
Parameters json.RawMessage
}
ToolSchema describes one Go-exposed tool.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ds4api test infrastructure: a pure-Go mock of libds4.
|
Package ds4api test infrastructure: a pure-Go mock of libds4. |
|
Package dsml encodes and decodes DeepSeek DSML tool-calling markup.
|
Package dsml encodes and decodes DeepSeek DSML tool-calling markup. |
|
examples
|
|
|
chat
command
Command chat is an interactive ds4 REPL.
|
Command chat is an interactive ds4 REPL. |
|
openai-compatible
command
Command openai-compatible serves the same HTTP APIs as ds4go serve.
|
Command openai-compatible serves the same HTTP APIs as ds4go serve. |
|
simple
command
Command simple loads a ds4 model and generates one response.
|
Command simple loads a ds4 model and generates one response. |
|
toolloop
command
Command toolloop demonstrates end-to-end DSML tool calling with Go handlers.
|
Command toolloop demonstrates end-to-end DSML tool calling with Go handlers. |
|
internal
|
|
|
cliopts
Package cliopts defines the command-line flag surface shared by the ds4go CLI and examples.
|
Package cliopts defines the command-line flag surface shared by the ds4go CLI and examples. |
|
install
Package install downloads prebuilt libds4 release assets for the ds4go CLI.
|
Package install downloads prebuilt libds4 release assets for the ds4go CLI. |
|
models
Package models manages ds4go's curated model catalog.
|
Package models manages ds4go's curated model catalog. |
|
openaiserver
Package openaiserver implements the shared ds4go serve and example HTTP APIs.
|
Package openaiserver implements the shared ds4go serve and example HTTP APIs. |
|
rocmarch
Package rocmarch reports which AMD GPU architectures a ROCm libds4 build supports and which architectures the host has, without cgo and without loading the library.
|
Package rocmarch reports which AMD GPU architectures a ROCm libds4 build supports and which architectures the host has, without cgo and without loading the library. |
|
termline
Package termline redraws one status line in place on a terminal.
|
Package termline redraws one status line in place on a terminal. |
|
Package lsp is a small client for Language Server Protocol servers, built for driving generation/self-correction loops: start one persistent server, sync in-memory documents, and query diagnostics, hover, symbols, and completion.
|
Package lsp is a small client for Language Server Protocol servers, built for driving generation/self-correction loops: start one persistent server, sync in-memory documents, and query diagnostics, hover, symbols, and completion. |
|
lsptool
Package lsptool adapts an *lsp.Client into ds4go.ToolHandler values so a model running in a ds4go.ToolLoop can query a language server.
|
Package lsptool adapts an *lsp.Client into ds4go.ToolHandler values so a model running in a ds4go.ToolLoop can query a language server. |
|
Package scratchtool provides a session-scoped key/value scratchpad tool for ds4go tool loops.
|
Package scratchtool provides a session-scoped key/value scratchpad tool for ds4go tool loops. |
|
Package workspacetool provides local filesystem and shell tools for ds4go tool loops.
|
Package workspacetool provides local filesystem and shell tools for ds4go tool loops. |