Documentation
¶
Overview ¶
Package promptr is the runtime that generated .promptr code calls into: a minimal, provider-agnostic Provider interface plus the parse-with-repair loop that turns a model's loose reply into a typed Go value via the coerce kernel.
The compiler (cmd/promptr) turns each `function` in a .promptr file into a Go function whose body is a single call to Extract — so the generated code stays thin and readable, and all the retry/coercion logic lives here, tested once.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Extract ¶
Extract runs prompt against the provider and coerces the reply into T. If the reply will not coerce, it re-asks — appending the unparseable reply and the parse error so the model can correct itself — up to Options.Attempts times.
This is the function every generated .promptr function calls.
Types ¶
type Message ¶
Message is one turn in a chat-style exchange. Roles follow the usual "system" / "user" / "assistant" convention; a Provider maps them to whatever its backend expects.
type Options ¶
type Options struct {
// Attempts is the maximum number of model calls (default 2): the first
// try plus repair re-asks when the reply will not coerce into T.
Attempts int
// System, when non-empty, is prepended as a system message.
System string
}
Options tunes an Extract call.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
promptr
command
Command promptr compiles .promptr schema files into Go.
|
Command promptr compiles .promptr schema files into Go. |
|
Package codegen turns a parsed .promptr File into idiomatic Go source.
|
Package codegen turns a parsed .promptr File into idiomatic Go source. |
|
Package coerce is a schema-aligned parser: it turns the loose, near-JSON text that language models actually emit into typed Go values.
|
Package coerce is a schema-aligned parser: it turns the loose, near-JSON text that language models actually emit into typed Go values. |
|
Package dsl lexes and parses the .promptr schema language into an AST.
|
Package dsl lexes and parses the .promptr schema language into an AST. |
|
examples
|
|
|
ticket
Package ticket is an end-to-end promptr example: a .promptr schema compiled to Go (ticket.promptr.go) and exercised against the fake provider in ticket_test.go.
|
Package ticket is an end-to-end promptr example: a .promptr schema compiled to Go (ticket.promptr.go) and exercised against the fake provider in ticket_test.go. |
|
providers
|
|
|
anthropic
Package anthropic is a promptr.Provider backed by the Anthropic Messages API, built on net/http alone — no vendor SDK, in keeping with promptr's zero-SDK core.
|
Package anthropic is a promptr.Provider backed by the Anthropic Messages API, built on net/http alone — no vendor SDK, in keeping with promptr's zero-SDK core. |
|
fake
Package fake is a deterministic promptr.Provider for tests, examples and the playground — no network, no API key.
|
Package fake is a deterministic promptr.Provider for tests, examples and the playground — no network, no API key. |