prompt

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 7 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 prompt separates what a user wrote from what they pasted.

A prompt like "<300 lines of log> why does auth time out?" is mostly pasted material; the intent is the last line. Capturing it verbatim and truncating would keep the log and lose the question. Split keeps the user's own words intact and turns large pasted blocks (code fences, quotes, logs and stack traces) into attachment records: kind, size, hash, a head+tail excerpt and the error lines, which is what retrieval needs.

Index

Constants

View Source
const (
	// MinBlockBytes is the smallest pasted block worth extracting; shorter
	// snippets stay inline because they are usually part of the question.
	MinBlockBytes = 400
)

Variables

This section is empty.

Functions

func OwnWords

func OwnWords(raw string) string

OwnWords is the user's own text: the split prompt without the placeholders that stand in for pasted blocks.

func Payload

func Payload(raw string) map[string]any

Payload renders a split prompt into event payload fields.

func ShouldRecall added in v0.1.4

func ShouldRecall(q string) bool

ShouldRecall allows compact Han queries such as "死锁" or "证书过期" while keeping acknowledgements and bare continuation prompts off the network. Latin-only input retains the existing six-letter/digit minimum.

func StripPlaceholders

func StripPlaceholders(text string) string

StripPlaceholders removes pasted-block placeholders from split text.

Types

type Attachment

type Attachment struct {
	Kind    string   `json:"kind"` // code | log | quote | image | pasted
	Lang    string   `json:"lang,omitempty"`
	Bytes   int      `json:"bytes,omitempty"`
	Lines   int      `json:"lines,omitempty"`
	SHA256  string   `json:"sha256,omitempty"`
	Excerpt string   `json:"excerpt,omitempty"`
	Errors  []string `json:"errors,omitempty"`
	Ref     string   `json:"ref,omitempty"` // placeholder or path the agent used
}

Attachment describes pasted or attached material that is not stored in full. Media content is never stored, only its metadata.

type Result

type Result struct {
	// Text is the prompt with large pasted blocks replaced by placeholders.
	Text        string
	Attachments []Attachment
}

Result is a split prompt.

func Split

func Split(s string) Result

Split extracts large pasted blocks from a prompt.

Jump to

Keyboard shortcuts

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