Add Promptkit execution adapter
This commit is contained in:
@@ -148,6 +148,16 @@ type Validation struct {
|
||||
Diagnostics []string
|
||||
}
|
||||
|
||||
// NewValidation returns a completed validation value with bounded diagnostics.
|
||||
func NewValidation(status ValidationStatus, mode string, schemaPath string, diagnostics []string) Validation {
|
||||
return Validation{
|
||||
Status: status,
|
||||
Mode: mode,
|
||||
SchemaPath: schemaPath,
|
||||
Diagnostics: boundDiagnostics(diagnostics),
|
||||
}
|
||||
}
|
||||
|
||||
// ValidationStatus identifies the completed validation state.
|
||||
type ValidationStatus string
|
||||
|
||||
|
||||
@@ -172,6 +172,10 @@ func TestBoundDiagnosticAndErrorText(t *testing.T) {
|
||||
if bounded[0] != "a<>b" {
|
||||
t.Fatalf("invalid UTF-8 diagnostic = %q, want replacement", bounded[0])
|
||||
}
|
||||
validation := NewValidation(ValidationFailed, "json_schema", "daily.schema.json", values)
|
||||
if len(validation.Diagnostics) != maxValidationDiagnostics || validation.Diagnostics[0] != "a<>b" {
|
||||
t.Fatalf("validation = %#v, want bounded diagnostics", validation)
|
||||
}
|
||||
|
||||
err := NewError(Generation, strings.Repeat("é", maxErrorMessageBytes), nil)
|
||||
if len(err.Error()) > maxErrorMessageBytes || !utf8.ValidString(err.Error()) {
|
||||
|
||||
Reference in New Issue
Block a user