Documentation
¶
Overview ¶
Package pack provides internal pack loading functionality.
Package pack provides internal pack loading functionality.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateAgainstSchema ¶
ValidateAgainstSchema validates pack JSON data against the PromptPack schema. It uses the $schema URL from the pack if present, otherwise uses the embedded schema. The PROMPTKIT_SCHEMA_SOURCE environment variable can override this behavior:
- "local": Always use embedded schema (default, for offline support)
- "remote": Always fetch from URL
- file path: Load schema from local file
Returns nil if validation passes, or a SchemaValidationError with details.
Types ¶
type LoadOptions ¶
type LoadOptions struct {
// SkipSchemaValidation disables JSON schema validation during load.
// Default is false (validation enabled).
SkipSchemaValidation bool
}
LoadOptions configures pack loading behavior.
type MediaConfig ¶
type MediaConfig struct {
AllowedTypes []string `json:"allowed_types,omitempty"`
MaxSize int `json:"max_size,omitempty"`
}
MediaConfig represents media/multimodal configuration.
type Pack ¶
type Pack struct {
// Identity
ID string `json:"id"`
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description"`
// Prompts - Map of prompt name -> Prompt
Prompts map[string]*Prompt `json:"prompts"`
// Tools - Map of tool name -> Tool
Tools map[string]*Tool `json:"tools,omitempty"`
// Fragments - Map of fragment name -> content
Fragments map[string]string `json:"fragments,omitempty"`
// FilePath is the path from which this pack was loaded.
FilePath string `json:"-"`
}
Pack represents a loaded prompt pack. This is the SDK's view of a pack, optimized for runtime use.
func Load ¶
func Load(path string, opts ...LoadOptions) (*Pack, error)
Load loads a pack from a JSON file. By default, the pack is validated against the PromptPack JSON schema. Use LoadOptions to customize behavior.
func (*Pack) ListPrompts ¶
ListPrompts returns all prompt names in the pack.
func (*Pack) ToPromptRegistry ¶
ToPromptRegistry creates a prompt.Registry from the pack. This allows the SDK to use the same PromptAssemblyMiddleware as Arena.
func (*Pack) ToToolRepository ¶
func (p *Pack) ToToolRepository() *memory.ToolRepository
ToToolRepository creates a memory.ToolRepository from the pack. This allows the SDK to use the same tools.Registry as Arena.
type Parameters ¶
type Parameters struct {
Temperature *float64 `json:"temperature,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
TopK *int `json:"top_k,omitempty"`
}
Parameters represents model parameters.
type Prompt ¶
type Prompt struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Version string `json:"version"`
SystemTemplate string `json:"system_template"`
Variables []Variable `json:"variables,omitempty"`
Tools []string `json:"tools,omitempty"`
ToolPolicy *ToolPolicy `json:"tool_policy,omitempty"`
MediaConfig *MediaConfig `json:"media,omitempty"`
Parameters *Parameters `json:"parameters,omitempty"`
Validators []Validator `json:"validators,omitempty"`
ModelOverrides map[string]any `json:"model_overrides,omitempty"`
}
Prompt represents a prompt definition within a pack.
type SchemaValidationError ¶
type SchemaValidationError struct {
Errors []string
}
SchemaValidationError represents a schema validation error with details.
func (*SchemaValidationError) Error ¶
func (e *SchemaValidationError) Error() string
type Tool ¶
type Tool struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters any `json:"parameters"`
}
Tool represents a tool definition.
type ToolPolicy ¶
type ToolPolicy struct {
ToolChoice string `json:"tool_choice,omitempty"`
MaxRounds int `json:"max_rounds,omitempty"`
MaxToolCallsPerTurn int `json:"max_tool_calls_per_turn,omitempty"`
Blocklist []string `json:"blocklist,omitempty"`
}
ToolPolicy represents tool usage policy.