/
models_output_schema.go
49 lines (36 loc) · 1.19 KB
/
models_output_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
package davinci
import "encoding/json"
type _OutputSchema OutputSchema
type OutputSchema struct {
AdditionalProperties map[string]interface{} `json:"-" davinci:"-,unmappedproperties"` // used to capture all other properties that are not explicitly defined in the model
Output interface{} `json:"output,omitempty" davinci:"output,config,omitempty"`
}
func (o OutputSchema) MarshalJSON() ([]byte, error) {
result, err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(result)
}
func (o OutputSchema) ToMap() (map[string]interface{}, error) {
result := map[string]interface{}{}
if o.Output != nil {
result["output"] = o.Output
}
for k, v := range o.AdditionalProperties {
result[k] = v
}
return result, nil
}
func (o *OutputSchema) UnmarshalJSON(bytes []byte) (err error) {
varOutputSchema := _OutputSchema{}
if err = json.Unmarshal(bytes, &varOutputSchema); err == nil {
*o = OutputSchema(varOutputSchema)
}
additionalProperties := make(map[string]interface{})
if err = json.Unmarshal(bytes, &additionalProperties); err == nil {
delete(additionalProperties, "output")
o.AdditionalProperties = additionalProperties
}
return err
}