prompts

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseArguments

func ParseArguments(arguments Arguments, args map[string]any, data map[string]map[string]any) (parameters.ParamValues, error)

ParseArguments validates and processes the user-provided arguments against the prompt's requirements.

func Register

func Register(kind string, factory PromptConfigFactory) bool

Register allows individual prompt packages to register their configuration factory function. This is typically called from an init() function in the prompt's package. It associates a 'kind' string with a function that can produce the specific PromptConfig type. It returns true if the registration was successful, and false if a prompt with the same kind was already registered.

Types

type ArgMcpManifest

type ArgMcpManifest struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Required    bool   `json:"required"`
}

ArgMcpManifest is the simplified manifest structure for an argument required for prompts.

type Argument

type Argument struct {
	parameters.Parameter
}

Argument is a wrapper around a parameters.Parameter that provides prompt-specific functionality. If the 'type' field is not specified in a YAML definition, it defaults to 'string'.

func (Argument) McpManifest

func (a Argument) McpManifest() ArgMcpManifest

McpManifest returns the simplified manifest structure required for prompts.

type Arguments

type Arguments []Argument

Arguments is a slice of Argument.

func (*Arguments) UnmarshalYAML

func (args *Arguments) UnmarshalYAML(ctx context.Context, unmarshal func(interface{}) error) error

UnmarshalYAML provides custom unmarshaling logic for Arguments.

type Manifest

type Manifest struct {
	Description string                         `json:"description"`
	Arguments   []parameters.ParameterManifest `json:"arguments"`
}

Manifest is the representation of prompts sent to Client SDKs.

func GetManifest

func GetManifest(desc string, args Arguments) Manifest

type McpManifest

type McpManifest struct {
	Name        string           `json:"name"`
	Description string           `json:"description,omitempty"`
	Arguments   []ArgMcpManifest `json:"arguments,omitempty"`
}

McpManifest is the definition for a prompt the MCP client can get.

func GetMcpManifest

func GetMcpManifest(name, desc string, args Arguments) McpManifest

type Message

type Message struct {
	Role    string `yaml:"role,omitempty"`
	Content string `yaml:"content"`
}

Message represents a single message in a prompt, with a role and content.

func SubstituteMessages

func SubstituteMessages(messages []Message, arguments Arguments, argValues parameters.ParamValues) ([]Message, error)

SubstituteMessages takes a slice of Messages and a set of parameter values, and returns a new slice with all template variables resolved.

func (*Message) UnmarshalYAML

func (m *Message) UnmarshalYAML(unmarshal func(interface{}) error) error

type Prompt

type Prompt interface {
	SubstituteParams(parameters.ParamValues) (any, error)
	ParseArgs(map[string]any, map[string]map[string]any) (parameters.ParamValues, error)
	Manifest() Manifest
	McpManifest() McpManifest
}

type PromptConfig

type PromptConfig interface {
	PromptConfigKind() string
	Initialize() (Prompt, error)
}

func DecodeConfig

func DecodeConfig(ctx context.Context, kind, name string, decoder *yaml.Decoder) (PromptConfig, error)

DecodeConfig looks up the registered factory for the given kind and uses it to decode the prompt configuration.

type PromptConfigFactory

type PromptConfigFactory func(ctx context.Context, name string, decoder *yaml.Decoder) (PromptConfig, error)

PromptConfigFactory defines the signature for a function that creates and decodes a specific prompt's configuration.

type Promptset

type Promptset struct {
	Name        string            `yaml:"name"`
	Prompts     []*Prompt         `yaml:",inline"`
	Manifest    PromptsetManifest `yaml:",inline"`
	McpManifest []McpManifest     `yaml:",inline"`
}

type PromptsetConfig

type PromptsetConfig struct {
	Name        string   `yaml:"name"`
	PromptNames []string `yaml:",inline"`
}

func (PromptsetConfig) Initialize

func (t PromptsetConfig) Initialize(serverVersion string, promptsMap map[string]Prompt) (Promptset, error)

type PromptsetManifest

type PromptsetManifest struct {
	ServerVersion   string              `json:"serverVersion"`
	PromptsManifest map[string]Manifest `json:"prompts"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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