-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschema.go
64 lines (54 loc) · 1.54 KB
/
schema.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package schema
//https://platform.openai.com/docs/guides/structured-outputs#supported-schemas
//String
//Number
//Boolean
//Integer
//Object
//Array
//Enum
//anyOf
// https://ai.google.dev/gemini-api/docs/structured-output?lang=python
// int
// float
// bool
// str (or enum)
// list[AllowedType]
// dict[str, AllowedType]
//
// anyOf
// enum
// format
// items
// maximum
// minimum
// maxItems
// minItems
// nullable
// properties
// propertyOrdering*
// required
type JSON struct {
// JSON Metadata
Description string `json:"description,omitempty"`
// Type System
Type string `json:"type,omitempty"` // Object / Array / String / Number / Integer / Boolean /
// Combinators
Properties map[string]*JSON `json:"properties,omitempty"` // for Object
AdditionalProperties *JSON `json:"additionalProperties,omitempty"` // for Map[string]someting...
Items *JSON `json:"items,omitempty"` // for Array
// Validation
Enum []interface{} `json:"enum,omitempty"`
Required []string `json:"required,omitempty"`
/// Number Validation
Maximum *float64 `json:"maximum,omitempty"`
Minimum *float64 `json:"minimum,omitempty"`
ExclusiveMaximum *float64 `json:"exclusiveMaximum,omitempty"`
ExclusiveMinimum *float64 `json:"exclusiveMinimum,omitempty"`
/// String Validation
MaxLength *int `json:"maxLength,omitempty"`
MinLength *int `json:"minLength,omitempty"`
// Array Validation
MaxItems *int `json:"maxItems,omitempty"`
MinItems *int `json:"minItems,omitempty"`
}