Move embedded prompts to PromptKit definitions
This commit is contained in:
53
internal/framework/structuredoutput/call.go
Normal file
53
internal/framework/structuredoutput/call.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package structuredoutput
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/internal/framework/responseschema"
|
||||
)
|
||||
|
||||
// DiagnosticContext identifies the logical call without examining rendered text.
|
||||
type DiagnosticContext struct {
|
||||
Role string `json:"role"`
|
||||
ModuleKey string `json:"module_key,omitempty"`
|
||||
ModuleInstance string `json:"module_instance,omitempty"`
|
||||
SectionIndex *int `json:"section_index,omitempty"`
|
||||
BatchIndex *int `json:"batch_index,omitempty"`
|
||||
ValidatorName string `json:"validator_name,omitempty"`
|
||||
}
|
||||
|
||||
// Request names an embedded prompt and response schema. Profile selection and
|
||||
// credentials are supplied by the role-bound runtime client.
|
||||
type Request struct {
|
||||
PromptID string `json:"prompt_id"`
|
||||
PromptVersion string `json:"prompt_version"`
|
||||
Variables map[string]string `json:"variables"`
|
||||
Schema responseschema.Key `json:"schema"`
|
||||
Context DiagnosticContext `json:"context"`
|
||||
}
|
||||
|
||||
// PromptMetadata is the execution snapshot returned by the runtime when available.
|
||||
type PromptMetadata struct {
|
||||
PromptID string `json:"prompt_id,omitempty"`
|
||||
PromptVersion string `json:"prompt_version,omitempty"`
|
||||
DefinitionHash string `json:"definition_hash,omitempty"`
|
||||
RenderedHash string `json:"rendered_hash,omitempty"`
|
||||
ProfileID string `json:"profile_id,omitempty"`
|
||||
BackendID string `json:"backend_id,omitempty"`
|
||||
Model string `json:"model,omitempty"`
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Content json.RawMessage `json:"content,omitempty"`
|
||||
Provider string `json:"provider,omitempty"`
|
||||
Model string `json:"model,omitempty"`
|
||||
PromptTokens int `json:"prompt_tokens,omitempty"`
|
||||
CompletionTokens int `json:"completion_tokens,omitempty"`
|
||||
TotalTokens int `json:"total_tokens,omitempty"`
|
||||
Prompt PromptMetadata `json:"prompt"`
|
||||
}
|
||||
|
||||
type Client interface {
|
||||
CompleteStructured(ctx context.Context, req Request, out any) (Response, error)
|
||||
}
|
||||
Reference in New Issue
Block a user