dshgo

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 17 Imported by: 1 module, 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 dshgo embeds omnix's model, event and tool interfaces in a bounded, cancellable desktop conversation. It starts no process or server.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBusy   = errors.New("assistant: a turn is already running")
	ErrClosed = errors.New("assistant: conversation is closed")
	ErrLimit  = errors.New("assistant: turn or context limit reached")
)

Functions

This section is empty.

Types

type Conversation

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

Conversation serializes turns and owns bounded in-memory history. API keys belong to the adapter and are never included in History or event logs.

func New

func New(o Options) (*Conversation, error)

New creates a conversation without network traffic or background goroutines.

func (*Conversation) Cancel

func (c *Conversation) Cancel()

Cancel cancels the current turn, if any, without blocking the UI thread.

func (*Conversation) Close

func (c *Conversation) Close() error

Close prevents new turns and cancels current work. Cooperative tools unwind asynchronously; Close never waits for a tool which might need the UI thread.

func (*Conversation) History

func (c *Conversation) History() []llm.Message

History returns an independent JSON-compatible copy of completed turns.

func (*Conversation) Reset

func (c *Conversation) Reset() error

Reset discards history when idle.

func (*Conversation) Run

func (c *Conversation) Run(parent context.Context, input string, emit func(Event)) (out Result, err error)

Run performs a bounded model/tool loop. Call it from a worker goroutine. Only a successfully completed turn is committed; errors return partial output.

type DeepSeek

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

DeepSeek implements dsh-go's LLMAdapter with native function-call messages.

func NewDeepSeek

func NewDeepSeek(o DeepSeekOptions) (*DeepSeek, error)

NewDeepSeek creates an adapter without making a request. Supplied clients retain their transport and timeout, but redirects are refused to protect keys.

func (*DeepSeek) Chat

func (d *DeepSeek) Chat(ctx context.Context, r llm.ChatRequest, cb func(llm.StreamChunk)) (usage llm.Usage, err error)

Chat maps dsh-go's content blocks to the provider's native tool-call protocol. In particular tool results are separate role=tool messages, never plain text.

func (*DeepSeek) Name

func (*DeepSeek) Name() string

type DeepSeekOptions

type DeepSeekOptions struct {
	APIKey, BaseURL string
	Client          *http.Client
}

DeepSeekOptions configures the Go HTTP/SSE adapter. BaseURL may point to a compatible local model server. HTTPS is required except for loopback hosts.

type Event

type Event struct {
	Kind    string
	Text    string
	Tool    string
	CallID  string
	IsError bool
}

Event reports incremental text and tool activity. Emit runs synchronously on Run's caller goroutine: use Window.Update before changing native UI state. Callbacks may call Cancel, but must not reenter Run or History.

type HTTPError

type HTTPError struct{ StatusCode int }

HTTPError reports status without copying provider response bodies or secrets.

func (*HTTPError) Error

func (e *HTTPError) Error() string

type Options

type Options struct {
	Adapter       llm.LLMAdapter
	Model, System string
	Tools         []Tool
	// Approve runs on the turn's worker, before executing a protected tool.
	// A nil callback denies protected tools. It must respect cancellation.
	Approve func(context.Context, llm.ToolCall) (bool, error)

	MaxSteps, MaxToolCalls, MaxTokens, MaxTurnBytes, MaxHistoryBytes, HistoryTurns int
	Timeout                                                                        time.Duration
}

Options is copied by New. The adapter must serialize callbacks within Chat and return only after its callbacks finish; adapters and tools must honor ctx.

type Result

type Result struct {
	Text   string
	Usage  llm.Usage
	Steps  int
	Events []session.SessionEvent
}

Result includes a per-turn omnix event log, suitable for explicit persistence. Failed turns are not added to conversation history; tools may already have run.

type Tool

type Tool struct {
	Name, Description string
	Parameters        map[string]any
	Execute           tools.ToolExecuteFunc
	RequiresApproval  bool
}

Tool exposes an explicitly registered Go function to the model. No shell, file access, desktop automation or other authority is registered implicitly.

Directories

Path Synopsis
Package native provides a reusable Forma chat panel, rendered entirely in Go.
Package native provides a reusable Forma chat panel, rendered entirely in Go.

Jump to

Keyboard shortcuts

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