Documentation
¶
Overview ¶
Package completion provides the typed runtime contract for service-owned direct assistant completions. Generated completion packages expose typed specs that this package uses to request provider-enforced structured output and decode the final assistant response through generated codecs.
Index ¶
- func DecodeChunk[T any](chunk model.Chunk, spec Spec[T]) (T, bool, error)
- func DecodeResponse[T any](resp *model.Response, spec Spec[T]) (T, error)
- func Stream[T any](ctx context.Context, client model.Client, req *model.Request, spec Spec[T]) (model.Streamer, error)
- type Ident
- type Response
- type Spec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeChunk ¶
DecodeChunk decodes the canonical final completion chunk from a typed completion stream. Non-completion chunks are ignored and return ok=false.
func DecodeResponse ¶
DecodeResponse decodes the structured assistant response with the generated typed codec from the completion spec.
func Stream ¶
func Stream[T any](ctx context.Context, client model.Client, req *model.Request, spec Spec[T]) (model.Streamer, error)
Stream starts a typed completion stream using the provided generated spec.
Streaming completions reuse the provider-neutral model.Streamer contract. The final typed value is decoded from the canonical ChunkTypeCompletion payload; completion deltas are preview-only and may be ignored.
Types ¶
type Response ¶
type Response[T any] struct { // Value is the decoded typed completion result. Value T // Raw is the original provider-agnostic model response. Raw *model.Response }
Response contains the raw model response plus the decoded typed value.
type Spec ¶
type Spec[T any] struct { // Name is the stable completion identifier declared in the DSL. Name Ident // Description provides human-readable context about the completion. Description string // Result describes the generated result schema and generic codec. Result tools.TypeSpec // Codec is the generated typed codec for the completion result. Codec tools.JSONCodec[T] }
Spec describes one generated typed completion contract.