Add appended message request validation
This commit is contained in:
16
types.go
16
types.go
@@ -123,6 +123,13 @@ type RunRequest struct {
|
||||
// Validation optionally replaces the prompt's complete output contract. It
|
||||
// does not merge individual fields. Nil uses the prompt contract.
|
||||
Validation *OutputContract
|
||||
// AppendedMessages are already-rendered messages appended after every prompt
|
||||
// definition message. Promptkit neither templates nor resolves files in
|
||||
// them, and preserves valid content exactly. Nil and empty slices are
|
||||
// equivalent. Prepare, PrepareExecution, and Run validate and copy the
|
||||
// messages before source or model work; malformed values return an error
|
||||
// matching ErrInvalidRequest.
|
||||
AppendedMessages []RenderedMessage
|
||||
}
|
||||
|
||||
// PreparedRun contains prepared prompt execution state returned by
|
||||
@@ -629,12 +636,13 @@ type RenderedPrompt struct {
|
||||
Messages []RenderedMessage `json:"messages"`
|
||||
}
|
||||
|
||||
// RenderedMessage is a rendered chat message and has a stable JSON
|
||||
// representation.
|
||||
// RenderedMessage is a prepared, provider-bound text chat message and has a
|
||||
// stable JSON representation. Its role must be one of [RoleDeveloper],
|
||||
// [RoleSystem], [RoleUser], or [RoleAssistant].
|
||||
type RenderedMessage struct {
|
||||
// Role is the definition-supplied chat role.
|
||||
// Role is the provider-bound chat role.
|
||||
Role string `json:"role"`
|
||||
// Content is the rendered message text.
|
||||
// Content is the provider-bound message text and may be empty or whitespace.
|
||||
Content string `json:"content"`
|
||||
// CacheControl is optional provider cache metadata.
|
||||
CacheControl *CacheControl `json:"cache_control,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user