54 lines
2.0 KiB
Go
54 lines
2.0 KiB
Go
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)
|
|
}
|