diff --git a/VERSION b/VERSION index a551051..04a373e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.15.0 +0.16.0 diff --git a/arkruntime/model/audiogeneration/oas_schemas_gen.go b/arkruntime/model/audiogeneration/oas_schemas_gen.go index 1b9b31d..dc1afbf 100644 --- a/arkruntime/model/audiogeneration/oas_schemas_gen.go +++ b/arkruntime/model/audiogeneration/oas_schemas_gen.go @@ -405,10 +405,10 @@ func (s *AudioRole) UnmarshalText(data []byte) error { // Ref: #/components/schemas/AudioURL type AudioURL struct { - // Public HTTP(S) URL, speaker://, file:// for registered reference audio, or - // data:audio/{wav,mp3};base64,. Decoded base64 audio is limited to 15 MiB for reference - // generation; separation uses a 90 MiB source-audio limit. A speaker reference cannot be used for - // separation. + // Public HTTP(S) URL, speaker:// for a preset speaker, file:// for a custom voice + // registered through the Files API, or data:audio/{wav,mp3};base64,. Voice-cloning speaker + // IDs are not supported. Decoded base64 audio is limited to 15 MiB for reference generation; + // separation uses a 90 MiB source-audio limit. A speaker reference cannot be used for separation. URL NonEmptyString `json:"url"` } @@ -2499,8 +2499,9 @@ func (s *VideoRole) UnmarshalText(data []byte) error { // Ref: #/components/schemas/VideoURL type VideoURL struct { - // Public HTTP(S) URL or tos:///. Base64 and speaker references are not supported. Media - // properties and size are validated by the server. + // Public HTTP(S) URL or tos:///. Supported video resolutions: 360p, 480p, 720p and + // 1080p; minimum total pixel count (width * height): 172800. Base64 and speaker references are not + // supported. Media properties and size are validated by the server. URL NonEmptyString `json:"url"` } diff --git a/arkruntime/model/responses/oas_json_gen.go b/arkruntime/model/responses/oas_json_gen.go index d829496..4757bc4 100644 --- a/arkruntime/model/responses/oas_json_gen.go +++ b/arkruntime/model/responses/oas_json_gen.go @@ -5850,13 +5850,20 @@ func (s *FunctionTool) encodeFields(e *jx.Encoder) { s.Description.Encode(e) } } + { + if s.DeferLoading.Set { + e.FieldStart("defer_loading") + s.DeferLoading.Encode(e) + } + } } -var jsonFieldsNameOfFunctionTool = [4]string{ +var jsonFieldsNameOfFunctionTool = [5]string{ 0: "name", 1: "parameters", 2: "type", 3: "description", + 4: "defer_loading", } // Decode decodes FunctionTool from json. @@ -5910,6 +5917,16 @@ func (s *FunctionTool) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"description\"") } + case "defer_loading": + if err := func() error { + s.DeferLoading.Reset() + if err := s.DeferLoading.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"defer_loading\"") + } default: return d.Skip() } @@ -6685,18 +6702,102 @@ func (s InputItemSum) encodeFields(e *jx.Encoder) { s.Name.Encode(e) } } + { + if s.Namespace.Set { + e.FieldStart("namespace") + s.Namespace.Encode(e) + } + } + { + if s.Status.Set { + e.FieldStart("status") + s.Status.Encode(e) + } + } + } + case ItemToolSearchCallInputItemSum: + e.FieldStart("type") + e.Str("tool_search_call") + { + s := s.ItemToolSearchCall + { + if s.ID.Set { + e.FieldStart("id") + s.ID.Encode(e) + } + } + { + if s.Status.Set { + e.FieldStart("status") + s.Status.Encode(e) + } + } + { + e.FieldStart("arguments") + s.Arguments.Encode(e) + } + { + if s.CallID.Set { + e.FieldStart("call_id") + s.CallID.Encode(e) + } + } + { + if s.Execution.Set { + e.FieldStart("execution") + s.Execution.Encode(e) + } + } + } + case ItemToolSearchOutputInputItemSum: + e.FieldStart("type") + e.Str("tool_search_output") + { + s := s.ItemToolSearchOutput + { + if s.ID.Set { + e.FieldStart("id") + s.ID.Encode(e) + } + } { if s.Status.Set { e.FieldStart("status") s.Status.Encode(e) } } + { + if s.CallID.Set { + e.FieldStart("call_id") + s.CallID.Encode(e) + } + } + { + if s.Execution.Set { + e.FieldStart("execution") + s.Execution.Encode(e) + } + } + { + e.FieldStart("tools") + e.ArrStart() + for _, elem := range s.Tools { + elem.Encode(e) + } + e.ArrEnd() + } } case ItemFunctionToolCallOutputInputItemSum: e.FieldStart("type") e.Str("function_call_output") { s := s.ItemFunctionToolCallOutput + { + if s.Namespace.Set { + e.FieldStart("namespace") + s.Namespace.Encode(e) + } + } { if s.CallID.Set { e.FieldStart("call_id") @@ -6926,6 +7027,12 @@ func (s *InputItemSum) Decode(d *jx.Decoder) error { case "function_call": s.Type = ItemFunctionToolCallInputItemSum found = true + case "tool_search_call": + s.Type = ItemToolSearchCallInputItemSum + found = true + case "tool_search_output": + s.Type = ItemToolSearchOutputInputItemSum + found = true case "function_call_output": s.Type = ItemFunctionToolCallOutputInputItemSum found = true @@ -6976,6 +7083,14 @@ func (s *InputItemSum) Decode(d *jx.Decoder) error { if err := s.ItemFunctionToolCall.Decode(d); err != nil { return err } + case ItemToolSearchCallInputItemSum: + if err := s.ItemToolSearchCall.Decode(d); err != nil { + return err + } + case ItemToolSearchOutputInputItemSum: + if err := s.ItemToolSearchOutput.Decode(d); err != nil { + return err + } case ItemFunctionToolCallOutputInputItemSum: if err := s.ItemFunctionToolCallOutput.Decode(d); err != nil { return err @@ -9107,6 +9222,12 @@ func (s *ItemFunctionToolCall) encodeFields(e *jx.Encoder) { s.Name.Encode(e) } } + { + if s.Namespace.Set { + e.FieldStart("namespace") + s.Namespace.Encode(e) + } + } { if s.Status.Set { e.FieldStart("status") @@ -9115,13 +9236,14 @@ func (s *ItemFunctionToolCall) encodeFields(e *jx.Encoder) { } } -var jsonFieldsNameOfItemFunctionToolCall = [6]string{ +var jsonFieldsNameOfItemFunctionToolCall = [7]string{ 0: "id", 1: "type", 2: "arguments", 3: "call_id", 4: "name", - 5: "status", + 5: "namespace", + 6: "status", } // Decode decodes ItemFunctionToolCall from json. @@ -9183,6 +9305,16 @@ func (s *ItemFunctionToolCall) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"name\"") } + case "namespace": + if err := func() error { + s.Namespace.Reset() + if err := s.Namespace.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"namespace\"") + } case "status": if err := func() error { s.Status.Reset() @@ -9258,6 +9390,12 @@ func (s *ItemFunctionToolCallOutput) Encode(e *jx.Encoder) { // encodeFields encodes fields. func (s *ItemFunctionToolCallOutput) encodeFields(e *jx.Encoder) { + { + if s.Namespace.Set { + e.FieldStart("namespace") + s.Namespace.Encode(e) + } + } { e.FieldStart("type") s.Type.Encode(e) @@ -9288,12 +9426,13 @@ func (s *ItemFunctionToolCallOutput) encodeFields(e *jx.Encoder) { } } -var jsonFieldsNameOfItemFunctionToolCallOutput = [5]string{ - 0: "type", - 1: "call_id", - 2: "output", - 3: "id", - 4: "status", +var jsonFieldsNameOfItemFunctionToolCallOutput = [6]string{ + 0: "namespace", + 1: "type", + 2: "call_id", + 3: "output", + 4: "id", + 5: "status", } // Decode decodes ItemFunctionToolCallOutput from json. @@ -9305,8 +9444,18 @@ func (s *ItemFunctionToolCallOutput) Decode(d *jx.Decoder) error { if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { + case "namespace": + if err := func() error { + s.Namespace.Reset() + if err := s.Namespace.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"namespace\"") + } case "type": - requiredBitSet[0] |= 1 << 0 + requiredBitSet[0] |= 1 << 1 if err := func() error { if err := s.Type.Decode(d); err != nil { return err @@ -9365,7 +9514,7 @@ func (s *ItemFunctionToolCallOutput) Decode(d *jx.Decoder) error { // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00000001, + 0b00000010, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -10214,14 +10363,18 @@ func (s *ItemStatus) UnmarshalJSON(data []byte) error { } // Encode implements json.Marshaler. -func (s *ItemTranscription) Encode(e *jx.Encoder) { +func (s *ItemToolSearchCall) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } // encodeFields encodes fields. -func (s *ItemTranscription) encodeFields(e *jx.Encoder) { +func (s *ItemToolSearchCall) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } { if s.ID.Set { e.FieldStart("id") @@ -10229,41 +10382,57 @@ func (s *ItemTranscription) encodeFields(e *jx.Encoder) { } } { - e.FieldStart("type") - s.Type.Encode(e) + if s.Status.Set { + e.FieldStart("status") + s.Status.Encode(e) + } } { - if s.Transcription != nil { - e.FieldStart("transcription") - e.ArrStart() - for _, elem := range s.Transcription { - elem.Encode(e) - } - e.ArrEnd() + e.FieldStart("arguments") + s.Arguments.Encode(e) + } + { + if s.CallID.Set { + e.FieldStart("call_id") + s.CallID.Encode(e) } } { - e.FieldStart("status") - s.Status.Encode(e) + if s.Execution.Set { + e.FieldStart("execution") + s.Execution.Encode(e) + } } } -var jsonFieldsNameOfItemTranscription = [4]string{ - 0: "id", - 1: "type", - 2: "transcription", - 3: "status", +var jsonFieldsNameOfItemToolSearchCall = [6]string{ + 0: "type", + 1: "id", + 2: "status", + 3: "arguments", + 4: "call_id", + 5: "execution", } -// Decode decodes ItemTranscription from json. -func (s *ItemTranscription) Decode(d *jx.Decoder) error { +// Decode decodes ItemToolSearchCall from json. +func (s *ItemToolSearchCall) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ItemTranscription to nil") + return errors.New("invalid: unable to decode ItemToolSearchCall to nil") } var requiredBitSet [1]uint8 if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { + case "type": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } case "id": if err := func() error { s.ID.Reset() @@ -10274,54 +10443,57 @@ func (s *ItemTranscription) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"id\"") } - case "type": - requiredBitSet[0] |= 1 << 1 + case "status": if err := func() error { - if err := s.Type.Decode(d); err != nil { + s.Status.Reset() + if err := s.Status.Decode(d); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"type\"") + return errors.Wrap(err, "decode field \"status\"") } - case "transcription": + case "arguments": + requiredBitSet[0] |= 1 << 3 if err := func() error { - s.Transcription = make([]TranscriptionPart, 0) - if err := d.Arr(func(d *jx.Decoder) error { - var elem TranscriptionPart - if err := elem.Decode(d); err != nil { - return err - } - s.Transcription = append(s.Transcription, elem) - return nil - }); err != nil { + if err := s.Arguments.Decode(d); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"transcription\"") + return errors.Wrap(err, "decode field \"arguments\"") } - case "status": - requiredBitSet[0] |= 1 << 3 + case "call_id": if err := func() error { - if err := s.Status.Decode(d); err != nil { + s.CallID.Reset() + if err := s.CallID.Decode(d); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"status\"") + return errors.Wrap(err, "decode field \"call_id\"") + } + case "execution": + if err := func() error { + s.Execution.Reset() + if err := s.Execution.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"execution\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode ItemTranscription") + return errors.Wrap(err, "decode ItemToolSearchCall") } // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00001010, + 0b00001001, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -10333,8 +10505,8 @@ func (s *ItemTranscription) Decode(d *jx.Decoder) error { bitIdx := bits.TrailingZeros8(result) fieldIdx := i*8 + bitIdx var name string - if fieldIdx < len(jsonFieldsNameOfItemTranscription) { - name = jsonFieldsNameOfItemTranscription[fieldIdx] + if fieldIdx < len(jsonFieldsNameOfItemToolSearchCall) { + name = jsonFieldsNameOfItemToolSearchCall[fieldIdx] } else { name = strconv.Itoa(fieldIdx) } @@ -10355,126 +10527,174 @@ func (s *ItemTranscription) Decode(d *jx.Decoder) error { } // MarshalJSON implements stdjson.Marshaler. -func (s *ItemTranscription) MarshalJSON() ([]byte, error) { +func (s *ItemToolSearchCall) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ItemTranscription) UnmarshalJSON(data []byte) error { +func (s *ItemToolSearchCall) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ItemTranscriptionType as json. -func (s ItemTranscriptionType) Encode(e *jx.Encoder) { - e.Str(string(s)) +// Encode implements json.Marshaler. +func (s ItemToolSearchCallArguments) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() } -// Decode decodes ItemTranscriptionType from json. -func (s *ItemTranscriptionType) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode ItemTranscriptionType to nil") +// encodeFields implements json.Marshaler. +func (s ItemToolSearchCallArguments) encodeFields(e *jx.Encoder) { + for k, elem := range s { + e.FieldStart(k) + + if len(elem) != 0 { + e.Raw(elem) + } } - v, err := d.StrBytes() - if err != nil { - return err +} + +// Decode decodes ItemToolSearchCallArguments from json. +func (s *ItemToolSearchCallArguments) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ItemToolSearchCallArguments to nil") } - // Try to use constant string. - switch ItemTranscriptionType(v) { - case ItemTranscriptionTypeTranscription: - *s = ItemTranscriptionTypeTranscription - default: - *s = ItemTranscriptionType(v) + m := s.init() + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + var elem jx.Raw + if err := func() error { + v, err := d.RawAppend(nil) + elem = jx.Raw(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrapf(err, "decode field %q", k) + } + m[string(k)] = elem + return nil + }); err != nil { + return errors.Wrap(err, "decode ItemToolSearchCallArguments") } return nil } // MarshalJSON implements stdjson.Marshaler. -func (s ItemTranscriptionType) MarshalJSON() ([]byte, error) { +func (s ItemToolSearchCallArguments) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ItemTranscriptionType) UnmarshalJSON(data []byte) error { +func (s *ItemToolSearchCallArguments) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode implements json.Marshaler. -func (s *KnowledgeSearchTool) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() +// Encode encodes ItemToolSearchCallType as json. +func (s ItemToolSearchCallType) Encode(e *jx.Encoder) { + e.Str(string(s)) } -// encodeFields encodes fields. -func (s *KnowledgeSearchTool) encodeFields(e *jx.Encoder) { - { - e.FieldStart("type") - s.Type.Encode(e) +// Decode decodes ItemToolSearchCallType from json. +func (s *ItemToolSearchCallType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ItemToolSearchCallType to nil") } - { - e.FieldStart("knowledge_resource_id") - e.Str(s.KnowledgeResourceID) + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch ItemToolSearchCallType(v) { + case ItemToolSearchCallTypeToolSearchCall: + *s = ItemToolSearchCallTypeToolSearchCall + default: + *s = ItemToolSearchCallType(v) } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ItemToolSearchCallType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ItemToolSearchCallType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ItemToolSearchOutput) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ItemToolSearchOutput) encodeFields(e *jx.Encoder) { { - if s.Description.Set { - e.FieldStart("description") - s.Description.Encode(e) - } + e.FieldStart("type") + s.Type.Encode(e) } { - if s.Limit.Set { - e.FieldStart("limit") - s.Limit.Encode(e) + if s.ID.Set { + e.FieldStart("id") + s.ID.Encode(e) } } { - if s.DenseWeight.Set { - e.FieldStart("dense_weight") - s.DenseWeight.Encode(e) + if s.Status.Set { + e.FieldStart("status") + s.Status.Encode(e) } } { - if s.DocFilter.Set { - e.FieldStart("doc_filter") - s.DocFilter.Encode(e) + if s.CallID.Set { + e.FieldStart("call_id") + s.CallID.Encode(e) } } { - if s.RankingOptions.Set { - e.FieldStart("ranking_options") - s.RankingOptions.Encode(e) + if s.Execution.Set { + e.FieldStart("execution") + s.Execution.Encode(e) } } { - if s.MaxKeyword.Set { - e.FieldStart("max_keyword") - s.MaxKeyword.Encode(e) + e.FieldStart("tools") + e.ArrStart() + for _, elem := range s.Tools { + elem.Encode(e) } + e.ArrEnd() } } -var jsonFieldsNameOfKnowledgeSearchTool = [8]string{ +var jsonFieldsNameOfItemToolSearchOutput = [6]string{ 0: "type", - 1: "knowledge_resource_id", - 2: "description", - 3: "limit", - 4: "dense_weight", - 5: "doc_filter", - 6: "ranking_options", - 7: "max_keyword", + 1: "id", + 2: "status", + 3: "call_id", + 4: "execution", + 5: "tools", } -// Decode decodes KnowledgeSearchTool from json. -func (s *KnowledgeSearchTool) Decode(d *jx.Decoder) error { +// Decode decodes ItemToolSearchOutput from json. +func (s *ItemToolSearchOutput) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode KnowledgeSearchTool to nil") + return errors.New("invalid: unable to decode ItemToolSearchOutput to nil") } var requiredBitSet [1]uint8 @@ -10490,89 +10710,75 @@ func (s *KnowledgeSearchTool) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"type\"") } - case "knowledge_resource_id": - requiredBitSet[0] |= 1 << 1 - if err := func() error { - v, err := d.Str() - s.KnowledgeResourceID = string(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"knowledge_resource_id\"") - } - case "description": - if err := func() error { - s.Description.Reset() - if err := s.Description.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"description\"") - } - case "limit": + case "id": if err := func() error { - s.Limit.Reset() - if err := s.Limit.Decode(d); err != nil { + s.ID.Reset() + if err := s.ID.Decode(d); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"limit\"") + return errors.Wrap(err, "decode field \"id\"") } - case "dense_weight": + case "status": if err := func() error { - s.DenseWeight.Reset() - if err := s.DenseWeight.Decode(d); err != nil { + s.Status.Reset() + if err := s.Status.Decode(d); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"dense_weight\"") + return errors.Wrap(err, "decode field \"status\"") } - case "doc_filter": + case "call_id": if err := func() error { - s.DocFilter.Reset() - if err := s.DocFilter.Decode(d); err != nil { + s.CallID.Reset() + if err := s.CallID.Decode(d); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"doc_filter\"") + return errors.Wrap(err, "decode field \"call_id\"") } - case "ranking_options": + case "execution": if err := func() error { - s.RankingOptions.Reset() - if err := s.RankingOptions.Decode(d); err != nil { + s.Execution.Reset() + if err := s.Execution.Decode(d); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"ranking_options\"") + return errors.Wrap(err, "decode field \"execution\"") } - case "max_keyword": + case "tools": + requiredBitSet[0] |= 1 << 5 if err := func() error { - s.MaxKeyword.Reset() - if err := s.MaxKeyword.Decode(d); err != nil { + s.Tools = make([]ToolSearchResultTool, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem ToolSearchResultTool + if err := elem.Decode(d); err != nil { + return err + } + s.Tools = append(s.Tools, elem) + return nil + }); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"max_keyword\"") + return errors.Wrap(err, "decode field \"tools\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode KnowledgeSearchTool") + return errors.Wrap(err, "decode ItemToolSearchOutput") } // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00000011, + 0b00100001, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -10584,8 +10790,8 @@ func (s *KnowledgeSearchTool) Decode(d *jx.Decoder) error { bitIdx := bits.TrailingZeros8(result) fieldIdx := i*8 + bitIdx var name string - if fieldIdx < len(jsonFieldsNameOfKnowledgeSearchTool) { - name = jsonFieldsNameOfKnowledgeSearchTool[fieldIdx] + if fieldIdx < len(jsonFieldsNameOfItemToolSearchOutput) { + name = jsonFieldsNameOfItemToolSearchOutput[fieldIdx] } else { name = strconv.Itoa(fieldIdx) } @@ -10606,122 +10812,565 @@ func (s *KnowledgeSearchTool) Decode(d *jx.Decoder) error { } // MarshalJSON implements stdjson.Marshaler. -func (s *KnowledgeSearchTool) MarshalJSON() ([]byte, error) { +func (s *ItemToolSearchOutput) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *KnowledgeSearchTool) UnmarshalJSON(data []byte) error { +func (s *ItemToolSearchOutput) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode implements json.Marshaler. -func (s KnowledgeSearchToolDocFilter) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() -} - -// encodeFields implements json.Marshaler. -func (s KnowledgeSearchToolDocFilter) encodeFields(e *jx.Encoder) { - for k, elem := range s { - e.FieldStart(k) - - if len(elem) != 0 { - e.Raw(elem) - } - } +// Encode encodes ItemToolSearchOutputType as json. +func (s ItemToolSearchOutputType) Encode(e *jx.Encoder) { + e.Str(string(s)) } -// Decode decodes KnowledgeSearchToolDocFilter from json. -func (s *KnowledgeSearchToolDocFilter) Decode(d *jx.Decoder) error { +// Decode decodes ItemToolSearchOutputType from json. +func (s *ItemToolSearchOutputType) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode KnowledgeSearchToolDocFilter to nil") + return errors.New("invalid: unable to decode ItemToolSearchOutputType to nil") } - m := s.init() - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - var elem jx.Raw - if err := func() error { - v, err := d.RawAppend(nil) - elem = jx.Raw(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrapf(err, "decode field %q", k) - } - m[string(k)] = elem - return nil - }); err != nil { - return errors.Wrap(err, "decode KnowledgeSearchToolDocFilter") + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch ItemToolSearchOutputType(v) { + case ItemToolSearchOutputTypeToolSearchOutput: + *s = ItemToolSearchOutputTypeToolSearchOutput + default: + *s = ItemToolSearchOutputType(v) } return nil } // MarshalJSON implements stdjson.Marshaler. -func (s KnowledgeSearchToolDocFilter) MarshalJSON() ([]byte, error) { +func (s ItemToolSearchOutputType) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *KnowledgeSearchToolDocFilter) UnmarshalJSON(data []byte) error { +func (s *ItemToolSearchOutputType) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } // Encode implements json.Marshaler. -func (s KnowledgeSearchToolRankingOptions) Encode(e *jx.Encoder) { +func (s *ItemTranscription) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } -// encodeFields implements json.Marshaler. -func (s KnowledgeSearchToolRankingOptions) encodeFields(e *jx.Encoder) { - for k, elem := range s { - e.FieldStart(k) - - if len(elem) != 0 { - e.Raw(elem) +// encodeFields encodes fields. +func (s *ItemTranscription) encodeFields(e *jx.Encoder) { + { + if s.ID.Set { + e.FieldStart("id") + s.ID.Encode(e) } } -} - -// Decode decodes KnowledgeSearchToolRankingOptions from json. -func (s *KnowledgeSearchToolRankingOptions) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode KnowledgeSearchToolRankingOptions to nil") + { + e.FieldStart("type") + s.Type.Encode(e) } - m := s.init() - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - var elem jx.Raw - if err := func() error { - v, err := d.RawAppend(nil) - elem = jx.Raw(v) - if err != nil { - return err + { + if s.Transcription != nil { + e.FieldStart("transcription") + e.ArrStart() + for _, elem := range s.Transcription { + elem.Encode(e) } - return nil - }(); err != nil { - return errors.Wrapf(err, "decode field %q", k) + e.ArrEnd() } - m[string(k)] = elem - return nil - }); err != nil { - return errors.Wrap(err, "decode KnowledgeSearchToolRankingOptions") } + { + e.FieldStart("status") + s.Status.Encode(e) + } +} - return nil +var jsonFieldsNameOfItemTranscription = [4]string{ + 0: "id", + 1: "type", + 2: "transcription", + 3: "status", } -// MarshalJSON implements stdjson.Marshaler. +// Decode decodes ItemTranscription from json. +func (s *ItemTranscription) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ItemTranscription to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "id": + if err := func() error { + s.ID.Reset() + if err := s.ID.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"id\"") + } + case "type": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "transcription": + if err := func() error { + s.Transcription = make([]TranscriptionPart, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem TranscriptionPart + if err := elem.Decode(d); err != nil { + return err + } + s.Transcription = append(s.Transcription, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"transcription\"") + } + case "status": + requiredBitSet[0] |= 1 << 3 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ItemTranscription") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00001010, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfItemTranscription) { + name = jsonFieldsNameOfItemTranscription[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ItemTranscription) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ItemTranscription) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ItemTranscriptionType as json. +func (s ItemTranscriptionType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes ItemTranscriptionType from json. +func (s *ItemTranscriptionType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ItemTranscriptionType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch ItemTranscriptionType(v) { + case ItemTranscriptionTypeTranscription: + *s = ItemTranscriptionTypeTranscription + default: + *s = ItemTranscriptionType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ItemTranscriptionType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ItemTranscriptionType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *KnowledgeSearchTool) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *KnowledgeSearchTool) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } + { + e.FieldStart("knowledge_resource_id") + e.Str(s.KnowledgeResourceID) + } + { + if s.Description.Set { + e.FieldStart("description") + s.Description.Encode(e) + } + } + { + if s.Limit.Set { + e.FieldStart("limit") + s.Limit.Encode(e) + } + } + { + if s.DenseWeight.Set { + e.FieldStart("dense_weight") + s.DenseWeight.Encode(e) + } + } + { + if s.DocFilter.Set { + e.FieldStart("doc_filter") + s.DocFilter.Encode(e) + } + } + { + if s.RankingOptions.Set { + e.FieldStart("ranking_options") + s.RankingOptions.Encode(e) + } + } + { + if s.MaxKeyword.Set { + e.FieldStart("max_keyword") + s.MaxKeyword.Encode(e) + } + } +} + +var jsonFieldsNameOfKnowledgeSearchTool = [8]string{ + 0: "type", + 1: "knowledge_resource_id", + 2: "description", + 3: "limit", + 4: "dense_weight", + 5: "doc_filter", + 6: "ranking_options", + 7: "max_keyword", +} + +// Decode decodes KnowledgeSearchTool from json. +func (s *KnowledgeSearchTool) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode KnowledgeSearchTool to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "type": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "knowledge_resource_id": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.KnowledgeResourceID = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"knowledge_resource_id\"") + } + case "description": + if err := func() error { + s.Description.Reset() + if err := s.Description.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"description\"") + } + case "limit": + if err := func() error { + s.Limit.Reset() + if err := s.Limit.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"limit\"") + } + case "dense_weight": + if err := func() error { + s.DenseWeight.Reset() + if err := s.DenseWeight.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"dense_weight\"") + } + case "doc_filter": + if err := func() error { + s.DocFilter.Reset() + if err := s.DocFilter.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"doc_filter\"") + } + case "ranking_options": + if err := func() error { + s.RankingOptions.Reset() + if err := s.RankingOptions.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"ranking_options\"") + } + case "max_keyword": + if err := func() error { + s.MaxKeyword.Reset() + if err := s.MaxKeyword.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"max_keyword\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode KnowledgeSearchTool") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfKnowledgeSearchTool) { + name = jsonFieldsNameOfKnowledgeSearchTool[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *KnowledgeSearchTool) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *KnowledgeSearchTool) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s KnowledgeSearchToolDocFilter) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields implements json.Marshaler. +func (s KnowledgeSearchToolDocFilter) encodeFields(e *jx.Encoder) { + for k, elem := range s { + e.FieldStart(k) + + if len(elem) != 0 { + e.Raw(elem) + } + } +} + +// Decode decodes KnowledgeSearchToolDocFilter from json. +func (s *KnowledgeSearchToolDocFilter) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode KnowledgeSearchToolDocFilter to nil") + } + m := s.init() + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + var elem jx.Raw + if err := func() error { + v, err := d.RawAppend(nil) + elem = jx.Raw(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrapf(err, "decode field %q", k) + } + m[string(k)] = elem + return nil + }); err != nil { + return errors.Wrap(err, "decode KnowledgeSearchToolDocFilter") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s KnowledgeSearchToolDocFilter) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *KnowledgeSearchToolDocFilter) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s KnowledgeSearchToolRankingOptions) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields implements json.Marshaler. +func (s KnowledgeSearchToolRankingOptions) encodeFields(e *jx.Encoder) { + for k, elem := range s { + e.FieldStart(k) + + if len(elem) != 0 { + e.Raw(elem) + } + } +} + +// Decode decodes KnowledgeSearchToolRankingOptions from json. +func (s *KnowledgeSearchToolRankingOptions) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode KnowledgeSearchToolRankingOptions to nil") + } + m := s.init() + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + var elem jx.Raw + if err := func() error { + v, err := d.RawAppend(nil) + elem = jx.Raw(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrapf(err, "decode field %q", k) + } + m[string(k)] = elem + return nil + }); err != nil { + return errors.Wrap(err, "decode KnowledgeSearchToolRankingOptions") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. func (s KnowledgeSearchToolRankingOptions) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) @@ -12113,78 +12762,271 @@ func (s *MessageContent) Decode(d *jx.Decoder) error { if err := elem.Decode(d); err != nil { return err } - s.ContentItemArray = append(s.ContentItemArray, elem) - return nil - }); err != nil { - return err + s.ContentItemArray = append(s.ContentItemArray, elem) + return nil + }); err != nil { + return err + } + s.Type = ContentItemArrayMessageContent + case jx.String: + v, err := d.Str() + s.String = string(v) + if err != nil { + return err + } + s.Type = StringMessageContent + default: + return errors.Errorf("unexpected json type %q", t) + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s MessageContent) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *MessageContent) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes MessageRole as json. +func (s MessageRole) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes MessageRole from json. +func (s *MessageRole) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode MessageRole to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch MessageRole(v) { + case MessageRoleUser: + *s = MessageRoleUser + case MessageRoleSystem: + *s = MessageRoleSystem + case MessageRoleDeveloper: + *s = MessageRoleDeveloper + case MessageRoleAssistant: + *s = MessageRoleAssistant + default: + *s = MessageRole(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s MessageRole) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *MessageRole) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NamespaceTool) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NamespaceTool) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } + { + e.FieldStart("name") + e.Str(s.Name) + } + { + if s.Description.Set { + e.FieldStart("description") + s.Description.Encode(e) + } + } + { + e.FieldStart("tools") + e.ArrStart() + for _, elem := range s.Tools { + elem.Encode(e) + } + e.ArrEnd() + } +} + +var jsonFieldsNameOfNamespaceTool = [4]string{ + 0: "type", + 1: "name", + 2: "description", + 3: "tools", +} + +// Decode decodes NamespaceTool from json. +func (s *NamespaceTool) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NamespaceTool to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "type": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "name": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.Name = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"name\"") + } + case "description": + if err := func() error { + s.Description.Reset() + if err := s.Description.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"description\"") + } + case "tools": + requiredBitSet[0] |= 1 << 3 + if err := func() error { + s.Tools = make([]FunctionTool, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem FunctionTool + if err := elem.Decode(d); err != nil { + return err + } + s.Tools = append(s.Tools, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"tools\"") + } + default: + return d.Skip() } - s.Type = ContentItemArrayMessageContent - case jx.String: - v, err := d.Str() - s.String = string(v) - if err != nil { - return err + return nil + }); err != nil { + return errors.Wrap(err, "decode NamespaceTool") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00001011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNamespaceTool) { + name = jsonFieldsNameOfNamespaceTool[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } } - s.Type = StringMessageContent - default: - return errors.Errorf("unexpected json type %q", t) } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s MessageContent) MarshalJSON() ([]byte, error) { +func (s *NamespaceTool) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *MessageContent) UnmarshalJSON(data []byte) error { +func (s *NamespaceTool) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes MessageRole as json. -func (s MessageRole) Encode(e *jx.Encoder) { +// Encode encodes NamespaceToolType as json. +func (s NamespaceToolType) Encode(e *jx.Encoder) { e.Str(string(s)) } -// Decode decodes MessageRole from json. -func (s *MessageRole) Decode(d *jx.Decoder) error { +// Decode decodes NamespaceToolType from json. +func (s *NamespaceToolType) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode MessageRole to nil") + return errors.New("invalid: unable to decode NamespaceToolType to nil") } v, err := d.StrBytes() if err != nil { return err } // Try to use constant string. - switch MessageRole(v) { - case MessageRoleUser: - *s = MessageRoleUser - case MessageRoleSystem: - *s = MessageRoleSystem - case MessageRoleDeveloper: - *s = MessageRoleDeveloper - case MessageRoleAssistant: - *s = MessageRoleAssistant + switch NamespaceToolType(v) { + case NamespaceToolTypeNamespace: + *s = NamespaceToolTypeNamespace default: - *s = MessageRole(v) + *s = NamespaceToolType(v) } return nil } // MarshalJSON implements stdjson.Marshaler. -func (s MessageRole) MarshalJSON() ([]byte, error) { +func (s NamespaceToolType) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *MessageRole) UnmarshalJSON(data []byte) error { +func (s *NamespaceToolType) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } @@ -13260,6 +14102,106 @@ func (s *OptMessageRole) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes string as json. +func (o OptNilString) Encode(e *jx.Encoder) { + if !o.Set { + return + } + if o.Null { + e.Null() + return + } + e.Str(string(o.Value)) +} + +// Decode decodes string from json. +func (o *OptNilString) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptNilString to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v string + o.Value = v + o.Set = true + o.Null = true + return nil + } + o.Set = true + o.Null = false + v, err := d.Str() + if err != nil { + return err + } + o.Value = string(v) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptNilString) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptNilString) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ToolSearchExecution as json. +func (o OptNilToolSearchExecution) Encode(e *jx.Encoder) { + if !o.Set { + return + } + if o.Null { + e.Null() + return + } + e.Str(string(o.Value)) +} + +// Decode decodes ToolSearchExecution from json. +func (o *OptNilToolSearchExecution) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptNilToolSearchExecution to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v ToolSearchExecution + o.Value = v + o.Set = true + o.Null = true + return nil + } + o.Set = true + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptNilToolSearchExecution) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptNilToolSearchExecution) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes Reasoning as json. func (o OptReasoning) Encode(e *jx.Encoder) { if !o.Set { @@ -13857,6 +14799,73 @@ func (s *OptToolNameList) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes ToolSearchExecution as json. +func (o OptToolSearchExecution) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes ToolSearchExecution from json. +func (o *OptToolSearchExecution) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptToolSearchExecution to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptToolSearchExecution) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptToolSearchExecution) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ToolSearchToolParameters as json. +func (o OptToolSearchToolParameters) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes ToolSearchToolParameters from json. +func (o *OptToolSearchToolParameters) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptToolSearchToolParameters to nil") + } + o.Set = true + o.Value = make(ToolSearchToolParameters) + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptToolSearchToolParameters) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptToolSearchToolParameters) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes ToolUsage as json. func (o OptToolUsage) Encode(e *jx.Encoder) { if !o.Set { @@ -14877,12 +15886,90 @@ func (s OutputItemSum) encodeFields(e *jx.Encoder) { s.Name.Encode(e) } } + { + if s.Namespace.Set { + e.FieldStart("namespace") + s.Namespace.Encode(e) + } + } + { + if s.Status.Set { + e.FieldStart("status") + s.Status.Encode(e) + } + } + } + case ItemToolSearchCallOutputItemSum: + e.FieldStart("type") + e.Str("tool_search_call") + { + s := s.ItemToolSearchCall + { + if s.ID.Set { + e.FieldStart("id") + s.ID.Encode(e) + } + } + { + if s.Status.Set { + e.FieldStart("status") + s.Status.Encode(e) + } + } + { + e.FieldStart("arguments") + s.Arguments.Encode(e) + } + { + if s.CallID.Set { + e.FieldStart("call_id") + s.CallID.Encode(e) + } + } + { + if s.Execution.Set { + e.FieldStart("execution") + s.Execution.Encode(e) + } + } + } + case ItemToolSearchOutputOutputItemSum: + e.FieldStart("type") + e.Str("tool_search_output") + { + s := s.ItemToolSearchOutput + { + if s.ID.Set { + e.FieldStart("id") + s.ID.Encode(e) + } + } { if s.Status.Set { e.FieldStart("status") s.Status.Encode(e) } } + { + if s.CallID.Set { + e.FieldStart("call_id") + s.CallID.Encode(e) + } + } + { + if s.Execution.Set { + e.FieldStart("execution") + s.Execution.Encode(e) + } + } + { + e.FieldStart("tools") + e.ArrStart() + for _, elem := range s.Tools { + elem.Encode(e) + } + e.ArrEnd() + } } case ItemReasoningOutputItemSum: e.FieldStart("type") @@ -15222,6 +16309,12 @@ func (s *OutputItemSum) Decode(d *jx.Decoder) error { case "function_call": s.Type = ItemFunctionToolCallOutputItemSum found = true + case "tool_search_call": + s.Type = ItemToolSearchCallOutputItemSum + found = true + case "tool_search_output": + s.Type = ItemToolSearchOutputOutputItemSum + found = true case "reasoning": s.Type = ItemReasoningOutputItemSum found = true @@ -15284,6 +16377,14 @@ func (s *OutputItemSum) Decode(d *jx.Decoder) error { if err := s.ItemFunctionToolCall.Decode(d); err != nil { return err } + case ItemToolSearchCallOutputItemSum: + if err := s.ItemToolSearchCall.Decode(d); err != nil { + return err + } + case ItemToolSearchOutputOutputItemSum: + if err := s.ItemToolSearchOutput.Decode(d); err != nil { + return err + } case ItemReasoningOutputItemSum: if err := s.ItemReasoning.Decode(d); err != nil { return err @@ -33396,132 +34497,430 @@ func (s *Tool) Decode(d *jx.Decoder) error { return d.Skip() } }); err != nil { - return errors.Wrap(err, "decode Tool") + return errors.Wrap(err, "decode Tool") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *Tool) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *Tool) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ToolChoice as json. +func (s ToolChoice) Encode(e *jx.Encoder) { + switch s.Type { + case ToolChoiceOptionsToolChoice: + s.ToolChoiceOptions.Encode(e) + case TypedToolChoiceToolChoice: + s.TypedToolChoice.Encode(e) + } +} + +// Decode decodes ToolChoice from json. +func (s *ToolChoice) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ToolChoice to nil") + } + // Sum type type_discriminator. + switch t := d.Next(); t { + case jx.Object: + if err := s.TypedToolChoice.Decode(d); err != nil { + return err + } + s.Type = TypedToolChoiceToolChoice + case jx.String: + if err := s.ToolChoiceOptions.Decode(d); err != nil { + return err + } + s.Type = ToolChoiceOptionsToolChoice + default: + return errors.Errorf("unexpected json type %q", t) + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ToolChoice) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ToolChoice) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ToolChoiceFunction) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ToolChoiceFunction) encodeFields(e *jx.Encoder) { + { + e.FieldStart("name") + e.Str(s.Name) + } + { + e.FieldStart("type") + s.Type.Encode(e) + } +} + +var jsonFieldsNameOfToolChoiceFunction = [2]string{ + 0: "name", + 1: "type", +} + +// Decode decodes ToolChoiceFunction from json. +func (s *ToolChoiceFunction) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ToolChoiceFunction to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "name": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Str() + s.Name = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"name\"") + } + case "type": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ToolChoiceFunction") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfToolChoiceFunction) { + name = jsonFieldsNameOfToolChoiceFunction[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ToolChoiceFunction) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ToolChoiceFunction) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ToolChoiceFunctionType as json. +func (s ToolChoiceFunctionType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes ToolChoiceFunctionType from json. +func (s *ToolChoiceFunctionType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ToolChoiceFunctionType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch ToolChoiceFunctionType(v) { + case ToolChoiceFunctionTypeFunction: + *s = ToolChoiceFunctionTypeFunction + default: + *s = ToolChoiceFunctionType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ToolChoiceFunctionType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ToolChoiceFunctionType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ToolChoiceKnowledgeSearch) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ToolChoiceKnowledgeSearch) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } +} + +var jsonFieldsNameOfToolChoiceKnowledgeSearch = [1]string{ + 0: "type", +} + +// Decode decodes ToolChoiceKnowledgeSearch from json. +func (s *ToolChoiceKnowledgeSearch) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ToolChoiceKnowledgeSearch to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "type": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ToolChoiceKnowledgeSearch") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000001, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfToolChoiceKnowledgeSearch) { + name = jsonFieldsNameOfToolChoiceKnowledgeSearch[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} } return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *Tool) MarshalJSON() ([]byte, error) { +func (s *ToolChoiceKnowledgeSearch) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *Tool) UnmarshalJSON(data []byte) error { +func (s *ToolChoiceKnowledgeSearch) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ToolChoice as json. -func (s ToolChoice) Encode(e *jx.Encoder) { - switch s.Type { - case ToolChoiceOptionsToolChoice: - s.ToolChoiceOptions.Encode(e) - case TypedToolChoiceToolChoice: - s.TypedToolChoice.Encode(e) - } +// Encode encodes ToolChoiceKnowledgeSearchType as json. +func (s ToolChoiceKnowledgeSearchType) Encode(e *jx.Encoder) { + e.Str(string(s)) } -// Decode decodes ToolChoice from json. -func (s *ToolChoice) Decode(d *jx.Decoder) error { +// Decode decodes ToolChoiceKnowledgeSearchType from json. +func (s *ToolChoiceKnowledgeSearchType) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ToolChoice to nil") + return errors.New("invalid: unable to decode ToolChoiceKnowledgeSearchType to nil") } - // Sum type type_discriminator. - switch t := d.Next(); t { - case jx.Object: - if err := s.TypedToolChoice.Decode(d); err != nil { - return err - } - s.Type = TypedToolChoiceToolChoice - case jx.String: - if err := s.ToolChoiceOptions.Decode(d); err != nil { - return err - } - s.Type = ToolChoiceOptionsToolChoice + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch ToolChoiceKnowledgeSearchType(v) { + case ToolChoiceKnowledgeSearchTypeKnowledgeSearch: + *s = ToolChoiceKnowledgeSearchTypeKnowledgeSearch default: - return errors.Errorf("unexpected json type %q", t) + *s = ToolChoiceKnowledgeSearchType(v) } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s ToolChoice) MarshalJSON() ([]byte, error) { +func (s ToolChoiceKnowledgeSearchType) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ToolChoice) UnmarshalJSON(data []byte) error { +func (s *ToolChoiceKnowledgeSearchType) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } // Encode implements json.Marshaler. -func (s *ToolChoiceFunction) Encode(e *jx.Encoder) { +func (s *ToolChoiceMcp) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } // encodeFields encodes fields. -func (s *ToolChoiceFunction) encodeFields(e *jx.Encoder) { - { - e.FieldStart("name") - e.Str(s.Name) - } +func (s *ToolChoiceMcp) encodeFields(e *jx.Encoder) { { e.FieldStart("type") s.Type.Encode(e) } + { + e.FieldStart("server_label") + e.Str(s.ServerLabel) + } + { + if s.Name.Set { + e.FieldStart("name") + s.Name.Encode(e) + } + } } -var jsonFieldsNameOfToolChoiceFunction = [2]string{ - 0: "name", - 1: "type", +var jsonFieldsNameOfToolChoiceMcp = [3]string{ + 0: "type", + 1: "server_label", + 2: "name", } -// Decode decodes ToolChoiceFunction from json. -func (s *ToolChoiceFunction) Decode(d *jx.Decoder) error { +// Decode decodes ToolChoiceMcp from json. +func (s *ToolChoiceMcp) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ToolChoiceFunction to nil") + return errors.New("invalid: unable to decode ToolChoiceMcp to nil") } var requiredBitSet [1]uint8 if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "name": + case "type": requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "server_label": + requiredBitSet[0] |= 1 << 1 if err := func() error { v, err := d.Str() - s.Name = string(v) + s.ServerLabel = string(v) if err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"name\"") + return errors.Wrap(err, "decode field \"server_label\"") } - case "type": - requiredBitSet[0] |= 1 << 1 + case "name": if err := func() error { - if err := s.Type.Decode(d); err != nil { + s.Name.Reset() + if err := s.Name.Decode(d); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"type\"") + return errors.Wrap(err, "decode field \"name\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode ToolChoiceFunction") + return errors.Wrap(err, "decode ToolChoiceMcp") } // Validate required fields. var failures []validate.FieldError @@ -33538,8 +34937,8 @@ func (s *ToolChoiceFunction) Decode(d *jx.Decoder) error { bitIdx := bits.TrailingZeros8(result) fieldIdx := i*8 + bitIdx var name string - if fieldIdx < len(jsonFieldsNameOfToolChoiceFunction) { - name = jsonFieldsNameOfToolChoiceFunction[fieldIdx] + if fieldIdx < len(jsonFieldsNameOfToolChoiceMcp) { + name = jsonFieldsNameOfToolChoiceMcp[fieldIdx] } else { name = strconv.Itoa(fieldIdx) } @@ -33560,79 +34959,121 @@ func (s *ToolChoiceFunction) Decode(d *jx.Decoder) error { } // MarshalJSON implements stdjson.Marshaler. -func (s *ToolChoiceFunction) MarshalJSON() ([]byte, error) { +func (s *ToolChoiceMcp) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ToolChoiceFunction) UnmarshalJSON(data []byte) error { +func (s *ToolChoiceMcp) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ToolChoiceFunctionType as json. -func (s ToolChoiceFunctionType) Encode(e *jx.Encoder) { +// Encode encodes ToolChoiceMcpType as json. +func (s ToolChoiceMcpType) Encode(e *jx.Encoder) { e.Str(string(s)) } -// Decode decodes ToolChoiceFunctionType from json. -func (s *ToolChoiceFunctionType) Decode(d *jx.Decoder) error { +// Decode decodes ToolChoiceMcpType from json. +func (s *ToolChoiceMcpType) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ToolChoiceFunctionType to nil") + return errors.New("invalid: unable to decode ToolChoiceMcpType to nil") } v, err := d.StrBytes() if err != nil { return err } // Try to use constant string. - switch ToolChoiceFunctionType(v) { - case ToolChoiceFunctionTypeFunction: - *s = ToolChoiceFunctionTypeFunction + switch ToolChoiceMcpType(v) { + case ToolChoiceMcpTypeMcp: + *s = ToolChoiceMcpTypeMcp default: - *s = ToolChoiceFunctionType(v) + *s = ToolChoiceMcpType(v) } return nil } // MarshalJSON implements stdjson.Marshaler. -func (s ToolChoiceFunctionType) MarshalJSON() ([]byte, error) { +func (s ToolChoiceMcpType) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ToolChoiceFunctionType) UnmarshalJSON(data []byte) error { +func (s *ToolChoiceMcpType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ToolChoiceOptions as json. +func (s ToolChoiceOptions) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes ToolChoiceOptions from json. +func (s *ToolChoiceOptions) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ToolChoiceOptions to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch ToolChoiceOptions(v) { + case ToolChoiceOptionsAuto: + *s = ToolChoiceOptionsAuto + case ToolChoiceOptionsNone: + *s = ToolChoiceOptionsNone + case ToolChoiceOptionsRequired: + *s = ToolChoiceOptionsRequired + default: + *s = ToolChoiceOptions(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ToolChoiceOptions) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ToolChoiceOptions) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } // Encode implements json.Marshaler. -func (s *ToolChoiceKnowledgeSearch) Encode(e *jx.Encoder) { +func (s *ToolChoiceWebSearch) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } // encodeFields encodes fields. -func (s *ToolChoiceKnowledgeSearch) encodeFields(e *jx.Encoder) { +func (s *ToolChoiceWebSearch) encodeFields(e *jx.Encoder) { { e.FieldStart("type") s.Type.Encode(e) } } -var jsonFieldsNameOfToolChoiceKnowledgeSearch = [1]string{ +var jsonFieldsNameOfToolChoiceWebSearch = [1]string{ 0: "type", } -// Decode decodes ToolChoiceKnowledgeSearch from json. -func (s *ToolChoiceKnowledgeSearch) Decode(d *jx.Decoder) error { +// Decode decodes ToolChoiceWebSearch from json. +func (s *ToolChoiceWebSearch) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ToolChoiceKnowledgeSearch to nil") + return errors.New("invalid: unable to decode ToolChoiceWebSearch to nil") } var requiredBitSet [1]uint8 @@ -33653,7 +35094,7 @@ func (s *ToolChoiceKnowledgeSearch) Decode(d *jx.Decoder) error { } return nil }); err != nil { - return errors.Wrap(err, "decode ToolChoiceKnowledgeSearch") + return errors.Wrap(err, "decode ToolChoiceWebSearch") } // Validate required fields. var failures []validate.FieldError @@ -33670,8 +35111,8 @@ func (s *ToolChoiceKnowledgeSearch) Decode(d *jx.Decoder) error { bitIdx := bits.TrailingZeros8(result) fieldIdx := i*8 + bitIdx var name string - if fieldIdx < len(jsonFieldsNameOfToolChoiceKnowledgeSearch) { - name = jsonFieldsNameOfToolChoiceKnowledgeSearch[fieldIdx] + if fieldIdx < len(jsonFieldsNameOfToolChoiceWebSearch) { + name = jsonFieldsNameOfToolChoiceWebSearch[fieldIdx] } else { name = strconv.Itoa(fieldIdx) } @@ -33692,139 +35133,119 @@ func (s *ToolChoiceKnowledgeSearch) Decode(d *jx.Decoder) error { } // MarshalJSON implements stdjson.Marshaler. -func (s *ToolChoiceKnowledgeSearch) MarshalJSON() ([]byte, error) { +func (s *ToolChoiceWebSearch) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ToolChoiceKnowledgeSearch) UnmarshalJSON(data []byte) error { +func (s *ToolChoiceWebSearch) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ToolChoiceKnowledgeSearchType as json. -func (s ToolChoiceKnowledgeSearchType) Encode(e *jx.Encoder) { +// Encode encodes ToolChoiceWebSearchType as json. +func (s ToolChoiceWebSearchType) Encode(e *jx.Encoder) { e.Str(string(s)) } -// Decode decodes ToolChoiceKnowledgeSearchType from json. -func (s *ToolChoiceKnowledgeSearchType) Decode(d *jx.Decoder) error { +// Decode decodes ToolChoiceWebSearchType from json. +func (s *ToolChoiceWebSearchType) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ToolChoiceKnowledgeSearchType to nil") + return errors.New("invalid: unable to decode ToolChoiceWebSearchType to nil") } v, err := d.StrBytes() if err != nil { return err } // Try to use constant string. - switch ToolChoiceKnowledgeSearchType(v) { - case ToolChoiceKnowledgeSearchTypeKnowledgeSearch: - *s = ToolChoiceKnowledgeSearchTypeKnowledgeSearch + switch ToolChoiceWebSearchType(v) { + case ToolChoiceWebSearchTypeWebSearch: + *s = ToolChoiceWebSearchTypeWebSearch default: - *s = ToolChoiceKnowledgeSearchType(v) + *s = ToolChoiceWebSearchType(v) } return nil } // MarshalJSON implements stdjson.Marshaler. -func (s ToolChoiceKnowledgeSearchType) MarshalJSON() ([]byte, error) { +func (s ToolChoiceWebSearchType) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ToolChoiceKnowledgeSearchType) UnmarshalJSON(data []byte) error { +func (s *ToolChoiceWebSearchType) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } // Encode implements json.Marshaler. -func (s *ToolChoiceMcp) Encode(e *jx.Encoder) { +func (s *ToolNameList) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } // encodeFields encodes fields. -func (s *ToolChoiceMcp) encodeFields(e *jx.Encoder) { - { - e.FieldStart("type") - s.Type.Encode(e) - } - { - e.FieldStart("server_label") - e.Str(s.ServerLabel) - } +func (s *ToolNameList) encodeFields(e *jx.Encoder) { { - if s.Name.Set { - e.FieldStart("name") - s.Name.Encode(e) + e.FieldStart("clear_tool_names") + e.ArrStart() + for _, elem := range s.ClearToolNames { + e.Str(elem) } + e.ArrEnd() } } -var jsonFieldsNameOfToolChoiceMcp = [3]string{ - 0: "type", - 1: "server_label", - 2: "name", +var jsonFieldsNameOfToolNameList = [1]string{ + 0: "clear_tool_names", } -// Decode decodes ToolChoiceMcp from json. -func (s *ToolChoiceMcp) Decode(d *jx.Decoder) error { +// Decode decodes ToolNameList from json. +func (s *ToolNameList) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ToolChoiceMcp to nil") + return errors.New("invalid: unable to decode ToolNameList to nil") } var requiredBitSet [1]uint8 if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "type": + case "clear_tool_names": requiredBitSet[0] |= 1 << 0 if err := func() error { - if err := s.Type.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"type\"") - } - case "server_label": - requiredBitSet[0] |= 1 << 1 - if err := func() error { - v, err := d.Str() - s.ServerLabel = string(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"server_label\"") - } - case "name": - if err := func() error { - s.Name.Reset() - if err := s.Name.Decode(d); err != nil { + s.ClearToolNames = make([]string, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem string + v, err := d.Str() + elem = string(v) + if err != nil { + return err + } + s.ClearToolNames = append(s.ClearToolNames, elem) + return nil + }); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"name\"") + return errors.Wrap(err, "decode field \"clear_tool_names\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode ToolChoiceMcp") + return errors.Wrap(err, "decode ToolNameList") } // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00000011, + 0b00000001, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -33836,8 +35257,8 @@ func (s *ToolChoiceMcp) Decode(d *jx.Decoder) error { bitIdx := bits.TrailingZeros8(result) fieldIdx := i*8 + bitIdx var name string - if fieldIdx < len(jsonFieldsNameOfToolChoiceMcp) { - name = jsonFieldsNameOfToolChoiceMcp[fieldIdx] + if fieldIdx < len(jsonFieldsNameOfToolNameList) { + name = jsonFieldsNameOfToolNameList[fieldIdx] } else { name = strconv.Itoa(fieldIdx) } @@ -33858,121 +35279,315 @@ func (s *ToolChoiceMcp) Decode(d *jx.Decoder) error { } // MarshalJSON implements stdjson.Marshaler. -func (s *ToolChoiceMcp) MarshalJSON() ([]byte, error) { +func (s *ToolNameList) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ToolChoiceMcp) UnmarshalJSON(data []byte) error { +func (s *ToolNameList) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ToolChoiceMcpType as json. -func (s ToolChoiceMcpType) Encode(e *jx.Encoder) { +// Encode encodes ToolSearchExecution as json. +func (s ToolSearchExecution) Encode(e *jx.Encoder) { e.Str(string(s)) } -// Decode decodes ToolChoiceMcpType from json. -func (s *ToolChoiceMcpType) Decode(d *jx.Decoder) error { +// Decode decodes ToolSearchExecution from json. +func (s *ToolSearchExecution) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ToolChoiceMcpType to nil") + return errors.New("invalid: unable to decode ToolSearchExecution to nil") } v, err := d.StrBytes() if err != nil { return err } // Try to use constant string. - switch ToolChoiceMcpType(v) { - case ToolChoiceMcpTypeMcp: - *s = ToolChoiceMcpTypeMcp + switch ToolSearchExecution(v) { + case ToolSearchExecutionServer: + *s = ToolSearchExecutionServer + case ToolSearchExecutionClient: + *s = ToolSearchExecutionClient + case ToolSearchExecutionEmpty: + *s = ToolSearchExecutionEmpty default: - *s = ToolChoiceMcpType(v) + *s = ToolSearchExecution(v) } return nil } // MarshalJSON implements stdjson.Marshaler. -func (s ToolChoiceMcpType) MarshalJSON() ([]byte, error) { +func (s ToolSearchExecution) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ToolChoiceMcpType) UnmarshalJSON(data []byte) error { +func (s *ToolSearchExecution) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ToolChoiceOptions as json. -func (s ToolChoiceOptions) Encode(e *jx.Encoder) { - e.Str(string(s)) +// Encode implements json.Marshaler. +func (s *ToolSearchResultTool) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() } -// Decode decodes ToolChoiceOptions from json. -func (s *ToolChoiceOptions) Decode(d *jx.Decoder) error { +// encodeFields encodes fields. +func (s *ToolSearchResultTool) encodeFields(e *jx.Encoder) { + s.OneOf.encodeFields(e) +} + +var jsonFieldsNameOfToolSearchResultTool = [0]string{} + +// Decode decodes ToolSearchResultTool from json. +func (s *ToolSearchResultTool) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ToolChoiceOptions to nil") + return errors.New("invalid: unable to decode ToolSearchResultTool to nil") } - v, err := d.StrBytes() + if err := d.Capture(func(d *jx.Decoder) error { + return s.OneOf.Decode(d) + }); err != nil { + return errors.Wrap(err, "decode field OneOf") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + default: + return d.Skip() + } + }); err != nil { + return errors.Wrap(err, "decode ToolSearchResultTool") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ToolSearchResultTool) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ToolSearchResultTool) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ToolSearchResultToolSum as json. +func (s ToolSearchResultToolSum) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +func (s ToolSearchResultToolSum) encodeFields(e *jx.Encoder) { + if s.Type == "" && s.unknownType != "" { + // Decode validated this private object. Replay its fields, including + // when called by an enclosing object with an inline union. + raw := strings.TrimSpace(s.unknownJSON) + e.RawStr(raw[1 : len(raw)-1]) + return + } + switch s.Type { + case FunctionToolToolSearchResultToolSum: + e.FieldStart("type") + e.Str("function") + { + s := s.FunctionTool + { + e.FieldStart("name") + e.Str(s.Name) + } + { + if s.Parameters.Set { + e.FieldStart("parameters") + s.Parameters.Encode(e) + } + } + { + if s.Description.Set { + e.FieldStart("description") + s.Description.Encode(e) + } + } + { + if s.DeferLoading.Set { + e.FieldStart("defer_loading") + s.DeferLoading.Encode(e) + } + } + } + case NamespaceToolToolSearchResultToolSum: + e.FieldStart("type") + e.Str("namespace") + { + s := s.NamespaceTool + { + e.FieldStart("name") + e.Str(s.Name) + } + { + if s.Description.Set { + e.FieldStart("description") + s.Description.Encode(e) + } + } + { + e.FieldStart("tools") + e.ArrStart() + for _, elem := range s.Tools { + elem.Encode(e) + } + e.ArrEnd() + } + } + } +} + +// Decode decodes ToolSearchResultToolSum from json. +func (s *ToolSearchResultToolSum) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ToolSearchResultToolSum to nil") + } + // Sum type discriminator. + if typ := d.Next(); typ != jx.Object { + return errors.Errorf("unexpected json type %q", typ) + } + // Buffer one complete value before peeking. Capture must not rewind a + // reader-backed decoder after its input buffer has been refilled. + raw, err := d.Raw() if err != nil { return err } - // Try to use constant string. - switch ToolChoiceOptions(v) { - case ToolChoiceOptionsAuto: - *s = ToolChoiceOptionsAuto - case ToolChoiceOptionsNone: - *s = ToolChoiceOptionsNone - case ToolChoiceOptionsRequired: - *s = ToolChoiceOptionsRequired + d = jx.DecodeBytes(raw) + s.unknownType = "" + s.unknownJSON = "" + var unknownType string + + var found bool + if err := d.Capture(func(d *jx.Decoder) error { + return d.ObjBytes(func(d *jx.Decoder, key []byte) error { + if found { + return d.Skip() + } + switch string(key) { + case "type": + typ, err := d.Str() + if err != nil { + return err + } + switch typ { + case "function": + s.Type = FunctionToolToolSearchResultToolSum + found = true + case "namespace": + s.Type = NamespaceToolToolSearchResultToolSum + found = true + default: + if typ == "" { + return errors.New("empty sum type discriminator") + } + unknownType = typ + found = true + } + return nil + } + return d.Skip() + }) + }); err != nil { + return errors.Wrap(err, "capture") + } + if unknownType != "" { + // Copy bytes: decoder buffers can be reused after this call. + // Reset known members so a reused object cannot expose stale data. + *s = ToolSearchResultToolSum{unknownType: unknownType, unknownJSON: string(raw)} + return nil + } + if !found { + return errors.New("unable to detect sum type variant") + } + switch s.Type { + case FunctionToolToolSearchResultToolSum: + if err := s.FunctionTool.Decode(d); err != nil { + return err + } + case NamespaceToolToolSearchResultToolSum: + if err := s.NamespaceTool.Decode(d); err != nil { + return err + } default: - *s = ToolChoiceOptions(v) + return errors.Errorf("inferred invalid type: %s", s.Type) } - return nil } // MarshalJSON implements stdjson.Marshaler. -func (s ToolChoiceOptions) MarshalJSON() ([]byte, error) { +func (s ToolSearchResultToolSum) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ToolChoiceOptions) UnmarshalJSON(data []byte) error { +func (s *ToolSearchResultToolSum) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } // Encode implements json.Marshaler. -func (s *ToolChoiceWebSearch) Encode(e *jx.Encoder) { +func (s *ToolSearchTool) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } // encodeFields encodes fields. -func (s *ToolChoiceWebSearch) encodeFields(e *jx.Encoder) { +func (s *ToolSearchTool) encodeFields(e *jx.Encoder) { { e.FieldStart("type") s.Type.Encode(e) } + { + if s.Execution.Set { + e.FieldStart("execution") + s.Execution.Encode(e) + } + } + { + if s.Description.Set { + e.FieldStart("description") + s.Description.Encode(e) + } + } + { + if s.Parameters.Set { + e.FieldStart("parameters") + s.Parameters.Encode(e) + } + } } -var jsonFieldsNameOfToolChoiceWebSearch = [1]string{ +var jsonFieldsNameOfToolSearchTool = [4]string{ 0: "type", + 1: "execution", + 2: "description", + 3: "parameters", } -// Decode decodes ToolChoiceWebSearch from json. -func (s *ToolChoiceWebSearch) Decode(d *jx.Decoder) error { +// Decode decodes ToolSearchTool from json. +func (s *ToolSearchTool) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ToolChoiceWebSearch to nil") + return errors.New("invalid: unable to decode ToolSearchTool to nil") } var requiredBitSet [1]uint8 @@ -33988,12 +35603,42 @@ func (s *ToolChoiceWebSearch) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"type\"") } + case "execution": + if err := func() error { + s.Execution.Reset() + if err := s.Execution.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"execution\"") + } + case "description": + if err := func() error { + s.Description.Reset() + if err := s.Description.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"description\"") + } + case "parameters": + if err := func() error { + s.Parameters.Reset() + if err := s.Parameters.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"parameters\"") + } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode ToolChoiceWebSearch") + return errors.Wrap(err, "decode ToolSearchTool") } // Validate required fields. var failures []validate.FieldError @@ -34010,8 +35655,8 @@ func (s *ToolChoiceWebSearch) Decode(d *jx.Decoder) error { bitIdx := bits.TrailingZeros8(result) fieldIdx := i*8 + bitIdx var name string - if fieldIdx < len(jsonFieldsNameOfToolChoiceWebSearch) { - name = jsonFieldsNameOfToolChoiceWebSearch[fieldIdx] + if fieldIdx < len(jsonFieldsNameOfToolSearchTool) { + name = jsonFieldsNameOfToolSearchTool[fieldIdx] } else { name = strconv.Itoa(fieldIdx) } @@ -34032,160 +35677,110 @@ func (s *ToolChoiceWebSearch) Decode(d *jx.Decoder) error { } // MarshalJSON implements stdjson.Marshaler. -func (s *ToolChoiceWebSearch) MarshalJSON() ([]byte, error) { +func (s *ToolSearchTool) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ToolChoiceWebSearch) UnmarshalJSON(data []byte) error { +func (s *ToolSearchTool) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ToolChoiceWebSearchType as json. -func (s ToolChoiceWebSearchType) Encode(e *jx.Encoder) { - e.Str(string(s)) +// Encode implements json.Marshaler. +func (s ToolSearchToolParameters) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() } -// Decode decodes ToolChoiceWebSearchType from json. -func (s *ToolChoiceWebSearchType) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode ToolChoiceWebSearchType to nil") +// encodeFields implements json.Marshaler. +func (s ToolSearchToolParameters) encodeFields(e *jx.Encoder) { + for k, elem := range s { + e.FieldStart(k) + + if len(elem) != 0 { + e.Raw(elem) + } } - v, err := d.StrBytes() - if err != nil { - return err +} + +// Decode decodes ToolSearchToolParameters from json. +func (s *ToolSearchToolParameters) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ToolSearchToolParameters to nil") } - // Try to use constant string. - switch ToolChoiceWebSearchType(v) { - case ToolChoiceWebSearchTypeWebSearch: - *s = ToolChoiceWebSearchTypeWebSearch - default: - *s = ToolChoiceWebSearchType(v) + m := s.init() + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + var elem jx.Raw + if err := func() error { + v, err := d.RawAppend(nil) + elem = jx.Raw(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrapf(err, "decode field %q", k) + } + m[string(k)] = elem + return nil + }); err != nil { + return errors.Wrap(err, "decode ToolSearchToolParameters") } return nil } // MarshalJSON implements stdjson.Marshaler. -func (s ToolChoiceWebSearchType) MarshalJSON() ([]byte, error) { +func (s ToolSearchToolParameters) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ToolChoiceWebSearchType) UnmarshalJSON(data []byte) error { +func (s *ToolSearchToolParameters) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode implements json.Marshaler. -func (s *ToolNameList) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() -} - -// encodeFields encodes fields. -func (s *ToolNameList) encodeFields(e *jx.Encoder) { - { - e.FieldStart("clear_tool_names") - e.ArrStart() - for _, elem := range s.ClearToolNames { - e.Str(elem) - } - e.ArrEnd() - } -} - -var jsonFieldsNameOfToolNameList = [1]string{ - 0: "clear_tool_names", +// Encode encodes ToolSearchToolType as json. +func (s ToolSearchToolType) Encode(e *jx.Encoder) { + e.Str(string(s)) } -// Decode decodes ToolNameList from json. -func (s *ToolNameList) Decode(d *jx.Decoder) error { +// Decode decodes ToolSearchToolType from json. +func (s *ToolSearchToolType) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ToolNameList to nil") - } - var requiredBitSet [1]uint8 - - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - case "clear_tool_names": - requiredBitSet[0] |= 1 << 0 - if err := func() error { - s.ClearToolNames = make([]string, 0) - if err := d.Arr(func(d *jx.Decoder) error { - var elem string - v, err := d.Str() - elem = string(v) - if err != nil { - return err - } - s.ClearToolNames = append(s.ClearToolNames, elem) - return nil - }); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"clear_tool_names\"") - } - default: - return d.Skip() - } - return nil - }); err != nil { - return errors.Wrap(err, "decode ToolNameList") + return errors.New("invalid: unable to decode ToolSearchToolType to nil") } - // Validate required fields. - var failures []validate.FieldError - for i, mask := range [1]uint8{ - 0b00000001, - } { - if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { - // Mask only required fields and check equality to mask using XOR. - // - // If XOR result is not zero, result is not equal to expected, so some fields are missed. - // Bits of fields which would be set are actually bits of missed fields. - missed := bits.OnesCount8(result) - for bitN := 0; bitN < missed; bitN++ { - bitIdx := bits.TrailingZeros8(result) - fieldIdx := i*8 + bitIdx - var name string - if fieldIdx < len(jsonFieldsNameOfToolNameList) { - name = jsonFieldsNameOfToolNameList[fieldIdx] - } else { - name = strconv.Itoa(fieldIdx) - } - failures = append(failures, validate.FieldError{ - Name: name, - Error: validate.ErrFieldRequired, - }) - // Reset bit. - result &^= 1 << bitIdx - } - } + v, err := d.StrBytes() + if err != nil { + return err } - if len(failures) > 0 { - return &validate.Error{Fields: failures} + // Try to use constant string. + switch ToolSearchToolType(v) { + case ToolSearchToolTypeToolSearch: + *s = ToolSearchToolTypeToolSearch + default: + *s = ToolSearchToolType(v) } return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *ToolNameList) MarshalJSON() ([]byte, error) { +func (s ToolSearchToolType) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ToolNameList) UnmarshalJSON(data []byte) error { +func (s *ToolSearchToolType) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } @@ -34227,6 +35822,60 @@ func (s ToolSum) encodeFields(e *jx.Encoder) { s.Description.Encode(e) } } + { + if s.DeferLoading.Set { + e.FieldStart("defer_loading") + s.DeferLoading.Encode(e) + } + } + } + case NamespaceToolToolSum: + e.FieldStart("type") + e.Str("namespace") + { + s := s.NamespaceTool + { + e.FieldStart("name") + e.Str(s.Name) + } + { + if s.Description.Set { + e.FieldStart("description") + s.Description.Encode(e) + } + } + { + e.FieldStart("tools") + e.ArrStart() + for _, elem := range s.Tools { + elem.Encode(e) + } + e.ArrEnd() + } + } + case ToolSearchToolToolSum: + e.FieldStart("type") + e.Str("tool_search") + { + s := s.ToolSearchTool + { + if s.Execution.Set { + e.FieldStart("execution") + s.Execution.Encode(e) + } + } + { + if s.Description.Set { + e.FieldStart("description") + s.Description.Encode(e) + } + } + { + if s.Parameters.Set { + e.FieldStart("parameters") + s.Parameters.Encode(e) + } + } } case WebSearchToolToolSum: e.FieldStart("type") @@ -34431,6 +36080,12 @@ func (s *ToolSum) Decode(d *jx.Decoder) error { case "function": s.Type = FunctionToolToolSum found = true + case "namespace": + s.Type = NamespaceToolToolSum + found = true + case "tool_search": + s.Type = ToolSearchToolToolSum + found = true case "web_search": s.Type = WebSearchToolToolSum found = true @@ -34474,6 +36129,14 @@ func (s *ToolSum) Decode(d *jx.Decoder) error { if err := s.FunctionTool.Decode(d); err != nil { return err } + case NamespaceToolToolSum: + if err := s.NamespaceTool.Decode(d); err != nil { + return err + } + case ToolSearchToolToolSum: + if err := s.ToolSearchTool.Decode(d); err != nil { + return err + } case WebSearchToolToolSum: if err := s.WebSearchTool.Decode(d); err != nil { return err diff --git a/arkruntime/model/responses/oas_schemas_gen.go b/arkruntime/model/responses/oas_schemas_gen.go index aa70935..c3cf097 100644 --- a/arkruntime/model/responses/oas_schemas_gen.go +++ b/arkruntime/model/responses/oas_schemas_gen.go @@ -2560,6 +2560,8 @@ type FunctionTool struct { // A description of the function. // Used by the model to determine whether or not to call the function. Description OptString `json:"description"` + // Defer the full schema until tool_search loads this function. Defaults to false. + DeferLoading OptBool `json:"defer_loading"` } // GetName returns the value of Name. @@ -2582,6 +2584,11 @@ func (s *FunctionTool) GetDescription() OptString { return s.Description } +// GetDeferLoading returns the value of DeferLoading. +func (s *FunctionTool) GetDeferLoading() OptBool { + return s.DeferLoading +} + // SetName sets the value of Name. func (s *FunctionTool) SetName(val string) { s.Name = val @@ -2602,6 +2609,11 @@ func (s *FunctionTool) SetDescription(val OptString) { s.Description = val } +// SetDeferLoading sets the value of DeferLoading. +func (s *FunctionTool) SetDeferLoading(val OptBool) { + s.DeferLoading = val +} + // A JSON schema object describing the parameters of the function. type FunctionToolParameters map[string]jx.Raw @@ -2890,6 +2902,8 @@ type InputItemSum struct { Type InputItemSumType // switch on this field ItemEasyMessage ItemEasyMessage ItemFunctionToolCall ItemFunctionToolCall + ItemToolSearchCall ItemToolSearchCall + ItemToolSearchOutput ItemToolSearchOutput ItemFunctionToolCallOutput ItemFunctionToolCallOutput ItemReasoning ItemReasoning ItemFunctionMcpApprovalRequest ItemFunctionMcpApprovalRequest @@ -2915,6 +2929,8 @@ type InputItemSumType string const ( ItemEasyMessageInputItemSum InputItemSumType = "message" ItemFunctionToolCallInputItemSum InputItemSumType = "function_call" + ItemToolSearchCallInputItemSum InputItemSumType = "tool_search_call" + ItemToolSearchOutputInputItemSum InputItemSumType = "tool_search_output" ItemFunctionToolCallOutputInputItemSum InputItemSumType = "function_call_output" ItemReasoningInputItemSum InputItemSumType = "reasoning" ItemFunctionMcpApprovalRequestInputItemSum InputItemSumType = "mcp_approval_request" @@ -2931,6 +2947,14 @@ func (s InputItemSum) IsItemFunctionToolCall() bool { return s.Type == ItemFunctionToolCallInputItemSum } +// IsItemToolSearchCall reports whether InputItemSum is ItemToolSearchCall. +func (s InputItemSum) IsItemToolSearchCall() bool { return s.Type == ItemToolSearchCallInputItemSum } + +// IsItemToolSearchOutput reports whether InputItemSum is ItemToolSearchOutput. +func (s InputItemSum) IsItemToolSearchOutput() bool { + return s.Type == ItemToolSearchOutputInputItemSum +} + // IsItemFunctionToolCallOutput reports whether InputItemSum is ItemFunctionToolCallOutput. func (s InputItemSum) IsItemFunctionToolCallOutput() bool { return s.Type == ItemFunctionToolCallOutputInputItemSum @@ -3003,6 +3027,52 @@ func NewItemFunctionToolCallInputItemSum(v ItemFunctionToolCall) InputItemSum { return s } +// SetItemToolSearchCall sets InputItemSum to ItemToolSearchCall. +func (s *InputItemSum) SetItemToolSearchCall(v ItemToolSearchCall) { + s.Type = ItemToolSearchCallInputItemSum + s.unknownType = "" + s.unknownJSON = "" + s.ItemToolSearchCall = v +} + +// GetItemToolSearchCall returns ItemToolSearchCall and true boolean if InputItemSum is ItemToolSearchCall. +func (s InputItemSum) GetItemToolSearchCall() (v ItemToolSearchCall, ok bool) { + if !s.IsItemToolSearchCall() { + return v, false + } + return s.ItemToolSearchCall, true +} + +// NewItemToolSearchCallInputItemSum returns new InputItemSum from ItemToolSearchCall. +func NewItemToolSearchCallInputItemSum(v ItemToolSearchCall) InputItemSum { + var s InputItemSum + s.SetItemToolSearchCall(v) + return s +} + +// SetItemToolSearchOutput sets InputItemSum to ItemToolSearchOutput. +func (s *InputItemSum) SetItemToolSearchOutput(v ItemToolSearchOutput) { + s.Type = ItemToolSearchOutputInputItemSum + s.unknownType = "" + s.unknownJSON = "" + s.ItemToolSearchOutput = v +} + +// GetItemToolSearchOutput returns ItemToolSearchOutput and true boolean if InputItemSum is ItemToolSearchOutput. +func (s InputItemSum) GetItemToolSearchOutput() (v ItemToolSearchOutput, ok bool) { + if !s.IsItemToolSearchOutput() { + return v, false + } + return s.ItemToolSearchOutput, true +} + +// NewItemToolSearchOutputInputItemSum returns new InputItemSum from ItemToolSearchOutput. +func NewItemToolSearchOutputInputItemSum(v ItemToolSearchOutput) InputItemSum { + var s InputItemSum + s.SetItemToolSearchOutput(v) + return s +} + // SetItemFunctionToolCallOutput sets InputItemSum to ItemFunctionToolCallOutput. func (s *InputItemSum) SetItemFunctionToolCallOutput(v ItemFunctionToolCallOutput) { s.Type = ItemFunctionToolCallOutputInputItemSum @@ -4087,6 +4157,8 @@ type ItemFunctionToolCall struct { CallID OptString `json:"call_id"` // The name of the function to call. Name OptString `json:"name"` + // Namespace of the called function, omitted for top-level functions. + Namespace OptString `json:"namespace"` // The status of the item. Status OptItemStatus `json:"status"` } @@ -4116,6 +4188,11 @@ func (s *ItemFunctionToolCall) GetName() OptString { return s.Name } +// GetNamespace returns the value of Namespace. +func (s *ItemFunctionToolCall) GetNamespace() OptString { + return s.Namespace +} + // GetStatus returns the value of Status. func (s *ItemFunctionToolCall) GetStatus() OptItemStatus { return s.Status @@ -4146,6 +4223,11 @@ func (s *ItemFunctionToolCall) SetName(val OptString) { s.Name = val } +// SetNamespace sets the value of Namespace. +func (s *ItemFunctionToolCall) SetNamespace(val OptString) { + s.Namespace = val +} + // SetStatus sets the value of Status. func (s *ItemFunctionToolCall) SetStatus(val OptItemStatus) { s.Status = val @@ -4153,11 +4235,18 @@ func (s *ItemFunctionToolCall) SetStatus(val OptItemStatus) { // Ref: #/components/schemas/ItemFunctionToolCallOutput type ItemFunctionToolCallOutput struct { - Type ItemFunctionToolCallOutputType `json:"type"` - CallID OptString `json:"call_id"` - Output OptMessageContent `json:"output"` - ID OptString `json:"id"` - Status OptItemStatus `json:"status"` + // Namespace of the function whose result is being supplied. + Namespace OptString `json:"namespace"` + Type ItemFunctionToolCallOutputType `json:"type"` + CallID OptString `json:"call_id"` + Output OptMessageContent `json:"output"` + ID OptString `json:"id"` + Status OptItemStatus `json:"status"` +} + +// GetNamespace returns the value of Namespace. +func (s *ItemFunctionToolCallOutput) GetNamespace() OptString { + return s.Namespace } // GetType returns the value of Type. @@ -4185,6 +4274,11 @@ func (s *ItemFunctionToolCallOutput) GetStatus() OptItemStatus { return s.Status } +// SetNamespace sets the value of Namespace. +func (s *ItemFunctionToolCallOutput) SetNamespace(val OptString) { + s.Namespace = val +} + // SetType sets the value of Type. func (s *ItemFunctionToolCallOutput) SetType(val ItemFunctionToolCallOutputType) { s.Type = val @@ -4665,6 +4759,236 @@ func (s *ItemStatus) UnmarshalText(data []byte) error { } } +// Ref: #/components/schemas/ItemToolSearchCall +type ItemToolSearchCall struct { + Type ItemToolSearchCallType `json:"type"` + ID OptString `json:"id"` + Status OptItemStatus `json:"status"` + // JSON object (not an encoded string). Completed calls contain a nonempty paths array; added + // streaming items initially contain {}. + Arguments ItemToolSearchCallArguments `json:"arguments"` + // Hosted search emits null. Replayed hosted history must omit this field or set it to null. + CallID OptNilString `json:"call_id"` + // Hosted search emits server. Omitted or empty execution defaults to server when replaying history. + // Client history is not supported. + Execution OptToolSearchExecution `json:"execution"` +} + +// GetType returns the value of Type. +func (s *ItemToolSearchCall) GetType() ItemToolSearchCallType { + return s.Type +} + +// GetID returns the value of ID. +func (s *ItemToolSearchCall) GetID() OptString { + return s.ID +} + +// GetStatus returns the value of Status. +func (s *ItemToolSearchCall) GetStatus() OptItemStatus { + return s.Status +} + +// GetArguments returns the value of Arguments. +func (s *ItemToolSearchCall) GetArguments() ItemToolSearchCallArguments { + return s.Arguments +} + +// GetCallID returns the value of CallID. +func (s *ItemToolSearchCall) GetCallID() OptNilString { + return s.CallID +} + +// GetExecution returns the value of Execution. +func (s *ItemToolSearchCall) GetExecution() OptToolSearchExecution { + return s.Execution +} + +// SetType sets the value of Type. +func (s *ItemToolSearchCall) SetType(val ItemToolSearchCallType) { + s.Type = val +} + +// SetID sets the value of ID. +func (s *ItemToolSearchCall) SetID(val OptString) { + s.ID = val +} + +// SetStatus sets the value of Status. +func (s *ItemToolSearchCall) SetStatus(val OptItemStatus) { + s.Status = val +} + +// SetArguments sets the value of Arguments. +func (s *ItemToolSearchCall) SetArguments(val ItemToolSearchCallArguments) { + s.Arguments = val +} + +// SetCallID sets the value of CallID. +func (s *ItemToolSearchCall) SetCallID(val OptNilString) { + s.CallID = val +} + +// SetExecution sets the value of Execution. +func (s *ItemToolSearchCall) SetExecution(val OptToolSearchExecution) { + s.Execution = val +} + +// JSON object (not an encoded string). Completed calls contain a nonempty paths array; added +// streaming items initially contain {}. +type ItemToolSearchCallArguments map[string]jx.Raw + +func (s *ItemToolSearchCallArguments) init() ItemToolSearchCallArguments { + m := *s + if m == nil { + m = map[string]jx.Raw{} + *s = m + } + return m +} + +type ItemToolSearchCallType string + +const ( + ItemToolSearchCallTypeToolSearchCall ItemToolSearchCallType = "tool_search_call" +) + +// AllValues returns all ItemToolSearchCallType values. +func (ItemToolSearchCallType) AllValues() []ItemToolSearchCallType { + return []ItemToolSearchCallType{ + ItemToolSearchCallTypeToolSearchCall, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s ItemToolSearchCallType) MarshalText() ([]byte, error) { + switch s { + case ItemToolSearchCallTypeToolSearchCall: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *ItemToolSearchCallType) UnmarshalText(data []byte) error { + switch ItemToolSearchCallType(data) { + case ItemToolSearchCallTypeToolSearchCall: + *s = ItemToolSearchCallTypeToolSearchCall + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// Ref: #/components/schemas/ItemToolSearchOutput +type ItemToolSearchOutput struct { + Type ItemToolSearchOutputType `json:"type"` + ID OptString `json:"id"` + Status OptItemStatus `json:"status"` + // Hosted search emits null. Replayed hosted history must omit this field or set it to null. + CallID OptNilString `json:"call_id"` + // Hosted search emits server; omitted or empty execution defaults to server on replay. + Execution OptToolSearchExecution `json:"execution"` + // Loaded definitions, including their complete parameter schemas. Replayed history requires a + // nonempty list following the corresponding search call. + Tools []ToolSearchResultTool `json:"tools"` +} + +// GetType returns the value of Type. +func (s *ItemToolSearchOutput) GetType() ItemToolSearchOutputType { + return s.Type +} + +// GetID returns the value of ID. +func (s *ItemToolSearchOutput) GetID() OptString { + return s.ID +} + +// GetStatus returns the value of Status. +func (s *ItemToolSearchOutput) GetStatus() OptItemStatus { + return s.Status +} + +// GetCallID returns the value of CallID. +func (s *ItemToolSearchOutput) GetCallID() OptNilString { + return s.CallID +} + +// GetExecution returns the value of Execution. +func (s *ItemToolSearchOutput) GetExecution() OptToolSearchExecution { + return s.Execution +} + +// GetTools returns the value of Tools. +func (s *ItemToolSearchOutput) GetTools() []ToolSearchResultTool { + return s.Tools +} + +// SetType sets the value of Type. +func (s *ItemToolSearchOutput) SetType(val ItemToolSearchOutputType) { + s.Type = val +} + +// SetID sets the value of ID. +func (s *ItemToolSearchOutput) SetID(val OptString) { + s.ID = val +} + +// SetStatus sets the value of Status. +func (s *ItemToolSearchOutput) SetStatus(val OptItemStatus) { + s.Status = val +} + +// SetCallID sets the value of CallID. +func (s *ItemToolSearchOutput) SetCallID(val OptNilString) { + s.CallID = val +} + +// SetExecution sets the value of Execution. +func (s *ItemToolSearchOutput) SetExecution(val OptToolSearchExecution) { + s.Execution = val +} + +// SetTools sets the value of Tools. +func (s *ItemToolSearchOutput) SetTools(val []ToolSearchResultTool) { + s.Tools = val +} + +type ItemToolSearchOutputType string + +const ( + ItemToolSearchOutputTypeToolSearchOutput ItemToolSearchOutputType = "tool_search_output" +) + +// AllValues returns all ItemToolSearchOutputType values. +func (ItemToolSearchOutputType) AllValues() []ItemToolSearchOutputType { + return []ItemToolSearchOutputType{ + ItemToolSearchOutputTypeToolSearchOutput, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s ItemToolSearchOutputType) MarshalText() ([]byte, error) { + switch s { + case ItemToolSearchOutputTypeToolSearchOutput: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *ItemToolSearchOutputType) UnmarshalText(data []byte) error { + switch ItemToolSearchOutputType(data) { + case ItemToolSearchOutputTypeToolSearchOutput: + *s = ItemToolSearchOutputTypeToolSearchOutput + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + // Ref: #/components/schemas/ItemTranscription type ItemTranscription struct { ID OptString `json:"id"` @@ -5571,6 +5895,90 @@ func (s *MessageRole) UnmarshalText(data []byte) error { } } +// Ref: #/components/schemas/NamespaceTool +type NamespaceTool struct { + Type NamespaceToolType `json:"type"` + // Namespace used to qualify function calls. + Name string `json:"name"` + Description OptString `json:"description"` + // Functions in this namespace. Nested namespaces are not supported. + Tools []FunctionTool `json:"tools"` +} + +// GetType returns the value of Type. +func (s *NamespaceTool) GetType() NamespaceToolType { + return s.Type +} + +// GetName returns the value of Name. +func (s *NamespaceTool) GetName() string { + return s.Name +} + +// GetDescription returns the value of Description. +func (s *NamespaceTool) GetDescription() OptString { + return s.Description +} + +// GetTools returns the value of Tools. +func (s *NamespaceTool) GetTools() []FunctionTool { + return s.Tools +} + +// SetType sets the value of Type. +func (s *NamespaceTool) SetType(val NamespaceToolType) { + s.Type = val +} + +// SetName sets the value of Name. +func (s *NamespaceTool) SetName(val string) { + s.Name = val +} + +// SetDescription sets the value of Description. +func (s *NamespaceTool) SetDescription(val OptString) { + s.Description = val +} + +// SetTools sets the value of Tools. +func (s *NamespaceTool) SetTools(val []FunctionTool) { + s.Tools = val +} + +type NamespaceToolType string + +const ( + NamespaceToolTypeNamespace NamespaceToolType = "namespace" +) + +// AllValues returns all NamespaceToolType values. +func (NamespaceToolType) AllValues() []NamespaceToolType { + return []NamespaceToolType{ + NamespaceToolTypeNamespace, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s NamespaceToolType) MarshalText() ([]byte, error) { + switch s { + case NamespaceToolTypeNamespace: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *NamespaceToolType) UnmarshalText(data []byte) error { + switch NamespaceToolType(data) { + case NamespaceToolTypeNamespace: + *s = NamespaceToolTypeNamespace + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + // NewOptAudioChunkingStrategy returns new OptAudioChunkingStrategy with value set to v. func NewOptAudioChunkingStrategy(v AudioChunkingStrategy) OptAudioChunkingStrategy { return OptAudioChunkingStrategy{ @@ -7043,6 +7451,132 @@ func (o OptMessageRole) Or(d MessageRole) MessageRole { return d } +// NewOptNilString returns new OptNilString with value set to v. +func NewOptNilString(v string) OptNilString { + return OptNilString{ + Value: v, + Set: true, + } +} + +// OptNilString is optional nullable string. +type OptNilString struct { + Value string + Set bool + Null bool +} + +// IsSet returns true if OptNilString was set. +func (o OptNilString) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptNilString) Reset() { + var v string + o.Value = v + o.Set = false + o.Null = false +} + +// SetTo sets value to v. +func (o *OptNilString) SetTo(v string) { + o.Set = true + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o OptNilString) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *OptNilString) SetToNull() { + o.Set = true + o.Null = true + var v string + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptNilString) Get() (v string, ok bool) { + if o.Null { + return v, false + } + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptNilString) Or(d string) string { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptNilToolSearchExecution returns new OptNilToolSearchExecution with value set to v. +func NewOptNilToolSearchExecution(v ToolSearchExecution) OptNilToolSearchExecution { + return OptNilToolSearchExecution{ + Value: v, + Set: true, + } +} + +// OptNilToolSearchExecution is optional nullable ToolSearchExecution. +type OptNilToolSearchExecution struct { + Value ToolSearchExecution + Set bool + Null bool +} + +// IsSet returns true if OptNilToolSearchExecution was set. +func (o OptNilToolSearchExecution) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptNilToolSearchExecution) Reset() { + var v ToolSearchExecution + o.Value = v + o.Set = false + o.Null = false +} + +// SetTo sets value to v. +func (o *OptNilToolSearchExecution) SetTo(v ToolSearchExecution) { + o.Set = true + o.Null = false + o.Value = v +} + +// IsNull returns true if value is Null. +func (o OptNilToolSearchExecution) IsNull() bool { return o.Null } + +// SetToNull sets value to null. +func (o *OptNilToolSearchExecution) SetToNull() { + o.Set = true + o.Null = true + var v ToolSearchExecution + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptNilToolSearchExecution) Get() (v ToolSearchExecution, ok bool) { + if o.Null { + return v, false + } + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptNilToolSearchExecution) Or(d ToolSearchExecution) ToolSearchExecution { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptOrder returns new OptOrder with value set to v. func NewOptOrder(v Order) OptOrder { return OptOrder{ @@ -7758,13 +8292,105 @@ func (o *OptThinkingMode) Reset() { } // SetTo sets value to v. -func (o *OptThinkingMode) SetTo(v ThinkingMode) { +func (o *OptThinkingMode) SetTo(v ThinkingMode) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptThinkingMode) Get() (v ThinkingMode, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptThinkingMode) Or(d ThinkingMode) ThinkingMode { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptThinkingTurnsParam returns new OptThinkingTurnsParam with value set to v. +func NewOptThinkingTurnsParam(v ThinkingTurnsParam) OptThinkingTurnsParam { + return OptThinkingTurnsParam{ + Value: v, + Set: true, + } +} + +// OptThinkingTurnsParam is optional ThinkingTurnsParam. +type OptThinkingTurnsParam struct { + Value ThinkingTurnsParam + Set bool +} + +// IsSet returns true if OptThinkingTurnsParam was set. +func (o OptThinkingTurnsParam) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptThinkingTurnsParam) Reset() { + var v ThinkingTurnsParam + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptThinkingTurnsParam) SetTo(v ThinkingTurnsParam) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptThinkingTurnsParam) Get() (v ThinkingTurnsParam, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptThinkingTurnsParam) Or(d ThinkingTurnsParam) ThinkingTurnsParam { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptToolChoice returns new OptToolChoice with value set to v. +func NewOptToolChoice(v ToolChoice) OptToolChoice { + return OptToolChoice{ + Value: v, + Set: true, + } +} + +// OptToolChoice is optional ToolChoice. +type OptToolChoice struct { + Value ToolChoice + Set bool +} + +// IsSet returns true if OptToolChoice was set. +func (o OptToolChoice) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptToolChoice) Reset() { + var v ToolChoice + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptToolChoice) SetTo(v ToolChoice) { o.Set = true o.Value = v } // Get returns value and boolean that denotes whether value was set. -func (o OptThinkingMode) Get() (v ThinkingMode, ok bool) { +func (o OptToolChoice) Get() (v ToolChoice, ok bool) { if !o.Set { return v, false } @@ -7772,45 +8398,45 @@ func (o OptThinkingMode) Get() (v ThinkingMode, ok bool) { } // Or returns value if set, or given parameter if does not. -func (o OptThinkingMode) Or(d ThinkingMode) ThinkingMode { +func (o OptToolChoice) Or(d ToolChoice) ToolChoice { if v, ok := o.Get(); ok { return v } return d } -// NewOptThinkingTurnsParam returns new OptThinkingTurnsParam with value set to v. -func NewOptThinkingTurnsParam(v ThinkingTurnsParam) OptThinkingTurnsParam { - return OptThinkingTurnsParam{ +// NewOptToolNameList returns new OptToolNameList with value set to v. +func NewOptToolNameList(v ToolNameList) OptToolNameList { + return OptToolNameList{ Value: v, Set: true, } } -// OptThinkingTurnsParam is optional ThinkingTurnsParam. -type OptThinkingTurnsParam struct { - Value ThinkingTurnsParam +// OptToolNameList is optional ToolNameList. +type OptToolNameList struct { + Value ToolNameList Set bool } -// IsSet returns true if OptThinkingTurnsParam was set. -func (o OptThinkingTurnsParam) IsSet() bool { return o.Set } +// IsSet returns true if OptToolNameList was set. +func (o OptToolNameList) IsSet() bool { return o.Set } // Reset unsets value. -func (o *OptThinkingTurnsParam) Reset() { - var v ThinkingTurnsParam +func (o *OptToolNameList) Reset() { + var v ToolNameList o.Value = v o.Set = false } // SetTo sets value to v. -func (o *OptThinkingTurnsParam) SetTo(v ThinkingTurnsParam) { +func (o *OptToolNameList) SetTo(v ToolNameList) { o.Set = true o.Value = v } // Get returns value and boolean that denotes whether value was set. -func (o OptThinkingTurnsParam) Get() (v ThinkingTurnsParam, ok bool) { +func (o OptToolNameList) Get() (v ToolNameList, ok bool) { if !o.Set { return v, false } @@ -7818,45 +8444,45 @@ func (o OptThinkingTurnsParam) Get() (v ThinkingTurnsParam, ok bool) { } // Or returns value if set, or given parameter if does not. -func (o OptThinkingTurnsParam) Or(d ThinkingTurnsParam) ThinkingTurnsParam { +func (o OptToolNameList) Or(d ToolNameList) ToolNameList { if v, ok := o.Get(); ok { return v } return d } -// NewOptToolChoice returns new OptToolChoice with value set to v. -func NewOptToolChoice(v ToolChoice) OptToolChoice { - return OptToolChoice{ +// NewOptToolSearchExecution returns new OptToolSearchExecution with value set to v. +func NewOptToolSearchExecution(v ToolSearchExecution) OptToolSearchExecution { + return OptToolSearchExecution{ Value: v, Set: true, } } -// OptToolChoice is optional ToolChoice. -type OptToolChoice struct { - Value ToolChoice +// OptToolSearchExecution is optional ToolSearchExecution. +type OptToolSearchExecution struct { + Value ToolSearchExecution Set bool } -// IsSet returns true if OptToolChoice was set. -func (o OptToolChoice) IsSet() bool { return o.Set } +// IsSet returns true if OptToolSearchExecution was set. +func (o OptToolSearchExecution) IsSet() bool { return o.Set } // Reset unsets value. -func (o *OptToolChoice) Reset() { - var v ToolChoice +func (o *OptToolSearchExecution) Reset() { + var v ToolSearchExecution o.Value = v o.Set = false } // SetTo sets value to v. -func (o *OptToolChoice) SetTo(v ToolChoice) { +func (o *OptToolSearchExecution) SetTo(v ToolSearchExecution) { o.Set = true o.Value = v } // Get returns value and boolean that denotes whether value was set. -func (o OptToolChoice) Get() (v ToolChoice, ok bool) { +func (o OptToolSearchExecution) Get() (v ToolSearchExecution, ok bool) { if !o.Set { return v, false } @@ -7864,45 +8490,45 @@ func (o OptToolChoice) Get() (v ToolChoice, ok bool) { } // Or returns value if set, or given parameter if does not. -func (o OptToolChoice) Or(d ToolChoice) ToolChoice { +func (o OptToolSearchExecution) Or(d ToolSearchExecution) ToolSearchExecution { if v, ok := o.Get(); ok { return v } return d } -// NewOptToolNameList returns new OptToolNameList with value set to v. -func NewOptToolNameList(v ToolNameList) OptToolNameList { - return OptToolNameList{ +// NewOptToolSearchToolParameters returns new OptToolSearchToolParameters with value set to v. +func NewOptToolSearchToolParameters(v ToolSearchToolParameters) OptToolSearchToolParameters { + return OptToolSearchToolParameters{ Value: v, Set: true, } } -// OptToolNameList is optional ToolNameList. -type OptToolNameList struct { - Value ToolNameList +// OptToolSearchToolParameters is optional ToolSearchToolParameters. +type OptToolSearchToolParameters struct { + Value ToolSearchToolParameters Set bool } -// IsSet returns true if OptToolNameList was set. -func (o OptToolNameList) IsSet() bool { return o.Set } +// IsSet returns true if OptToolSearchToolParameters was set. +func (o OptToolSearchToolParameters) IsSet() bool { return o.Set } // Reset unsets value. -func (o *OptToolNameList) Reset() { - var v ToolNameList +func (o *OptToolSearchToolParameters) Reset() { + var v ToolSearchToolParameters o.Value = v o.Set = false } // SetTo sets value to v. -func (o *OptToolNameList) SetTo(v ToolNameList) { +func (o *OptToolSearchToolParameters) SetTo(v ToolSearchToolParameters) { o.Set = true o.Value = v } // Get returns value and boolean that denotes whether value was set. -func (o OptToolNameList) Get() (v ToolNameList, ok bool) { +func (o OptToolSearchToolParameters) Get() (v ToolSearchToolParameters, ok bool) { if !o.Set { return v, false } @@ -7910,7 +8536,7 @@ func (o OptToolNameList) Get() (v ToolNameList, ok bool) { } // Or returns value if set, or given parameter if does not. -func (o OptToolNameList) Or(d ToolNameList) ToolNameList { +func (o OptToolSearchToolParameters) Or(d ToolSearchToolParameters) ToolSearchToolParameters { if v, ok := o.Get(); ok { return v } @@ -8685,6 +9311,8 @@ type OutputItemSum struct { Type OutputItemSumType // switch on this field ItemOutputMessage ItemOutputMessage ItemFunctionToolCall ItemFunctionToolCall + ItemToolSearchCall ItemToolSearchCall + ItemToolSearchOutput ItemToolSearchOutput ItemReasoning ItemReasoning ItemTranscription ItemTranscription ItemFunctionWebSearch ItemFunctionWebSearch @@ -8714,6 +9342,8 @@ type OutputItemSumType string const ( ItemOutputMessageOutputItemSum OutputItemSumType = "message" ItemFunctionToolCallOutputItemSum OutputItemSumType = "function_call" + ItemToolSearchCallOutputItemSum OutputItemSumType = "tool_search_call" + ItemToolSearchOutputOutputItemSum OutputItemSumType = "tool_search_output" ItemReasoningOutputItemSum OutputItemSumType = "reasoning" ItemTranscriptionOutputItemSum OutputItemSumType = "transcription" ItemFunctionWebSearchOutputItemSum OutputItemSumType = "web_search_call" @@ -8734,6 +9364,14 @@ func (s OutputItemSum) IsItemFunctionToolCall() bool { return s.Type == ItemFunctionToolCallOutputItemSum } +// IsItemToolSearchCall reports whether OutputItemSum is ItemToolSearchCall. +func (s OutputItemSum) IsItemToolSearchCall() bool { return s.Type == ItemToolSearchCallOutputItemSum } + +// IsItemToolSearchOutput reports whether OutputItemSum is ItemToolSearchOutput. +func (s OutputItemSum) IsItemToolSearchOutput() bool { + return s.Type == ItemToolSearchOutputOutputItemSum +} + // IsItemReasoning reports whether OutputItemSum is ItemReasoning. func (s OutputItemSum) IsItemReasoning() bool { return s.Type == ItemReasoningOutputItemSum } @@ -8822,6 +9460,52 @@ func NewItemFunctionToolCallOutputItemSum(v ItemFunctionToolCall) OutputItemSum return s } +// SetItemToolSearchCall sets OutputItemSum to ItemToolSearchCall. +func (s *OutputItemSum) SetItemToolSearchCall(v ItemToolSearchCall) { + s.Type = ItemToolSearchCallOutputItemSum + s.unknownType = "" + s.unknownJSON = "" + s.ItemToolSearchCall = v +} + +// GetItemToolSearchCall returns ItemToolSearchCall and true boolean if OutputItemSum is ItemToolSearchCall. +func (s OutputItemSum) GetItemToolSearchCall() (v ItemToolSearchCall, ok bool) { + if !s.IsItemToolSearchCall() { + return v, false + } + return s.ItemToolSearchCall, true +} + +// NewItemToolSearchCallOutputItemSum returns new OutputItemSum from ItemToolSearchCall. +func NewItemToolSearchCallOutputItemSum(v ItemToolSearchCall) OutputItemSum { + var s OutputItemSum + s.SetItemToolSearchCall(v) + return s +} + +// SetItemToolSearchOutput sets OutputItemSum to ItemToolSearchOutput. +func (s *OutputItemSum) SetItemToolSearchOutput(v ItemToolSearchOutput) { + s.Type = ItemToolSearchOutputOutputItemSum + s.unknownType = "" + s.unknownJSON = "" + s.ItemToolSearchOutput = v +} + +// GetItemToolSearchOutput returns ItemToolSearchOutput and true boolean if OutputItemSum is ItemToolSearchOutput. +func (s OutputItemSum) GetItemToolSearchOutput() (v ItemToolSearchOutput, ok bool) { + if !s.IsItemToolSearchOutput() { + return v, false + } + return s.ItemToolSearchOutput, true +} + +// NewItemToolSearchOutputOutputItemSum returns new OutputItemSum from ItemToolSearchOutput. +func NewItemToolSearchOutputOutputItemSum(v ItemToolSearchOutput) OutputItemSum { + var s OutputItemSum + s.SetItemToolSearchOutput(v) + return s +} + // SetItemReasoning sets OutputItemSum to ItemReasoning. func (s *OutputItemSum) SetItemReasoning(v ItemReasoning) { s.Type = ItemReasoningOutputItemSum @@ -19012,6 +19696,253 @@ func (s *ToolNameList) SetClearToolNames(val []string) { s.ClearToolNames = val } +// Ref: #/components/schemas/ToolSearchExecution +type ToolSearchExecution string + +const ( + ToolSearchExecutionServer ToolSearchExecution = "server" + ToolSearchExecutionClient ToolSearchExecution = "client" + ToolSearchExecutionEmpty ToolSearchExecution = "" +) + +// AllValues returns all ToolSearchExecution values. +func (ToolSearchExecution) AllValues() []ToolSearchExecution { + return []ToolSearchExecution{ + ToolSearchExecutionServer, + ToolSearchExecutionClient, + ToolSearchExecutionEmpty, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s ToolSearchExecution) MarshalText() ([]byte, error) { + switch s { + case ToolSearchExecutionServer: + return []byte(s), nil + case ToolSearchExecutionClient: + return []byte(s), nil + case ToolSearchExecutionEmpty: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *ToolSearchExecution) UnmarshalText(data []byte) error { + switch ToolSearchExecution(data) { + case ToolSearchExecutionServer: + *s = ToolSearchExecutionServer + return nil + case ToolSearchExecutionClient: + *s = ToolSearchExecutionClient + return nil + case ToolSearchExecutionEmpty: + *s = ToolSearchExecutionEmpty + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// Full function or namespace definitions returned by hosted tool search. +// Ref: #/components/schemas/ToolSearchResultTool +type ToolSearchResultTool struct { + OneOf ToolSearchResultToolSum +} + +// GetOneOf returns the value of OneOf. +func (s *ToolSearchResultTool) GetOneOf() ToolSearchResultToolSum { + return s.OneOf +} + +// SetOneOf sets the value of OneOf. +func (s *ToolSearchResultTool) SetOneOf(val ToolSearchResultToolSum) { + s.OneOf = val +} + +// ToolSearchResultToolSum represents sum type. +type ToolSearchResultToolSum struct { + // Only populated for unknown wire variants; no known member is selected. + unknownType string + unknownJSON string + Type ToolSearchResultToolSumType // switch on this field + FunctionTool FunctionTool + NamespaceTool NamespaceTool +} + +// GetUnknown returns the discriminator and original JSON for an unknown variant. +// The bool is false for known variants and zero values. Explicit validation +// remains strict; selecting a known member makes the fallback inactive. +func (s ToolSearchResultToolSum) GetUnknown() (string, string, bool) { + if s.Type != "" || s.unknownType == "" { + return "", "", false + } + return s.unknownType, s.unknownJSON, true +} + +// ToolSearchResultToolSumType is oneOf type of ToolSearchResultToolSum. +type ToolSearchResultToolSumType string + +// Possible values for ToolSearchResultToolSumType. +const ( + FunctionToolToolSearchResultToolSum ToolSearchResultToolSumType = "function" + NamespaceToolToolSearchResultToolSum ToolSearchResultToolSumType = "namespace" +) + +// IsFunctionTool reports whether ToolSearchResultToolSum is FunctionTool. +func (s ToolSearchResultToolSum) IsFunctionTool() bool { + return s.Type == FunctionToolToolSearchResultToolSum +} + +// IsNamespaceTool reports whether ToolSearchResultToolSum is NamespaceTool. +func (s ToolSearchResultToolSum) IsNamespaceTool() bool { + return s.Type == NamespaceToolToolSearchResultToolSum +} + +// SetFunctionTool sets ToolSearchResultToolSum to FunctionTool. +func (s *ToolSearchResultToolSum) SetFunctionTool(v FunctionTool) { + s.Type = FunctionToolToolSearchResultToolSum + s.unknownType = "" + s.unknownJSON = "" + s.FunctionTool = v +} + +// GetFunctionTool returns FunctionTool and true boolean if ToolSearchResultToolSum is FunctionTool. +func (s ToolSearchResultToolSum) GetFunctionTool() (v FunctionTool, ok bool) { + if !s.IsFunctionTool() { + return v, false + } + return s.FunctionTool, true +} + +// NewFunctionToolToolSearchResultToolSum returns new ToolSearchResultToolSum from FunctionTool. +func NewFunctionToolToolSearchResultToolSum(v FunctionTool) ToolSearchResultToolSum { + var s ToolSearchResultToolSum + s.SetFunctionTool(v) + return s +} + +// SetNamespaceTool sets ToolSearchResultToolSum to NamespaceTool. +func (s *ToolSearchResultToolSum) SetNamespaceTool(v NamespaceTool) { + s.Type = NamespaceToolToolSearchResultToolSum + s.unknownType = "" + s.unknownJSON = "" + s.NamespaceTool = v +} + +// GetNamespaceTool returns NamespaceTool and true boolean if ToolSearchResultToolSum is NamespaceTool. +func (s ToolSearchResultToolSum) GetNamespaceTool() (v NamespaceTool, ok bool) { + if !s.IsNamespaceTool() { + return v, false + } + return s.NamespaceTool, true +} + +// NewNamespaceToolToolSearchResultToolSum returns new ToolSearchResultToolSum from NamespaceTool. +func NewNamespaceToolToolSearchResultToolSum(v NamespaceTool) ToolSearchResultToolSum { + var s ToolSearchResultToolSum + s.SetNamespaceTool(v) + return s +} + +// Ref: #/components/schemas/ToolSearchTool +type ToolSearchTool struct { + Type ToolSearchToolType `json:"type"` + // Omitted, null or empty means server. Client execution uses full-schema fallback. + Execution OptNilToolSearchExecution `json:"execution"` + // Optional caller-supplied description; hosted search uses its built-in definition. + Description OptString `json:"description"` + // Optional JSON schema; hosted search uses its built-in parameter schema. + Parameters OptToolSearchToolParameters `json:"parameters"` +} + +// GetType returns the value of Type. +func (s *ToolSearchTool) GetType() ToolSearchToolType { + return s.Type +} + +// GetExecution returns the value of Execution. +func (s *ToolSearchTool) GetExecution() OptNilToolSearchExecution { + return s.Execution +} + +// GetDescription returns the value of Description. +func (s *ToolSearchTool) GetDescription() OptString { + return s.Description +} + +// GetParameters returns the value of Parameters. +func (s *ToolSearchTool) GetParameters() OptToolSearchToolParameters { + return s.Parameters +} + +// SetType sets the value of Type. +func (s *ToolSearchTool) SetType(val ToolSearchToolType) { + s.Type = val +} + +// SetExecution sets the value of Execution. +func (s *ToolSearchTool) SetExecution(val OptNilToolSearchExecution) { + s.Execution = val +} + +// SetDescription sets the value of Description. +func (s *ToolSearchTool) SetDescription(val OptString) { + s.Description = val +} + +// SetParameters sets the value of Parameters. +func (s *ToolSearchTool) SetParameters(val OptToolSearchToolParameters) { + s.Parameters = val +} + +// Optional JSON schema; hosted search uses its built-in parameter schema. +type ToolSearchToolParameters map[string]jx.Raw + +func (s *ToolSearchToolParameters) init() ToolSearchToolParameters { + m := *s + if m == nil { + m = map[string]jx.Raw{} + *s = m + } + return m +} + +type ToolSearchToolType string + +const ( + ToolSearchToolTypeToolSearch ToolSearchToolType = "tool_search" +) + +// AllValues returns all ToolSearchToolType values. +func (ToolSearchToolType) AllValues() []ToolSearchToolType { + return []ToolSearchToolType{ + ToolSearchToolTypeToolSearch, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s ToolSearchToolType) MarshalText() ([]byte, error) { + switch s { + case ToolSearchToolTypeToolSearch: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *ToolSearchToolType) UnmarshalText(data []byte) error { + switch ToolSearchToolType(data) { + case ToolSearchToolTypeToolSearch: + *s = ToolSearchToolTypeToolSearch + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + // ToolSum represents sum type. type ToolSum struct { // Only populated for unknown wire variants; no known member is selected. @@ -19019,6 +19950,8 @@ type ToolSum struct { unknownJSON string Type ToolSumType // switch on this field FunctionTool FunctionTool + NamespaceTool NamespaceTool + ToolSearchTool ToolSearchTool WebSearchTool WebSearchTool ImageProcessTool ImageProcessTool McpTool McpTool @@ -19042,6 +19975,8 @@ type ToolSumType string // Possible values for ToolSumType. const ( FunctionToolToolSum ToolSumType = "function" + NamespaceToolToolSum ToolSumType = "namespace" + ToolSearchToolToolSum ToolSumType = "tool_search" WebSearchToolToolSum ToolSumType = "web_search" ImageProcessToolToolSum ToolSumType = "image_process" McpToolToolSum ToolSumType = "mcp" @@ -19052,6 +19987,12 @@ const ( // IsFunctionTool reports whether ToolSum is FunctionTool. func (s ToolSum) IsFunctionTool() bool { return s.Type == FunctionToolToolSum } +// IsNamespaceTool reports whether ToolSum is NamespaceTool. +func (s ToolSum) IsNamespaceTool() bool { return s.Type == NamespaceToolToolSum } + +// IsToolSearchTool reports whether ToolSum is ToolSearchTool. +func (s ToolSum) IsToolSearchTool() bool { return s.Type == ToolSearchToolToolSum } + // IsWebSearchTool reports whether ToolSum is WebSearchTool. func (s ToolSum) IsWebSearchTool() bool { return s.Type == WebSearchToolToolSum } @@ -19090,6 +20031,52 @@ func NewFunctionToolToolSum(v FunctionTool) ToolSum { return s } +// SetNamespaceTool sets ToolSum to NamespaceTool. +func (s *ToolSum) SetNamespaceTool(v NamespaceTool) { + s.Type = NamespaceToolToolSum + s.unknownType = "" + s.unknownJSON = "" + s.NamespaceTool = v +} + +// GetNamespaceTool returns NamespaceTool and true boolean if ToolSum is NamespaceTool. +func (s ToolSum) GetNamespaceTool() (v NamespaceTool, ok bool) { + if !s.IsNamespaceTool() { + return v, false + } + return s.NamespaceTool, true +} + +// NewNamespaceToolToolSum returns new ToolSum from NamespaceTool. +func NewNamespaceToolToolSum(v NamespaceTool) ToolSum { + var s ToolSum + s.SetNamespaceTool(v) + return s +} + +// SetToolSearchTool sets ToolSum to ToolSearchTool. +func (s *ToolSum) SetToolSearchTool(v ToolSearchTool) { + s.Type = ToolSearchToolToolSum + s.unknownType = "" + s.unknownJSON = "" + s.ToolSearchTool = v +} + +// GetToolSearchTool returns ToolSearchTool and true boolean if ToolSum is ToolSearchTool. +func (s ToolSum) GetToolSearchTool() (v ToolSearchTool, ok bool) { + if !s.IsToolSearchTool() { + return v, false + } + return s.ToolSearchTool, true +} + +// NewToolSearchToolToolSum returns new ToolSum from ToolSearchTool. +func NewToolSearchToolToolSum(v ToolSearchTool) ToolSum { + var s ToolSum + s.SetToolSearchTool(v) + return s +} + // SetWebSearchTool sets ToolSum to WebSearchTool. func (s *ToolSum) SetWebSearchTool(v WebSearchTool) { s.Type = WebSearchToolToolSum diff --git a/arkruntime/model/responses/oas_validators_gen.go b/arkruntime/model/responses/oas_validators_gen.go index 5d90cc0..9dd0f60 100644 --- a/arkruntime/model/responses/oas_validators_gen.go +++ b/arkruntime/model/responses/oas_validators_gen.go @@ -1439,6 +1439,16 @@ func (s InputItemSum) Validate() error { return err } return nil + case ItemToolSearchCallInputItemSum: + if err := s.ItemToolSearchCall.Validate(); err != nil { + return err + } + return nil + case ItemToolSearchOutputInputItemSum: + if err := s.ItemToolSearchOutput.Validate(); err != nil { + return err + } + return nil case ItemFunctionToolCallOutputInputItemSum: if err := s.ItemFunctionToolCallOutput.Validate(); err != nil { return err @@ -2262,6 +2272,170 @@ func (s ItemStatus) Validate() error { } } +func (s *ItemToolSearchCall) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Status.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Execution.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "execution", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ItemToolSearchCallType) Validate() error { + switch s { + case "tool_search_call": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *ItemToolSearchOutput) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Status.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Execution.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "execution", + Error: err, + }) + } + if err := func() error { + if s.Tools == nil { + return errors.New("nil is invalid value") + } + var failures []validate.FieldError + for i, elem := range s.Tools { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "tools", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ItemToolSearchOutputType) Validate() error { + switch s { + case "tool_search_output": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + func (s *ItemTranscription) Validate() error { if s == nil { return validate.ErrNilPointer @@ -2716,6 +2890,66 @@ func (s MessageRole) Validate() error { } } +func (s *NamespaceTool) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if err := func() error { + if s.Tools == nil { + return errors.New("nil is invalid value") + } + var failures []validate.FieldError + for i, elem := range s.Tools { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "tools", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s NamespaceToolType) Validate() error { + switch s { + case "namespace": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + func (s Order) Validate() error { switch s { case "asc": @@ -2916,6 +3150,16 @@ func (s OutputItemSum) Validate() error { return err } return nil + case ItemToolSearchCallOutputItemSum: + if err := s.ItemToolSearchCall.Validate(); err != nil { + return err + } + return nil + case ItemToolSearchOutputOutputItemSum: + if err := s.ItemToolSearchOutput.Validate(); err != nil { + return err + } + return nil case ItemReasoningOutputItemSum: if err := s.ItemReasoning.Validate(); err != nil { return err @@ -6620,6 +6864,109 @@ func (s *ToolNameList) Validate() error { return nil } +func (s ToolSearchExecution) Validate() error { + switch s { + case "server": + return nil + case "client": + return nil + case "": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *ToolSearchResultTool) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.OneOf.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "OneOf", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ToolSearchResultToolSum) Validate() error { + switch s.Type { + case FunctionToolToolSearchResultToolSum: + if err := s.FunctionTool.Validate(); err != nil { + return err + } + return nil + case NamespaceToolToolSearchResultToolSum: + if err := s.NamespaceTool.Validate(); err != nil { + return err + } + return nil + default: + return errors.Errorf("invalid type %q", s.Type) + } +} + +func (s *ToolSearchTool) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Execution.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "execution", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ToolSearchToolType) Validate() error { + switch s { + case "tool_search": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + func (s ToolSum) Validate() error { switch s.Type { case FunctionToolToolSum: @@ -6627,6 +6974,16 @@ func (s ToolSum) Validate() error { return err } return nil + case NamespaceToolToolSum: + if err := s.NamespaceTool.Validate(); err != nil { + return err + } + return nil + case ToolSearchToolToolSum: + if err := s.ToolSearchTool.Validate(); err != nil { + return err + } + return nil case WebSearchToolToolSum: if err := s.WebSearchTool.Validate(); err != nil { return err diff --git a/arkruntime/model/session/oas_json_gen.go b/arkruntime/model/session/oas_json_gen.go index 996fcb8..e2239fc 100644 --- a/arkruntime/model/session/oas_json_gen.go +++ b/arkruntime/model/session/oas_json_gen.go @@ -1137,6 +1137,10 @@ func (s *Base64DocumentSource) Encode(e *jx.Encoder) { // encodeFields encodes fields. func (s *Base64DocumentSource) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } { e.FieldStart("data") e.Str(s.Data) @@ -1147,9 +1151,10 @@ func (s *Base64DocumentSource) encodeFields(e *jx.Encoder) { } } -var jsonFieldsNameOfBase64DocumentSource = [2]string{ - 0: "data", - 1: "media_type", +var jsonFieldsNameOfBase64DocumentSource = [3]string{ + 0: "type", + 1: "data", + 2: "media_type", } // Decode decodes Base64DocumentSource from json. @@ -1161,8 +1166,18 @@ func (s *Base64DocumentSource) Decode(d *jx.Decoder) error { if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "data": + case "type": requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "data": + requiredBitSet[0] |= 1 << 1 if err := func() error { v, err := d.Str() s.Data = string(v) @@ -1174,7 +1189,7 @@ func (s *Base64DocumentSource) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"data\"") } case "media_type": - requiredBitSet[0] |= 1 << 1 + requiredBitSet[0] |= 1 << 2 if err := func() error { v, err := d.Str() s.MediaType = string(v) @@ -1195,7 +1210,7 @@ func (s *Base64DocumentSource) Decode(d *jx.Decoder) error { // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00000011, + 0b00000111, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -1241,6 +1256,44 @@ func (s *Base64DocumentSource) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes Base64DocumentSourceType as json. +func (s Base64DocumentSourceType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes Base64DocumentSourceType from json. +func (s *Base64DocumentSourceType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Base64DocumentSourceType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch Base64DocumentSourceType(v) { + case Base64DocumentSourceTypeBase64: + *s = Base64DocumentSourceTypeBase64 + default: + *s = Base64DocumentSourceType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s Base64DocumentSourceType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *Base64DocumentSourceType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *Base64ImageSource) Encode(e *jx.Encoder) { e.ObjStart() @@ -1250,6 +1303,10 @@ func (s *Base64ImageSource) Encode(e *jx.Encoder) { // encodeFields encodes fields. func (s *Base64ImageSource) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } { e.FieldStart("data") e.Str(s.Data) @@ -1260,9 +1317,10 @@ func (s *Base64ImageSource) encodeFields(e *jx.Encoder) { } } -var jsonFieldsNameOfBase64ImageSource = [2]string{ - 0: "data", - 1: "media_type", +var jsonFieldsNameOfBase64ImageSource = [3]string{ + 0: "type", + 1: "data", + 2: "media_type", } // Decode decodes Base64ImageSource from json. @@ -1274,8 +1332,18 @@ func (s *Base64ImageSource) Decode(d *jx.Decoder) error { if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "data": + case "type": requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "data": + requiredBitSet[0] |= 1 << 1 if err := func() error { v, err := d.Str() s.Data = string(v) @@ -1287,7 +1355,7 @@ func (s *Base64ImageSource) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"data\"") } case "media_type": - requiredBitSet[0] |= 1 << 1 + requiredBitSet[0] |= 1 << 2 if err := func() error { v, err := d.Str() s.MediaType = string(v) @@ -1308,7 +1376,7 @@ func (s *Base64ImageSource) Decode(d *jx.Decoder) error { // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00000011, + 0b00000111, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -1354,6 +1422,227 @@ func (s *Base64ImageSource) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes Base64ImageSourceType as json. +func (s Base64ImageSourceType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes Base64ImageSourceType from json. +func (s *Base64ImageSourceType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Base64ImageSourceType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch Base64ImageSourceType(v) { + case Base64ImageSourceTypeBase64: + *s = Base64ImageSourceTypeBase64 + default: + *s = Base64ImageSourceType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s Base64ImageSourceType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *Base64ImageSourceType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *Base64VideoSource) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *Base64VideoSource) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } + { + e.FieldStart("data") + e.Str(s.Data) + } + { + e.FieldStart("media_type") + e.Str(s.MediaType) + } + { + if s.Fps.Set { + e.FieldStart("fps") + s.Fps.Encode(e) + } + } +} + +var jsonFieldsNameOfBase64VideoSource = [4]string{ + 0: "type", + 1: "data", + 2: "media_type", + 3: "fps", +} + +// Decode decodes Base64VideoSource from json. +func (s *Base64VideoSource) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Base64VideoSource to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "type": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "data": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.Data = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"data\"") + } + case "media_type": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + v, err := d.Str() + s.MediaType = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"media_type\"") + } + case "fps": + if err := func() error { + s.Fps.Reset() + if err := s.Fps.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"fps\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode Base64VideoSource") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfBase64VideoSource) { + name = jsonFieldsNameOfBase64VideoSource[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *Base64VideoSource) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *Base64VideoSource) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes Base64VideoSourceType as json. +func (s Base64VideoSourceType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes Base64VideoSourceType from json. +func (s *Base64VideoSourceType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Base64VideoSourceType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch Base64VideoSourceType(v) { + case Base64VideoSourceTypeBase64: + *s = Base64VideoSourceTypeBase64 + default: + *s = Base64VideoSourceType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s Base64VideoSourceType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *Base64VideoSourceType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *CacheCreation) Encode(e *jx.Encoder) { e.ObjStart() @@ -4343,14 +4632,19 @@ func (s *FileDocumentSource) Encode(e *jx.Encoder) { // encodeFields encodes fields. func (s *FileDocumentSource) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } { e.FieldStart("file_id") e.Str(s.FileID) } } -var jsonFieldsNameOfFileDocumentSource = [1]string{ - 0: "file_id", +var jsonFieldsNameOfFileDocumentSource = [2]string{ + 0: "type", + 1: "file_id", } // Decode decodes FileDocumentSource from json. @@ -4362,8 +4656,18 @@ func (s *FileDocumentSource) Decode(d *jx.Decoder) error { if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "file_id": + case "type": requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "file_id": + requiredBitSet[0] |= 1 << 1 if err := func() error { v, err := d.Str() s.FileID = string(v) @@ -4384,7 +4688,7 @@ func (s *FileDocumentSource) Decode(d *jx.Decoder) error { // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00000001, + 0b00000011, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -4430,6 +4734,44 @@ func (s *FileDocumentSource) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes FileDocumentSourceType as json. +func (s FileDocumentSourceType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes FileDocumentSourceType from json. +func (s *FileDocumentSourceType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode FileDocumentSourceType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch FileDocumentSourceType(v) { + case FileDocumentSourceTypeFile: + *s = FileDocumentSourceTypeFile + default: + *s = FileDocumentSourceType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s FileDocumentSourceType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *FileDocumentSourceType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *FileImageSource) Encode(e *jx.Encoder) { e.ObjStart() @@ -4439,14 +4781,19 @@ func (s *FileImageSource) Encode(e *jx.Encoder) { // encodeFields encodes fields. func (s *FileImageSource) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } { e.FieldStart("file_id") e.Str(s.FileID) } } -var jsonFieldsNameOfFileImageSource = [1]string{ - 0: "file_id", +var jsonFieldsNameOfFileImageSource = [2]string{ + 0: "type", + 1: "file_id", } // Decode decodes FileImageSource from json. @@ -4458,8 +4805,18 @@ func (s *FileImageSource) Decode(d *jx.Decoder) error { if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "file_id": + case "type": requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "file_id": + requiredBitSet[0] |= 1 << 1 if err := func() error { v, err := d.Str() s.FileID = string(v) @@ -4480,7 +4837,7 @@ func (s *FileImageSource) Decode(d *jx.Decoder) error { // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00000001, + 0b00000011, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -4526,6 +4883,210 @@ func (s *FileImageSource) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes FileImageSourceType as json. +func (s FileImageSourceType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes FileImageSourceType from json. +func (s *FileImageSourceType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode FileImageSourceType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch FileImageSourceType(v) { + case FileImageSourceTypeFile: + *s = FileImageSourceTypeFile + default: + *s = FileImageSourceType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s FileImageSourceType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *FileImageSourceType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *FileVideoSource) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *FileVideoSource) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } + { + e.FieldStart("file_id") + e.Str(s.FileID) + } + { + if s.Fps.Set { + e.FieldStart("fps") + s.Fps.Encode(e) + } + } +} + +var jsonFieldsNameOfFileVideoSource = [3]string{ + 0: "type", + 1: "file_id", + 2: "fps", +} + +// Decode decodes FileVideoSource from json. +func (s *FileVideoSource) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode FileVideoSource to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "type": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "file_id": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.FileID = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"file_id\"") + } + case "fps": + if err := func() error { + s.Fps.Reset() + if err := s.Fps.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"fps\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode FileVideoSource") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfFileVideoSource) { + name = jsonFieldsNameOfFileVideoSource[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *FileVideoSource) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *FileVideoSource) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes FileVideoSourceType as json. +func (s FileVideoSourceType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes FileVideoSourceType from json. +func (s *FileVideoSourceType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode FileVideoSourceType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch FileVideoSourceType(v) { + case FileVideoSourceTypeFile: + *s = FileVideoSourceTypeFile + default: + *s = FileVideoSourceType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s FileVideoSourceType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *FileVideoSourceType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *GetSessionCheckpointResponse) Encode(e *jx.Encoder) { e.ObjStart() @@ -5458,6 +6019,10 @@ func (s *ManagedAgentsDocumentBlock) Encode(e *jx.Encoder) { // encodeFields encodes fields. func (s *ManagedAgentsDocumentBlock) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } { e.FieldStart("source") s.Source.Encode(e) @@ -5476,10 +6041,11 @@ func (s *ManagedAgentsDocumentBlock) encodeFields(e *jx.Encoder) { } } -var jsonFieldsNameOfManagedAgentsDocumentBlock = [3]string{ - 0: "source", - 1: "title", - 2: "context", +var jsonFieldsNameOfManagedAgentsDocumentBlock = [4]string{ + 0: "type", + 1: "source", + 2: "title", + 3: "context", } // Decode decodes ManagedAgentsDocumentBlock from json. @@ -5491,8 +6057,18 @@ func (s *ManagedAgentsDocumentBlock) Decode(d *jx.Decoder) error { if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "source": + case "type": requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "source": + requiredBitSet[0] |= 1 << 1 if err := func() error { if err := s.Source.Decode(d); err != nil { return err @@ -5531,7 +6107,7 @@ func (s *ManagedAgentsDocumentBlock) Decode(d *jx.Decoder) error { // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00000001, + 0b00000011, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -5577,16 +6153,54 @@ func (s *ManagedAgentsDocumentBlock) UnmarshalJSON(data []byte) error { return s.Decode(d) } -// Encode implements json.Marshaler. -func (s *ManagedAgentsEventParams) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() -} - -// encodeFields encodes fields. -func (s *ManagedAgentsEventParams) encodeFields(e *jx.Encoder) { - s.OneOf.encodeFields(e) +// Encode encodes ManagedAgentsDocumentBlockType as json. +func (s ManagedAgentsDocumentBlockType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes ManagedAgentsDocumentBlockType from json. +func (s *ManagedAgentsDocumentBlockType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ManagedAgentsDocumentBlockType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch ManagedAgentsDocumentBlockType(v) { + case ManagedAgentsDocumentBlockTypeDocument: + *s = ManagedAgentsDocumentBlockTypeDocument + default: + *s = ManagedAgentsDocumentBlockType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ManagedAgentsDocumentBlockType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ManagedAgentsDocumentBlockType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ManagedAgentsEventParams) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ManagedAgentsEventParams) encodeFields(e *jx.Encoder) { + s.OneOf.encodeFields(e) } var jsonFieldsNameOfManagedAgentsEventParams = [0]string{} @@ -6069,14 +6683,19 @@ func (s *ManagedAgentsImageBlock) Encode(e *jx.Encoder) { // encodeFields encodes fields. func (s *ManagedAgentsImageBlock) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } { e.FieldStart("source") s.Source.Encode(e) } } -var jsonFieldsNameOfManagedAgentsImageBlock = [1]string{ - 0: "source", +var jsonFieldsNameOfManagedAgentsImageBlock = [2]string{ + 0: "type", + 1: "source", } // Decode decodes ManagedAgentsImageBlock from json. @@ -6088,8 +6707,18 @@ func (s *ManagedAgentsImageBlock) Decode(d *jx.Decoder) error { if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "source": + case "type": requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "source": + requiredBitSet[0] |= 1 << 1 if err := func() error { if err := s.Source.Decode(d); err != nil { return err @@ -6108,7 +6737,7 @@ func (s *ManagedAgentsImageBlock) Decode(d *jx.Decoder) error { // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00000001, + 0b00000011, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -6154,6 +6783,44 @@ func (s *ManagedAgentsImageBlock) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes ManagedAgentsImageBlockType as json. +func (s ManagedAgentsImageBlockType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes ManagedAgentsImageBlockType from json. +func (s *ManagedAgentsImageBlockType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ManagedAgentsImageBlockType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch ManagedAgentsImageBlockType(v) { + case ManagedAgentsImageBlockTypeImage: + *s = ManagedAgentsImageBlockTypeImage + default: + *s = ManagedAgentsImageBlockType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ManagedAgentsImageBlockType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ManagedAgentsImageBlockType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *ManagedAgentsMessageContentBlock) Encode(e *jx.Encoder) { e.ObjStart() @@ -6255,6 +6922,16 @@ func (s ManagedAgentsMessageContentBlockSum) encodeFields(e *jx.Encoder) { } } } + case ManagedAgentsVideoBlockManagedAgentsMessageContentBlockSum: + e.FieldStart("type") + e.Str("video") + { + s := s.ManagedAgentsVideoBlock + { + e.FieldStart("source") + s.Source.Encode(e) + } + } } } @@ -6290,6 +6967,9 @@ func (s *ManagedAgentsMessageContentBlockSum) Decode(d *jx.Decoder) error { case "document": s.Type = ManagedAgentsDocumentBlockManagedAgentsMessageContentBlockSum found = true + case "video": + s.Type = ManagedAgentsVideoBlockManagedAgentsMessageContentBlockSum + found = true default: return errors.Errorf("unknown type %s", typ) } @@ -6316,6 +6996,10 @@ func (s *ManagedAgentsMessageContentBlockSum) Decode(d *jx.Decoder) error { if err := s.ManagedAgentsDocumentBlock.Decode(d); err != nil { return err } + case ManagedAgentsVideoBlockManagedAgentsMessageContentBlockSum: + if err := s.ManagedAgentsVideoBlock.Decode(d); err != nil { + return err + } default: return errors.Errorf("inferred invalid type: %s", s.Type) } @@ -6496,6 +7180,10 @@ func (s *ManagedAgentsSearchResultBlock) Encode(e *jx.Encoder) { // encodeFields encodes fields. func (s *ManagedAgentsSearchResultBlock) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } { e.FieldStart("citations") s.Citations.Encode(e) @@ -6518,11 +7206,12 @@ func (s *ManagedAgentsSearchResultBlock) encodeFields(e *jx.Encoder) { } } -var jsonFieldsNameOfManagedAgentsSearchResultBlock = [4]string{ - 0: "citations", - 1: "content", - 2: "source", - 3: "title", +var jsonFieldsNameOfManagedAgentsSearchResultBlock = [5]string{ + 0: "type", + 1: "citations", + 2: "content", + 3: "source", + 4: "title", } // Decode decodes ManagedAgentsSearchResultBlock from json. @@ -6534,8 +7223,18 @@ func (s *ManagedAgentsSearchResultBlock) Decode(d *jx.Decoder) error { if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "citations": + case "type": requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "citations": + requiredBitSet[0] |= 1 << 1 if err := func() error { if err := s.Citations.Decode(d); err != nil { return err @@ -6545,7 +7244,7 @@ func (s *ManagedAgentsSearchResultBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"citations\"") } case "content": - requiredBitSet[0] |= 1 << 1 + requiredBitSet[0] |= 1 << 2 if err := func() error { s.Content = make([]SearchResultContent, 0) if err := d.Arr(func(d *jx.Decoder) error { @@ -6563,7 +7262,7 @@ func (s *ManagedAgentsSearchResultBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"content\"") } case "source": - requiredBitSet[0] |= 1 << 2 + requiredBitSet[0] |= 1 << 3 if err := func() error { v, err := d.Str() s.Source = string(v) @@ -6575,7 +7274,7 @@ func (s *ManagedAgentsSearchResultBlock) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"source\"") } case "title": - requiredBitSet[0] |= 1 << 3 + requiredBitSet[0] |= 1 << 4 if err := func() error { v, err := d.Str() s.Title = string(v) @@ -6596,7 +7295,7 @@ func (s *ManagedAgentsSearchResultBlock) Decode(d *jx.Decoder) error { // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00001111, + 0b00011111, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -6642,6 +7341,44 @@ func (s *ManagedAgentsSearchResultBlock) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes ManagedAgentsSearchResultBlockType as json. +func (s ManagedAgentsSearchResultBlockType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes ManagedAgentsSearchResultBlockType from json. +func (s *ManagedAgentsSearchResultBlockType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ManagedAgentsSearchResultBlockType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch ManagedAgentsSearchResultBlockType(v) { + case ManagedAgentsSearchResultBlockTypeSearchResult: + *s = ManagedAgentsSearchResultBlockTypeSearchResult + default: + *s = ManagedAgentsSearchResultBlockType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ManagedAgentsSearchResultBlockType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ManagedAgentsSearchResultBlockType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *ManagedAgentsSystemContentBlock) Encode(e *jx.Encoder) { e.ObjStart() @@ -6894,14 +7631,19 @@ func (s *ManagedAgentsTextBlock) Encode(e *jx.Encoder) { // encodeFields encodes fields. func (s *ManagedAgentsTextBlock) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } { e.FieldStart("text") e.Str(s.Text) } } -var jsonFieldsNameOfManagedAgentsTextBlock = [1]string{ - 0: "text", +var jsonFieldsNameOfManagedAgentsTextBlock = [2]string{ + 0: "type", + 1: "text", } // Decode decodes ManagedAgentsTextBlock from json. @@ -6913,8 +7655,18 @@ func (s *ManagedAgentsTextBlock) Decode(d *jx.Decoder) error { if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "text": + case "type": requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "text": + requiredBitSet[0] |= 1 << 1 if err := func() error { v, err := d.Str() s.Text = string(v) @@ -6935,7 +7687,7 @@ func (s *ManagedAgentsTextBlock) Decode(d *jx.Decoder) error { // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00000001, + 0b00000011, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -6981,6 +7733,44 @@ func (s *ManagedAgentsTextBlock) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes ManagedAgentsTextBlockType as json. +func (s ManagedAgentsTextBlockType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes ManagedAgentsTextBlockType from json. +func (s *ManagedAgentsTextBlockType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ManagedAgentsTextBlockType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch ManagedAgentsTextBlockType(v) { + case ManagedAgentsTextBlockTypeText: + *s = ManagedAgentsTextBlockTypeText + default: + *s = ManagedAgentsTextBlockType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ManagedAgentsTextBlockType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ManagedAgentsTextBlockType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *ManagedAgentsTextRubricParams) Encode(e *jx.Encoder) { e.ObjStart() @@ -7204,6 +7994,16 @@ func (s ManagedAgentsToolResultContentBlockSum) encodeFields(e *jx.Encoder) { e.Str(s.Title) } } + case ManagedAgentsVideoBlockManagedAgentsToolResultContentBlockSum: + e.FieldStart("type") + e.Str("video") + { + s := s.ManagedAgentsVideoBlock + { + e.FieldStart("source") + s.Source.Encode(e) + } + } } } @@ -7242,6 +8042,9 @@ func (s *ManagedAgentsToolResultContentBlockSum) Decode(d *jx.Decoder) error { case "search_result": s.Type = ManagedAgentsSearchResultBlockManagedAgentsToolResultContentBlockSum found = true + case "video": + s.Type = ManagedAgentsVideoBlockManagedAgentsToolResultContentBlockSum + found = true default: return errors.Errorf("unknown type %s", typ) } @@ -7272,6 +8075,10 @@ func (s *ManagedAgentsToolResultContentBlockSum) Decode(d *jx.Decoder) error { if err := s.ManagedAgentsSearchResultBlock.Decode(d); err != nil { return err } + case ManagedAgentsVideoBlockManagedAgentsToolResultContentBlockSum: + if err := s.ManagedAgentsVideoBlock.Decode(d); err != nil { + return err + } default: return errors.Errorf("inferred invalid type: %s", s.Type) } @@ -8171,36 +8978,183 @@ func (s *ManagedAgentsUserToolResultEventParams) UnmarshalJSON(data []byte) erro } // Encode implements json.Marshaler. -func (s *ModelOverrides) Encode(e *jx.Encoder) { +func (s *ManagedAgentsVideoBlock) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } // encodeFields encodes fields. -func (s *ModelOverrides) encodeFields(e *jx.Encoder) { +func (s *ManagedAgentsVideoBlock) encodeFields(e *jx.Encoder) { { - if s.ID.Set { - e.FieldStart("id") - s.ID.Encode(e) - } + e.FieldStart("type") + s.Type.Encode(e) } { - if s.Speed.Set { - e.FieldStart("speed") - s.Speed.Encode(e) - } + e.FieldStart("source") + s.Source.Encode(e) } - { - if s.Thinking.Set { - e.FieldStart("thinking") - s.Thinking.Encode(e) - } +} + +var jsonFieldsNameOfManagedAgentsVideoBlock = [2]string{ + 0: "type", + 1: "source", +} + +// Decode decodes ManagedAgentsVideoBlock from json. +func (s *ManagedAgentsVideoBlock) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ManagedAgentsVideoBlock to nil") } - { - if s.ReasoningEffort.Set { - e.FieldStart("reasoning_effort") - s.ReasoningEffort.Encode(e) + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "type": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "source": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Source.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"source\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ManagedAgentsVideoBlock") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfManagedAgentsVideoBlock) { + name = jsonFieldsNameOfManagedAgentsVideoBlock[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ManagedAgentsVideoBlock) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ManagedAgentsVideoBlock) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ManagedAgentsVideoBlockType as json. +func (s ManagedAgentsVideoBlockType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes ManagedAgentsVideoBlockType from json. +func (s *ManagedAgentsVideoBlockType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ManagedAgentsVideoBlockType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch ManagedAgentsVideoBlockType(v) { + case ManagedAgentsVideoBlockTypeVideo: + *s = ManagedAgentsVideoBlockTypeVideo + default: + *s = ManagedAgentsVideoBlockType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ManagedAgentsVideoBlockType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ManagedAgentsVideoBlockType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ModelOverrides) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ModelOverrides) encodeFields(e *jx.Encoder) { + { + if s.ID.Set { + e.FieldStart("id") + s.ID.Encode(e) + } + } + { + if s.Speed.Set { + e.FieldStart("speed") + s.Speed.Encode(e) + } + } + { + if s.Thinking.Set { + e.FieldStart("thinking") + s.Thinking.Encode(e) + } + } + { + if s.ReasoningEffort.Set { + e.FieldStart("reasoning_effort") + s.ReasoningEffort.Encode(e) } } { @@ -9204,6 +10158,41 @@ func (s *OptEnvironmentWithUpgrades) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes float64 as json. +func (o OptFloat64) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Float64(float64(o.Value)) +} + +// Decode decodes float64 from json. +func (o *OptFloat64) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptFloat64 to nil") + } + o.Set = true + v, err := d.Float64() + if err != nil { + return err + } + o.Value = float64(v) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptFloat64) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptFloat64) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes int32 as json. func (o OptInt32) Encode(e *jx.Encoder) { if !o.Set { @@ -9949,6 +10938,10 @@ func (s *PlainTextDocumentSource) Encode(e *jx.Encoder) { // encodeFields encodes fields. func (s *PlainTextDocumentSource) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } { e.FieldStart("data") e.Str(s.Data) @@ -9959,9 +10952,10 @@ func (s *PlainTextDocumentSource) encodeFields(e *jx.Encoder) { } } -var jsonFieldsNameOfPlainTextDocumentSource = [2]string{ - 0: "data", - 1: "media_type", +var jsonFieldsNameOfPlainTextDocumentSource = [3]string{ + 0: "type", + 1: "data", + 2: "media_type", } // Decode decodes PlainTextDocumentSource from json. @@ -9973,8 +10967,18 @@ func (s *PlainTextDocumentSource) Decode(d *jx.Decoder) error { if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "data": + case "type": requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "data": + requiredBitSet[0] |= 1 << 1 if err := func() error { v, err := d.Str() s.Data = string(v) @@ -9986,7 +10990,7 @@ func (s *PlainTextDocumentSource) Decode(d *jx.Decoder) error { return errors.Wrap(err, "decode field \"data\"") } case "media_type": - requiredBitSet[0] |= 1 << 1 + requiredBitSet[0] |= 1 << 2 if err := func() error { v, err := d.Str() s.MediaType = string(v) @@ -10007,7 +11011,7 @@ func (s *PlainTextDocumentSource) Decode(d *jx.Decoder) error { // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00000011, + 0b00000111, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -10053,6 +11057,44 @@ func (s *PlainTextDocumentSource) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes PlainTextDocumentSourceType as json. +func (s PlainTextDocumentSourceType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes PlainTextDocumentSourceType from json. +func (s *PlainTextDocumentSourceType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode PlainTextDocumentSourceType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch PlainTextDocumentSourceType(v) { + case PlainTextDocumentSourceTypeText: + *s = PlainTextDocumentSourceTypeText + default: + *s = PlainTextDocumentSourceType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s PlainTextDocumentSourceType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *PlainTextDocumentSourceType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *SearchResultCitations) Encode(e *jx.Encoder) { e.ObjStart() @@ -10158,14 +11200,19 @@ func (s *SearchResultContent) Encode(e *jx.Encoder) { // encodeFields encodes fields. func (s *SearchResultContent) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } { e.FieldStart("text") e.Str(s.Text) } } -var jsonFieldsNameOfSearchResultContent = [1]string{ - 0: "text", +var jsonFieldsNameOfSearchResultContent = [2]string{ + 0: "type", + 1: "text", } // Decode decodes SearchResultContent from json. @@ -10177,8 +11224,18 @@ func (s *SearchResultContent) Decode(d *jx.Decoder) error { if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "text": + case "type": requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "text": + requiredBitSet[0] |= 1 << 1 if err := func() error { v, err := d.Str() s.Text = string(v) @@ -10199,7 +11256,7 @@ func (s *SearchResultContent) Decode(d *jx.Decoder) error { // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00000001, + 0b00000011, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -10245,6 +11302,44 @@ func (s *SearchResultContent) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes SearchResultContentType as json. +func (s SearchResultContentType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes SearchResultContentType from json. +func (s *SearchResultContentType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode SearchResultContentType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch SearchResultContentType(v) { + case SearchResultContentTypeText: + *s = SearchResultContentTypeText + default: + *s = SearchResultContentType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s SearchResultContentType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *SearchResultContentType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *SendSessionEventsRequest) Encode(e *jx.Encoder) { e.ObjStart() @@ -12364,14 +13459,19 @@ func (s *UrlDocumentSource) Encode(e *jx.Encoder) { // encodeFields encodes fields. func (s *UrlDocumentSource) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } { e.FieldStart("url") e.Str(s.URL) } } -var jsonFieldsNameOfUrlDocumentSource = [1]string{ - 0: "url", +var jsonFieldsNameOfUrlDocumentSource = [2]string{ + 0: "type", + 1: "url", } // Decode decodes UrlDocumentSource from json. @@ -12383,8 +13483,18 @@ func (s *UrlDocumentSource) Decode(d *jx.Decoder) error { if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "url": + case "type": requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "url": + requiredBitSet[0] |= 1 << 1 if err := func() error { v, err := d.Str() s.URL = string(v) @@ -12405,7 +13515,7 @@ func (s *UrlDocumentSource) Decode(d *jx.Decoder) error { // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00000001, + 0b00000011, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -12451,23 +13561,66 @@ func (s *UrlDocumentSource) UnmarshalJSON(data []byte) error { return s.Decode(d) } -// Encode implements json.Marshaler. -func (s *UrlImageSource) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() +// Encode encodes UrlDocumentSourceType as json. +func (s UrlDocumentSourceType) Encode(e *jx.Encoder) { + e.Str(string(s)) } -// encodeFields encodes fields. -func (s *UrlImageSource) encodeFields(e *jx.Encoder) { - { - e.FieldStart("url") +// Decode decodes UrlDocumentSourceType from json. +func (s *UrlDocumentSourceType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UrlDocumentSourceType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch UrlDocumentSourceType(v) { + case UrlDocumentSourceTypeURL: + *s = UrlDocumentSourceTypeURL + default: + *s = UrlDocumentSourceType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s UrlDocumentSourceType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *UrlDocumentSourceType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *UrlImageSource) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *UrlImageSource) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } + { + e.FieldStart("url") e.Str(s.URL) } } -var jsonFieldsNameOfUrlImageSource = [1]string{ - 0: "url", +var jsonFieldsNameOfUrlImageSource = [2]string{ + 0: "type", + 1: "url", } // Decode decodes UrlImageSource from json. @@ -12479,8 +13632,18 @@ func (s *UrlImageSource) Decode(d *jx.Decoder) error { if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "url": + case "type": requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "url": + requiredBitSet[0] |= 1 << 1 if err := func() error { v, err := d.Str() s.URL = string(v) @@ -12501,7 +13664,7 @@ func (s *UrlImageSource) Decode(d *jx.Decoder) error { // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00000001, + 0b00000011, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -12546,3 +13709,398 @@ func (s *UrlImageSource) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } + +// Encode encodes UrlImageSourceType as json. +func (s UrlImageSourceType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes UrlImageSourceType from json. +func (s *UrlImageSourceType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UrlImageSourceType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch UrlImageSourceType(v) { + case UrlImageSourceTypeURL: + *s = UrlImageSourceTypeURL + default: + *s = UrlImageSourceType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s UrlImageSourceType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *UrlImageSourceType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *UrlVideoSource) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *UrlVideoSource) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } + { + e.FieldStart("url") + e.Str(s.URL) + } + { + if s.Fps.Set { + e.FieldStart("fps") + s.Fps.Encode(e) + } + } +} + +var jsonFieldsNameOfUrlVideoSource = [3]string{ + 0: "type", + 1: "url", + 2: "fps", +} + +// Decode decodes UrlVideoSource from json. +func (s *UrlVideoSource) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UrlVideoSource to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "type": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "url": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.URL = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"url\"") + } + case "fps": + if err := func() error { + s.Fps.Reset() + if err := s.Fps.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"fps\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode UrlVideoSource") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfUrlVideoSource) { + name = jsonFieldsNameOfUrlVideoSource[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *UrlVideoSource) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *UrlVideoSource) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes UrlVideoSourceType as json. +func (s UrlVideoSourceType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes UrlVideoSourceType from json. +func (s *UrlVideoSourceType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UrlVideoSourceType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch UrlVideoSourceType(v) { + case UrlVideoSourceTypeURL: + *s = UrlVideoSourceTypeURL + default: + *s = UrlVideoSourceType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s UrlVideoSourceType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *UrlVideoSourceType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *VideoSource) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *VideoSource) encodeFields(e *jx.Encoder) { + s.OneOf.encodeFields(e) +} + +var jsonFieldsNameOfVideoSource = [0]string{} + +// Decode decodes VideoSource from json. +func (s *VideoSource) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode VideoSource to nil") + } + if err := d.Capture(func(d *jx.Decoder) error { + return s.OneOf.Decode(d) + }); err != nil { + return errors.Wrap(err, "decode field OneOf") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + default: + return d.Skip() + } + }); err != nil { + return errors.Wrap(err, "decode VideoSource") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *VideoSource) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *VideoSource) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes VideoSourceSum as json. +func (s VideoSourceSum) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +func (s VideoSourceSum) encodeFields(e *jx.Encoder) { + switch s.Type { + case Base64VideoSourceVideoSourceSum: + e.FieldStart("type") + e.Str("base64") + { + s := s.Base64VideoSource + { + e.FieldStart("data") + e.Str(s.Data) + } + { + e.FieldStart("media_type") + e.Str(s.MediaType) + } + { + if s.Fps.Set { + e.FieldStart("fps") + s.Fps.Encode(e) + } + } + } + case UrlVideoSourceVideoSourceSum: + e.FieldStart("type") + e.Str("url") + { + s := s.UrlVideoSource + { + e.FieldStart("url") + e.Str(s.URL) + } + { + if s.Fps.Set { + e.FieldStart("fps") + s.Fps.Encode(e) + } + } + } + case FileVideoSourceVideoSourceSum: + e.FieldStart("type") + e.Str("file") + { + s := s.FileVideoSource + { + e.FieldStart("file_id") + e.Str(s.FileID) + } + { + if s.Fps.Set { + e.FieldStart("fps") + s.Fps.Encode(e) + } + } + } + } +} + +// Decode decodes VideoSourceSum from json. +func (s *VideoSourceSum) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode VideoSourceSum to nil") + } + // Sum type discriminator. + if typ := d.Next(); typ != jx.Object { + return errors.Errorf("unexpected json type %q", typ) + } + + var found bool + if err := d.Capture(func(d *jx.Decoder) error { + return d.ObjBytes(func(d *jx.Decoder, key []byte) error { + if found { + return d.Skip() + } + switch string(key) { + case "type": + typ, err := d.Str() + if err != nil { + return err + } + switch typ { + case "base64": + s.Type = Base64VideoSourceVideoSourceSum + found = true + case "url": + s.Type = UrlVideoSourceVideoSourceSum + found = true + case "file": + s.Type = FileVideoSourceVideoSourceSum + found = true + default: + return errors.Errorf("unknown type %s", typ) + } + return nil + } + return d.Skip() + }) + }); err != nil { + return errors.Wrap(err, "capture") + } + if !found { + return errors.New("unable to detect sum type variant") + } + switch s.Type { + case Base64VideoSourceVideoSourceSum: + if err := s.Base64VideoSource.Decode(d); err != nil { + return err + } + case UrlVideoSourceVideoSourceSum: + if err := s.UrlVideoSource.Decode(d); err != nil { + return err + } + case FileVideoSourceVideoSourceSum: + if err := s.FileVideoSource.Decode(d); err != nil { + return err + } + default: + return errors.Errorf("inferred invalid type: %s", s.Type) + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s VideoSourceSum) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *VideoSourceSum) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} diff --git a/arkruntime/model/session/oas_schemas_gen.go b/arkruntime/model/session/oas_schemas_gen.go index 45b5214..52b06f0 100644 --- a/arkruntime/model/session/oas_schemas_gen.go +++ b/arkruntime/model/session/oas_schemas_gen.go @@ -467,12 +467,18 @@ func (s *AgentWithUpgradesType) UnmarshalText(data []byte) error { // 直接以 base64 携带的文档数据。. // Ref: #/components/schemas/Base64DocumentSource type Base64DocumentSource struct { + Type Base64DocumentSourceType `json:"type"` // Base64 文档数据。. Data string `json:"data"` // MIME 类型,如 `application/pdf`。. MediaType string `json:"media_type"` } +// GetType returns the value of Type. +func (s *Base64DocumentSource) GetType() Base64DocumentSourceType { + return s.Type +} + // GetData returns the value of Data. func (s *Base64DocumentSource) GetData() string { return s.Data @@ -483,6 +489,11 @@ func (s *Base64DocumentSource) GetMediaType() string { return s.MediaType } +// SetType sets the value of Type. +func (s *Base64DocumentSource) SetType(val Base64DocumentSourceType) { + s.Type = val +} + // SetData sets the value of Data. func (s *Base64DocumentSource) SetData(val string) { s.Data = val @@ -493,15 +504,55 @@ func (s *Base64DocumentSource) SetMediaType(val string) { s.MediaType = val } +type Base64DocumentSourceType string + +const ( + Base64DocumentSourceTypeBase64 Base64DocumentSourceType = "base64" +) + +// AllValues returns all Base64DocumentSourceType values. +func (Base64DocumentSourceType) AllValues() []Base64DocumentSourceType { + return []Base64DocumentSourceType{ + Base64DocumentSourceTypeBase64, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s Base64DocumentSourceType) MarshalText() ([]byte, error) { + switch s { + case Base64DocumentSourceTypeBase64: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *Base64DocumentSourceType) UnmarshalText(data []byte) error { + switch Base64DocumentSourceType(data) { + case Base64DocumentSourceTypeBase64: + *s = Base64DocumentSourceTypeBase64 + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + // 直接以 base64 携带的图片数据。. // Ref: #/components/schemas/Base64ImageSource type Base64ImageSource struct { + Type Base64ImageSourceType `json:"type"` // Base64 图片数据。. Data string `json:"data"` // MIME 类型,如 `image/png` / `image/jpeg`。. MediaType string `json:"media_type"` } +// GetType returns the value of Type. +func (s *Base64ImageSource) GetType() Base64ImageSourceType { + return s.Type +} + // GetData returns the value of Data. func (s *Base64ImageSource) GetData() string { return s.Data @@ -512,6 +563,11 @@ func (s *Base64ImageSource) GetMediaType() string { return s.MediaType } +// SetType sets the value of Type. +func (s *Base64ImageSource) SetType(val Base64ImageSourceType) { + s.Type = val +} + // SetData sets the value of Data. func (s *Base64ImageSource) SetData(val string) { s.Data = val @@ -522,6 +578,126 @@ func (s *Base64ImageSource) SetMediaType(val string) { s.MediaType = val } +type Base64ImageSourceType string + +const ( + Base64ImageSourceTypeBase64 Base64ImageSourceType = "base64" +) + +// AllValues returns all Base64ImageSourceType values. +func (Base64ImageSourceType) AllValues() []Base64ImageSourceType { + return []Base64ImageSourceType{ + Base64ImageSourceTypeBase64, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s Base64ImageSourceType) MarshalText() ([]byte, error) { + switch s { + case Base64ImageSourceTypeBase64: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *Base64ImageSourceType) UnmarshalText(data []byte) error { + switch Base64ImageSourceType(data) { + case Base64ImageSourceTypeBase64: + *s = Base64ImageSourceTypeBase64 + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// 直接以 base64 携带的视频。. +// Ref: #/components/schemas/Base64VideoSource +type Base64VideoSource struct { + Type Base64VideoSourceType `json:"type"` + // Base64 编码的视频数据。. + Data string `json:"data"` + // 视频 MIME 类型:`video/mp4` / `video/x-msvideo` / `video/quicktime`。. + MediaType string `json:"media_type"` + // 视频抽帧帧率;省略时由下游模型默认策略决定。. + Fps OptFloat64 `json:"fps"` +} + +// GetType returns the value of Type. +func (s *Base64VideoSource) GetType() Base64VideoSourceType { + return s.Type +} + +// GetData returns the value of Data. +func (s *Base64VideoSource) GetData() string { + return s.Data +} + +// GetMediaType returns the value of MediaType. +func (s *Base64VideoSource) GetMediaType() string { + return s.MediaType +} + +// GetFps returns the value of Fps. +func (s *Base64VideoSource) GetFps() OptFloat64 { + return s.Fps +} + +// SetType sets the value of Type. +func (s *Base64VideoSource) SetType(val Base64VideoSourceType) { + s.Type = val +} + +// SetData sets the value of Data. +func (s *Base64VideoSource) SetData(val string) { + s.Data = val +} + +// SetMediaType sets the value of MediaType. +func (s *Base64VideoSource) SetMediaType(val string) { + s.MediaType = val +} + +// SetFps sets the value of Fps. +func (s *Base64VideoSource) SetFps(val OptFloat64) { + s.Fps = val +} + +type Base64VideoSourceType string + +const ( + Base64VideoSourceTypeBase64 Base64VideoSourceType = "base64" +) + +// AllValues returns all Base64VideoSourceType values. +func (Base64VideoSourceType) AllValues() []Base64VideoSourceType { + return []Base64VideoSourceType{ + Base64VideoSourceTypeBase64, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s Base64VideoSourceType) MarshalText() ([]byte, error) { + switch s { + case Base64VideoSourceTypeBase64: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *Base64VideoSourceType) UnmarshalText(data []byte) error { + switch Base64VideoSourceType(data) { + case Base64VideoSourceTypeBase64: + *s = Base64VideoSourceTypeBase64 + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + // Token-usage 子段:每种缓存口径的输入 token 数。. // Ref: #/components/schemas/CacheCreation type CacheCreation struct { @@ -1849,37 +2025,201 @@ func (s *EnvironmentWithUpgradesType) UnmarshalText(data []byte) error { // 通过 Files API 上传后引用的文档。. // Ref: #/components/schemas/FileDocumentSource type FileDocumentSource struct { + Type FileDocumentSourceType `json:"type"` // File id,形如 `file_...`。. FileID string `json:"file_id"` } +// GetType returns the value of Type. +func (s *FileDocumentSource) GetType() FileDocumentSourceType { + return s.Type +} + // GetFileID returns the value of FileID. func (s *FileDocumentSource) GetFileID() string { return s.FileID } +// SetType sets the value of Type. +func (s *FileDocumentSource) SetType(val FileDocumentSourceType) { + s.Type = val +} + // SetFileID sets the value of FileID. func (s *FileDocumentSource) SetFileID(val string) { s.FileID = val } +type FileDocumentSourceType string + +const ( + FileDocumentSourceTypeFile FileDocumentSourceType = "file" +) + +// AllValues returns all FileDocumentSourceType values. +func (FileDocumentSourceType) AllValues() []FileDocumentSourceType { + return []FileDocumentSourceType{ + FileDocumentSourceTypeFile, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s FileDocumentSourceType) MarshalText() ([]byte, error) { + switch s { + case FileDocumentSourceTypeFile: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *FileDocumentSourceType) UnmarshalText(data []byte) error { + switch FileDocumentSourceType(data) { + case FileDocumentSourceTypeFile: + *s = FileDocumentSourceTypeFile + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + // 通过 Files API 上传后引用的图片。. // Ref: #/components/schemas/FileImageSource type FileImageSource struct { + Type FileImageSourceType `json:"type"` // File id,形如 `file_...`。. FileID string `json:"file_id"` } +// GetType returns the value of Type. +func (s *FileImageSource) GetType() FileImageSourceType { + return s.Type +} + // GetFileID returns the value of FileID. func (s *FileImageSource) GetFileID() string { return s.FileID } +// SetType sets the value of Type. +func (s *FileImageSource) SetType(val FileImageSourceType) { + s.Type = val +} + // SetFileID sets the value of FileID. func (s *FileImageSource) SetFileID(val string) { s.FileID = val } +type FileImageSourceType string + +const ( + FileImageSourceTypeFile FileImageSourceType = "file" +) + +// AllValues returns all FileImageSourceType values. +func (FileImageSourceType) AllValues() []FileImageSourceType { + return []FileImageSourceType{ + FileImageSourceTypeFile, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s FileImageSourceType) MarshalText() ([]byte, error) { + switch s { + case FileImageSourceTypeFile: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *FileImageSourceType) UnmarshalText(data []byte) error { + switch FileImageSourceType(data) { + case FileImageSourceTypeFile: + *s = FileImageSourceTypeFile + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// 通过 Files API 上传后引用的视频。. +// Ref: #/components/schemas/FileVideoSource +type FileVideoSource struct { + Type FileVideoSourceType `json:"type"` + // 已上传的视频 file id。. + FileID string `json:"file_id"` + // 视频抽帧帧率;file 改写为 URL 时透传此值。. + Fps OptFloat64 `json:"fps"` +} + +// GetType returns the value of Type. +func (s *FileVideoSource) GetType() FileVideoSourceType { + return s.Type +} + +// GetFileID returns the value of FileID. +func (s *FileVideoSource) GetFileID() string { + return s.FileID +} + +// GetFps returns the value of Fps. +func (s *FileVideoSource) GetFps() OptFloat64 { + return s.Fps +} + +// SetType sets the value of Type. +func (s *FileVideoSource) SetType(val FileVideoSourceType) { + s.Type = val +} + +// SetFileID sets the value of FileID. +func (s *FileVideoSource) SetFileID(val string) { + s.FileID = val +} + +// SetFps sets the value of Fps. +func (s *FileVideoSource) SetFps(val OptFloat64) { + s.Fps = val +} + +type FileVideoSourceType string + +const ( + FileVideoSourceTypeFile FileVideoSourceType = "file" +) + +// AllValues returns all FileVideoSourceType values. +func (FileVideoSourceType) AllValues() []FileVideoSourceType { + return []FileVideoSourceType{ + FileVideoSourceTypeFile, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s FileVideoSourceType) MarshalText() ([]byte, error) { + switch s { + case FileVideoSourceTypeFile: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *FileVideoSourceType) UnmarshalText(data []byte) error { + switch FileVideoSourceType(data) { + case FileVideoSourceTypeFile: + *s = FileVideoSourceTypeFile + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + // `GET /checkpoints/{checkpoint_id}` 响应体。. // Ref: #/components/schemas/GetSessionCheckpointResponse type GetSessionCheckpointResponse struct { @@ -2199,6 +2539,7 @@ func (s *ListSessionsResponse) SetNextPage(val OptString) { // 文档块。. // Ref: #/components/schemas/ManagedAgentsDocumentBlock type ManagedAgentsDocumentBlock struct { + Type ManagedAgentsDocumentBlockType `json:"type"` // 文档来源。. Source DocumentSource `json:"source"` // 文档标题。. @@ -2207,6 +2548,11 @@ type ManagedAgentsDocumentBlock struct { Context OptString `json:"context"` } +// GetType returns the value of Type. +func (s *ManagedAgentsDocumentBlock) GetType() ManagedAgentsDocumentBlockType { + return s.Type +} + // GetSource returns the value of Source. func (s *ManagedAgentsDocumentBlock) GetSource() DocumentSource { return s.Source @@ -2222,6 +2568,11 @@ func (s *ManagedAgentsDocumentBlock) GetContext() OptString { return s.Context } +// SetType sets the value of Type. +func (s *ManagedAgentsDocumentBlock) SetType(val ManagedAgentsDocumentBlockType) { + s.Type = val +} + // SetSource sets the value of Source. func (s *ManagedAgentsDocumentBlock) SetSource(val DocumentSource) { s.Source = val @@ -2237,6 +2588,40 @@ func (s *ManagedAgentsDocumentBlock) SetContext(val OptString) { s.Context = val } +type ManagedAgentsDocumentBlockType string + +const ( + ManagedAgentsDocumentBlockTypeDocument ManagedAgentsDocumentBlockType = "document" +) + +// AllValues returns all ManagedAgentsDocumentBlockType values. +func (ManagedAgentsDocumentBlockType) AllValues() []ManagedAgentsDocumentBlockType { + return []ManagedAgentsDocumentBlockType{ + ManagedAgentsDocumentBlockTypeDocument, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s ManagedAgentsDocumentBlockType) MarshalText() ([]byte, error) { + switch s { + case ManagedAgentsDocumentBlockTypeDocument: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *ManagedAgentsDocumentBlockType) UnmarshalText(data []byte) error { + switch ManagedAgentsDocumentBlockType(data) { + case ManagedAgentsDocumentBlockTypeDocument: + *s = ManagedAgentsDocumentBlockTypeDocument + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + // 客户端可提交的 7 种事件 tagged union(discriminator = `type`)。 // SDK marshal 变体时自动注入 `"type": ""`,调用方不必手填该字段。 // 变体名的 `.` 通过反引号 escape,但 discriminator 值就是原始形态 @@ -2484,22 +2869,67 @@ func (s *ManagedAgentsFileRubricParams) SetFileID(val string) { // 图片块。. // Ref: #/components/schemas/ManagedAgentsImageBlock type ManagedAgentsImageBlock struct { + Type ManagedAgentsImageBlockType `json:"type"` // 图片来源。. Source ImageSource `json:"source"` } +// GetType returns the value of Type. +func (s *ManagedAgentsImageBlock) GetType() ManagedAgentsImageBlockType { + return s.Type +} + // GetSource returns the value of Source. func (s *ManagedAgentsImageBlock) GetSource() ImageSource { return s.Source } +// SetType sets the value of Type. +func (s *ManagedAgentsImageBlock) SetType(val ManagedAgentsImageBlockType) { + s.Type = val +} + // SetSource sets the value of Source. func (s *ManagedAgentsImageBlock) SetSource(val ImageSource) { s.Source = val } +type ManagedAgentsImageBlockType string + +const ( + ManagedAgentsImageBlockTypeImage ManagedAgentsImageBlockType = "image" +) + +// AllValues returns all ManagedAgentsImageBlockType values. +func (ManagedAgentsImageBlockType) AllValues() []ManagedAgentsImageBlockType { + return []ManagedAgentsImageBlockType{ + ManagedAgentsImageBlockTypeImage, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s ManagedAgentsImageBlockType) MarshalText() ([]byte, error) { + switch s { + case ManagedAgentsImageBlockTypeImage: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *ManagedAgentsImageBlockType) UnmarshalText(data []byte) error { + switch ManagedAgentsImageBlockType(data) { + case ManagedAgentsImageBlockTypeImage: + *s = ManagedAgentsImageBlockTypeImage + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + // `user.message` 的 content 列表元素 tagged union(discriminator = `type`)。 -// 支持 3 种模态:`text` / `image` / `document`。. +// 支持 4 种模态:`text` / `image` / `document` / `video`。. // Ref: #/components/schemas/ManagedAgentsMessageContentBlock type ManagedAgentsMessageContentBlock struct { OneOf ManagedAgentsMessageContentBlockSum @@ -2521,6 +2951,7 @@ type ManagedAgentsMessageContentBlockSum struct { ManagedAgentsTextBlock ManagedAgentsTextBlock ManagedAgentsImageBlock ManagedAgentsImageBlock ManagedAgentsDocumentBlock ManagedAgentsDocumentBlock + ManagedAgentsVideoBlock ManagedAgentsVideoBlock } // ManagedAgentsMessageContentBlockSumType is oneOf type of ManagedAgentsMessageContentBlockSum. @@ -2531,6 +2962,7 @@ const ( ManagedAgentsTextBlockManagedAgentsMessageContentBlockSum ManagedAgentsMessageContentBlockSumType = "text" ManagedAgentsImageBlockManagedAgentsMessageContentBlockSum ManagedAgentsMessageContentBlockSumType = "image" ManagedAgentsDocumentBlockManagedAgentsMessageContentBlockSum ManagedAgentsMessageContentBlockSumType = "document" + ManagedAgentsVideoBlockManagedAgentsMessageContentBlockSum ManagedAgentsMessageContentBlockSumType = "video" ) // IsManagedAgentsTextBlock reports whether ManagedAgentsMessageContentBlockSum is ManagedAgentsTextBlock. @@ -2548,6 +2980,11 @@ func (s ManagedAgentsMessageContentBlockSum) IsManagedAgentsDocumentBlock() bool return s.Type == ManagedAgentsDocumentBlockManagedAgentsMessageContentBlockSum } +// IsManagedAgentsVideoBlock reports whether ManagedAgentsMessageContentBlockSum is ManagedAgentsVideoBlock. +func (s ManagedAgentsMessageContentBlockSum) IsManagedAgentsVideoBlock() bool { + return s.Type == ManagedAgentsVideoBlockManagedAgentsMessageContentBlockSum +} + // SetManagedAgentsTextBlock sets ManagedAgentsMessageContentBlockSum to ManagedAgentsTextBlock. func (s *ManagedAgentsMessageContentBlockSum) SetManagedAgentsTextBlock(v ManagedAgentsTextBlock) { s.Type = ManagedAgentsTextBlockManagedAgentsMessageContentBlockSum @@ -2611,6 +3048,27 @@ func NewManagedAgentsDocumentBlockManagedAgentsMessageContentBlockSum(v ManagedA return s } +// SetManagedAgentsVideoBlock sets ManagedAgentsMessageContentBlockSum to ManagedAgentsVideoBlock. +func (s *ManagedAgentsMessageContentBlockSum) SetManagedAgentsVideoBlock(v ManagedAgentsVideoBlock) { + s.Type = ManagedAgentsVideoBlockManagedAgentsMessageContentBlockSum + s.ManagedAgentsVideoBlock = v +} + +// GetManagedAgentsVideoBlock returns ManagedAgentsVideoBlock and true boolean if ManagedAgentsMessageContentBlockSum is ManagedAgentsVideoBlock. +func (s ManagedAgentsMessageContentBlockSum) GetManagedAgentsVideoBlock() (v ManagedAgentsVideoBlock, ok bool) { + if !s.IsManagedAgentsVideoBlock() { + return v, false + } + return s.ManagedAgentsVideoBlock, true +} + +// NewManagedAgentsVideoBlockManagedAgentsMessageContentBlockSum returns new ManagedAgentsMessageContentBlockSum from ManagedAgentsVideoBlock. +func NewManagedAgentsVideoBlockManagedAgentsMessageContentBlockSum(v ManagedAgentsVideoBlock) ManagedAgentsMessageContentBlockSum { + var s ManagedAgentsMessageContentBlockSum + s.SetManagedAgentsVideoBlock(v) + return s +} + // 评测 rubric tagged union——`file` 引用 / 内联 `text`。. // Ref: #/components/schemas/ManagedAgentsRubric type ManagedAgentsRubric struct { @@ -2698,6 +3156,7 @@ func NewManagedAgentsTextRubricParamsManagedAgentsRubricSum(v ManagedAgentsTextR // 搜索结果块——多个 SearchResultContent 文本片段 + 元信息。. // Ref: #/components/schemas/ManagedAgentsSearchResultBlock type ManagedAgentsSearchResultBlock struct { + Type ManagedAgentsSearchResultBlockType `json:"type"` // Citation 控制。. Citations SearchResultCitations `json:"citations"` // 结果内容片段。. @@ -2708,6 +3167,11 @@ type ManagedAgentsSearchResultBlock struct { Title string `json:"title"` } +// GetType returns the value of Type. +func (s *ManagedAgentsSearchResultBlock) GetType() ManagedAgentsSearchResultBlockType { + return s.Type +} + // GetCitations returns the value of Citations. func (s *ManagedAgentsSearchResultBlock) GetCitations() SearchResultCitations { return s.Citations @@ -2728,6 +3192,11 @@ func (s *ManagedAgentsSearchResultBlock) GetTitle() string { return s.Title } +// SetType sets the value of Type. +func (s *ManagedAgentsSearchResultBlock) SetType(val ManagedAgentsSearchResultBlockType) { + s.Type = val +} + // SetCitations sets the value of Citations. func (s *ManagedAgentsSearchResultBlock) SetCitations(val SearchResultCitations) { s.Citations = val @@ -2748,6 +3217,40 @@ func (s *ManagedAgentsSearchResultBlock) SetTitle(val string) { s.Title = val } +type ManagedAgentsSearchResultBlockType string + +const ( + ManagedAgentsSearchResultBlockTypeSearchResult ManagedAgentsSearchResultBlockType = "search_result" +) + +// AllValues returns all ManagedAgentsSearchResultBlockType values. +func (ManagedAgentsSearchResultBlockType) AllValues() []ManagedAgentsSearchResultBlockType { + return []ManagedAgentsSearchResultBlockType{ + ManagedAgentsSearchResultBlockTypeSearchResult, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s ManagedAgentsSearchResultBlockType) MarshalText() ([]byte, error) { + switch s { + case ManagedAgentsSearchResultBlockTypeSearchResult: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *ManagedAgentsSearchResultBlockType) UnmarshalText(data []byte) error { + switch ManagedAgentsSearchResultBlockType(data) { + case ManagedAgentsSearchResultBlockTypeSearchResult: + *s = ManagedAgentsSearchResultBlockTypeSearchResult + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + // `system.message` 的 content 列表元素——目前仅支持文本块,保留 union 语义以便 // 未来无破坏性扩展(image / document 等)。. // Ref: #/components/schemas/ManagedAgentsSystemContentBlock @@ -2850,20 +3353,65 @@ func (s *ManagedAgentsSystemMessageEventParams) SetSessionThreadID(val OptString // 文本块。用于 user.message / tool_result / system.message 的 content 列表。. // Ref: #/components/schemas/ManagedAgentsTextBlock type ManagedAgentsTextBlock struct { + Type ManagedAgentsTextBlockType `json:"type"` // 文本内容。. Text string `json:"text"` } +// GetType returns the value of Type. +func (s *ManagedAgentsTextBlock) GetType() ManagedAgentsTextBlockType { + return s.Type +} + // GetText returns the value of Text. func (s *ManagedAgentsTextBlock) GetText() string { return s.Text } +// SetType sets the value of Type. +func (s *ManagedAgentsTextBlock) SetType(val ManagedAgentsTextBlockType) { + s.Type = val +} + // SetText sets the value of Text. func (s *ManagedAgentsTextBlock) SetText(val string) { s.Text = val } +type ManagedAgentsTextBlockType string + +const ( + ManagedAgentsTextBlockTypeText ManagedAgentsTextBlockType = "text" +) + +// AllValues returns all ManagedAgentsTextBlockType values. +func (ManagedAgentsTextBlockType) AllValues() []ManagedAgentsTextBlockType { + return []ManagedAgentsTextBlockType{ + ManagedAgentsTextBlockTypeText, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s ManagedAgentsTextBlockType) MarshalText() ([]byte, error) { + switch s { + case ManagedAgentsTextBlockTypeText: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *ManagedAgentsTextBlockType) UnmarshalText(data []byte) error { + switch ManagedAgentsTextBlockType(data) { + case ManagedAgentsTextBlockTypeText: + *s = ManagedAgentsTextBlockTypeText + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + // 直接以字符串内联的 rubric 文本。. // Ref: #/components/schemas/ManagedAgentsTextRubricParams type ManagedAgentsTextRubricParams struct { @@ -2882,7 +3430,7 @@ func (s *ManagedAgentsTextRubricParams) SetContent(val string) { } // `user.tool_result.content` / `user.custom_tool_result.content` 允许的 block -// 类型 tagged union:`text` / `image` / `document` / `search_result`。. +// 类型 tagged union:`text` / `image` / `document` / `search_result` / `video`。. // Ref: #/components/schemas/ManagedAgentsToolResultContentBlock type ManagedAgentsToolResultContentBlock struct { OneOf ManagedAgentsToolResultContentBlockSum @@ -2905,6 +3453,7 @@ type ManagedAgentsToolResultContentBlockSum struct { ManagedAgentsImageBlock ManagedAgentsImageBlock ManagedAgentsDocumentBlock ManagedAgentsDocumentBlock ManagedAgentsSearchResultBlock ManagedAgentsSearchResultBlock + ManagedAgentsVideoBlock ManagedAgentsVideoBlock } // ManagedAgentsToolResultContentBlockSumType is oneOf type of ManagedAgentsToolResultContentBlockSum. @@ -2916,6 +3465,7 @@ const ( ManagedAgentsImageBlockManagedAgentsToolResultContentBlockSum ManagedAgentsToolResultContentBlockSumType = "image" ManagedAgentsDocumentBlockManagedAgentsToolResultContentBlockSum ManagedAgentsToolResultContentBlockSumType = "document" ManagedAgentsSearchResultBlockManagedAgentsToolResultContentBlockSum ManagedAgentsToolResultContentBlockSumType = "search_result" + ManagedAgentsVideoBlockManagedAgentsToolResultContentBlockSum ManagedAgentsToolResultContentBlockSumType = "video" ) // IsManagedAgentsTextBlock reports whether ManagedAgentsToolResultContentBlockSum is ManagedAgentsTextBlock. @@ -2938,6 +3488,11 @@ func (s ManagedAgentsToolResultContentBlockSum) IsManagedAgentsSearchResultBlock return s.Type == ManagedAgentsSearchResultBlockManagedAgentsToolResultContentBlockSum } +// IsManagedAgentsVideoBlock reports whether ManagedAgentsToolResultContentBlockSum is ManagedAgentsVideoBlock. +func (s ManagedAgentsToolResultContentBlockSum) IsManagedAgentsVideoBlock() bool { + return s.Type == ManagedAgentsVideoBlockManagedAgentsToolResultContentBlockSum +} + // SetManagedAgentsTextBlock sets ManagedAgentsToolResultContentBlockSum to ManagedAgentsTextBlock. func (s *ManagedAgentsToolResultContentBlockSum) SetManagedAgentsTextBlock(v ManagedAgentsTextBlock) { s.Type = ManagedAgentsTextBlockManagedAgentsToolResultContentBlockSum @@ -3022,6 +3577,27 @@ func NewManagedAgentsSearchResultBlockManagedAgentsToolResultContentBlockSum(v M return s } +// SetManagedAgentsVideoBlock sets ManagedAgentsToolResultContentBlockSum to ManagedAgentsVideoBlock. +func (s *ManagedAgentsToolResultContentBlockSum) SetManagedAgentsVideoBlock(v ManagedAgentsVideoBlock) { + s.Type = ManagedAgentsVideoBlockManagedAgentsToolResultContentBlockSum + s.ManagedAgentsVideoBlock = v +} + +// GetManagedAgentsVideoBlock returns ManagedAgentsVideoBlock and true boolean if ManagedAgentsToolResultContentBlockSum is ManagedAgentsVideoBlock. +func (s ManagedAgentsToolResultContentBlockSum) GetManagedAgentsVideoBlock() (v ManagedAgentsVideoBlock, ok bool) { + if !s.IsManagedAgentsVideoBlock() { + return v, false + } + return s.ManagedAgentsVideoBlock, true +} + +// NewManagedAgentsVideoBlockManagedAgentsToolResultContentBlockSum returns new ManagedAgentsToolResultContentBlockSum from ManagedAgentsVideoBlock. +func NewManagedAgentsVideoBlockManagedAgentsToolResultContentBlockSum(v ManagedAgentsVideoBlock) ManagedAgentsToolResultContentBlockSum { + var s ManagedAgentsToolResultContentBlockSum + s.SetManagedAgentsVideoBlock(v) + return s +} + // `user.custom_tool_result`:custom tool(非 MCP / 非 builtin)执行结果。 // `custom_tool_use_id` 由 agent.custom_tool_use 提供,与 tool_use 路径区分。. // Ref: #/components/schemas/ManagedAgentsUserCustomToolResultEventParams @@ -3203,7 +3779,7 @@ func (s *ManagedAgentsUserInterruptEventParams) SetSessionThreadID(val OptString // declare 成 optional,让 SDK 可以 marshal 出不带 `content` 字段的 wire body。. // Ref: #/components/schemas/ManagedAgentsUserMessageEventParams type ManagedAgentsUserMessageEventParams struct { - // 消息 content:多模态 block 列表(text / image / document)。. + // 消息 content:多模态 block 列表(text / image / document / video)。. Content []ManagedAgentsMessageContentBlock `json:"content"` // 目标 session id;SDK 通常从 URL 路径推断,此字段可省。. SessionID OptString `json:"session_id"` @@ -3368,9 +3944,71 @@ func (s *ManagedAgentsUserToolResultEventParams) SetSessionID(val OptString) { s.SessionID = val } -// SetSessionThreadID sets the value of SessionThreadID. -func (s *ManagedAgentsUserToolResultEventParams) SetSessionThreadID(val OptString) { - s.SessionThreadID = val +// SetSessionThreadID sets the value of SessionThreadID. +func (s *ManagedAgentsUserToolResultEventParams) SetSessionThreadID(val OptString) { + s.SessionThreadID = val +} + +// 视频块;支持 base64 / URL / file 来源。. +// Ref: #/components/schemas/ManagedAgentsVideoBlock +type ManagedAgentsVideoBlock struct { + Type ManagedAgentsVideoBlockType `json:"type"` + // 视频来源。. + Source VideoSource `json:"source"` +} + +// GetType returns the value of Type. +func (s *ManagedAgentsVideoBlock) GetType() ManagedAgentsVideoBlockType { + return s.Type +} + +// GetSource returns the value of Source. +func (s *ManagedAgentsVideoBlock) GetSource() VideoSource { + return s.Source +} + +// SetType sets the value of Type. +func (s *ManagedAgentsVideoBlock) SetType(val ManagedAgentsVideoBlockType) { + s.Type = val +} + +// SetSource sets the value of Source. +func (s *ManagedAgentsVideoBlock) SetSource(val VideoSource) { + s.Source = val +} + +type ManagedAgentsVideoBlockType string + +const ( + ManagedAgentsVideoBlockTypeVideo ManagedAgentsVideoBlockType = "video" +) + +// AllValues returns all ManagedAgentsVideoBlockType values. +func (ManagedAgentsVideoBlockType) AllValues() []ManagedAgentsVideoBlockType { + return []ManagedAgentsVideoBlockType{ + ManagedAgentsVideoBlockTypeVideo, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s ManagedAgentsVideoBlockType) MarshalText() ([]byte, error) { + switch s { + case ManagedAgentsVideoBlockTypeVideo: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *ManagedAgentsVideoBlockType) UnmarshalText(data []byte) error { + switch ManagedAgentsVideoBlockType(data) { + case ManagedAgentsVideoBlockTypeVideo: + *s = ManagedAgentsVideoBlockTypeVideo + return nil + default: + return errors.Errorf("invalid value: %q", data) + } } // Session 创建时允许临时覆写的模型运行参数与接入配置。 @@ -4440,6 +5078,52 @@ func (o OptEnvironmentWithUpgrades) Or(d EnvironmentWithUpgrades) EnvironmentWit return d } +// NewOptFloat64 returns new OptFloat64 with value set to v. +func NewOptFloat64(v float64) OptFloat64 { + return OptFloat64{ + Value: v, + Set: true, + } +} + +// OptFloat64 is optional float64. +type OptFloat64 struct { + Value float64 + Set bool +} + +// IsSet returns true if OptFloat64 was set. +func (o OptFloat64) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptFloat64) Reset() { + var v float64 + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptFloat64) SetTo(v float64) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptFloat64) Get() (v float64, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptFloat64) Or(d float64) float64 { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptInt32 returns new OptInt32 with value set to v. func NewOptInt32(v int32) OptInt32 { return OptInt32{ @@ -5280,12 +5964,18 @@ func (s *OverrideTokenLimits) SetMaxOutputTokenLength(val int64) { // 纯文本文档;`media_type` 必须为 `text/plain`;`data` 是原文。. // Ref: #/components/schemas/PlainTextDocumentSource type PlainTextDocumentSource struct { + Type PlainTextDocumentSourceType `json:"type"` // 文档原文。. Data string `json:"data"` // MIME 类型,固定 `text/plain`。. MediaType string `json:"media_type"` } +// GetType returns the value of Type. +func (s *PlainTextDocumentSource) GetType() PlainTextDocumentSourceType { + return s.Type +} + // GetData returns the value of Data. func (s *PlainTextDocumentSource) GetData() string { return s.Data @@ -5296,6 +5986,11 @@ func (s *PlainTextDocumentSource) GetMediaType() string { return s.MediaType } +// SetType sets the value of Type. +func (s *PlainTextDocumentSource) SetType(val PlainTextDocumentSourceType) { + s.Type = val +} + // SetData sets the value of Data. func (s *PlainTextDocumentSource) SetData(val string) { s.Data = val @@ -5306,6 +6001,40 @@ func (s *PlainTextDocumentSource) SetMediaType(val string) { s.MediaType = val } +type PlainTextDocumentSourceType string + +const ( + PlainTextDocumentSourceTypeText PlainTextDocumentSourceType = "text" +) + +// AllValues returns all PlainTextDocumentSourceType values. +func (PlainTextDocumentSourceType) AllValues() []PlainTextDocumentSourceType { + return []PlainTextDocumentSourceType{ + PlainTextDocumentSourceTypeText, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s PlainTextDocumentSourceType) MarshalText() ([]byte, error) { + switch s { + case PlainTextDocumentSourceTypeText: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *PlainTextDocumentSourceType) UnmarshalText(data []byte) error { + switch PlainTextDocumentSourceType(data) { + case PlainTextDocumentSourceTypeText: + *s = PlainTextDocumentSourceTypeText + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + // 搜索结果 citation 控制——是否在最终回答中显式标注引用。. // Ref: #/components/schemas/SearchResultCitations type SearchResultCitations struct { @@ -5326,20 +6055,65 @@ func (s *SearchResultCitations) SetEnabled(val bool) { // 搜索结果内的纯文本片段。. // Ref: #/components/schemas/SearchResultContent type SearchResultContent struct { + Type SearchResultContentType `json:"type"` // 文本内容。. Text string `json:"text"` } +// GetType returns the value of Type. +func (s *SearchResultContent) GetType() SearchResultContentType { + return s.Type +} + // GetText returns the value of Text. func (s *SearchResultContent) GetText() string { return s.Text } +// SetType sets the value of Type. +func (s *SearchResultContent) SetType(val SearchResultContentType) { + s.Type = val +} + // SetText sets the value of Text. func (s *SearchResultContent) SetText(val string) { s.Text = val } +type SearchResultContentType string + +const ( + SearchResultContentTypeText SearchResultContentType = "text" +) + +// AllValues returns all SearchResultContentType values. +func (SearchResultContentType) AllValues() []SearchResultContentType { + return []SearchResultContentType{ + SearchResultContentTypeText, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s SearchResultContentType) MarshalText() ([]byte, error) { + switch s { + case SearchResultContentTypeText: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *SearchResultContentType) UnmarshalText(data []byte) error { + switch SearchResultContentType(data) { + case SearchResultContentTypeText: + *s = SearchResultContentTypeText + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + // SendSessionEvents 请求体。. // Ref: #/components/schemas/SendSessionEventsRequest type SendSessionEventsRequest struct { @@ -6438,33 +7212,303 @@ func (s *UpdateSessionRequest) SetTitle(val OptString) { // 通过 URL 引用的文档。. // Ref: #/components/schemas/UrlDocumentSource type UrlDocumentSource struct { + Type UrlDocumentSourceType `json:"type"` // 文档 URL。. URL string `json:"url"` } +// GetType returns the value of Type. +func (s *UrlDocumentSource) GetType() UrlDocumentSourceType { + return s.Type +} + // GetURL returns the value of URL. func (s *UrlDocumentSource) GetURL() string { return s.URL } +// SetType sets the value of Type. +func (s *UrlDocumentSource) SetType(val UrlDocumentSourceType) { + s.Type = val +} + // SetURL sets the value of URL. func (s *UrlDocumentSource) SetURL(val string) { s.URL = val } +type UrlDocumentSourceType string + +const ( + UrlDocumentSourceTypeURL UrlDocumentSourceType = "url" +) + +// AllValues returns all UrlDocumentSourceType values. +func (UrlDocumentSourceType) AllValues() []UrlDocumentSourceType { + return []UrlDocumentSourceType{ + UrlDocumentSourceTypeURL, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s UrlDocumentSourceType) MarshalText() ([]byte, error) { + switch s { + case UrlDocumentSourceTypeURL: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *UrlDocumentSourceType) UnmarshalText(data []byte) error { + switch UrlDocumentSourceType(data) { + case UrlDocumentSourceTypeURL: + *s = UrlDocumentSourceTypeURL + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + // 通过 URL 引用的图片。. // Ref: #/components/schemas/UrlImageSource type UrlImageSource struct { + Type UrlImageSourceType `json:"type"` // 图片 URL。. URL string `json:"url"` } +// GetType returns the value of Type. +func (s *UrlImageSource) GetType() UrlImageSourceType { + return s.Type +} + // GetURL returns the value of URL. func (s *UrlImageSource) GetURL() string { return s.URL } +// SetType sets the value of Type. +func (s *UrlImageSource) SetType(val UrlImageSourceType) { + s.Type = val +} + // SetURL sets the value of URL. func (s *UrlImageSource) SetURL(val string) { s.URL = val } + +type UrlImageSourceType string + +const ( + UrlImageSourceTypeURL UrlImageSourceType = "url" +) + +// AllValues returns all UrlImageSourceType values. +func (UrlImageSourceType) AllValues() []UrlImageSourceType { + return []UrlImageSourceType{ + UrlImageSourceTypeURL, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s UrlImageSourceType) MarshalText() ([]byte, error) { + switch s { + case UrlImageSourceTypeURL: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *UrlImageSourceType) UnmarshalText(data []byte) error { + switch UrlImageSourceType(data) { + case UrlImageSourceTypeURL: + *s = UrlImageSourceTypeURL + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// 通过 URL 引用的视频。. +// Ref: #/components/schemas/UrlVideoSource +type UrlVideoSource struct { + Type UrlVideoSourceType `json:"type"` + // 视频 URL。. + URL string `json:"url"` + // 视频抽帧帧率;省略时由下游模型默认策略决定。. + Fps OptFloat64 `json:"fps"` +} + +// GetType returns the value of Type. +func (s *UrlVideoSource) GetType() UrlVideoSourceType { + return s.Type +} + +// GetURL returns the value of URL. +func (s *UrlVideoSource) GetURL() string { + return s.URL +} + +// GetFps returns the value of Fps. +func (s *UrlVideoSource) GetFps() OptFloat64 { + return s.Fps +} + +// SetType sets the value of Type. +func (s *UrlVideoSource) SetType(val UrlVideoSourceType) { + s.Type = val +} + +// SetURL sets the value of URL. +func (s *UrlVideoSource) SetURL(val string) { + s.URL = val +} + +// SetFps sets the value of Fps. +func (s *UrlVideoSource) SetFps(val OptFloat64) { + s.Fps = val +} + +type UrlVideoSourceType string + +const ( + UrlVideoSourceTypeURL UrlVideoSourceType = "url" +) + +// AllValues returns all UrlVideoSourceType values. +func (UrlVideoSourceType) AllValues() []UrlVideoSourceType { + return []UrlVideoSourceType{ + UrlVideoSourceTypeURL, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s UrlVideoSourceType) MarshalText() ([]byte, error) { + switch s { + case UrlVideoSourceTypeURL: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *UrlVideoSourceType) UnmarshalText(data []byte) error { + switch UrlVideoSourceType(data) { + case UrlVideoSourceTypeURL: + *s = UrlVideoSourceTypeURL + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// 视频来源 tagged union:`base64` / `url` / `file`。. +// Ref: #/components/schemas/VideoSource +type VideoSource struct { + OneOf VideoSourceSum +} + +// GetOneOf returns the value of OneOf. +func (s *VideoSource) GetOneOf() VideoSourceSum { + return s.OneOf +} + +// SetOneOf sets the value of OneOf. +func (s *VideoSource) SetOneOf(val VideoSourceSum) { + s.OneOf = val +} + +// VideoSourceSum represents sum type. +type VideoSourceSum struct { + Type VideoSourceSumType // switch on this field + Base64VideoSource Base64VideoSource + UrlVideoSource UrlVideoSource + FileVideoSource FileVideoSource +} + +// VideoSourceSumType is oneOf type of VideoSourceSum. +type VideoSourceSumType string + +// Possible values for VideoSourceSumType. +const ( + Base64VideoSourceVideoSourceSum VideoSourceSumType = "base64" + UrlVideoSourceVideoSourceSum VideoSourceSumType = "url" + FileVideoSourceVideoSourceSum VideoSourceSumType = "file" +) + +// IsBase64VideoSource reports whether VideoSourceSum is Base64VideoSource. +func (s VideoSourceSum) IsBase64VideoSource() bool { return s.Type == Base64VideoSourceVideoSourceSum } + +// IsUrlVideoSource reports whether VideoSourceSum is UrlVideoSource. +func (s VideoSourceSum) IsUrlVideoSource() bool { return s.Type == UrlVideoSourceVideoSourceSum } + +// IsFileVideoSource reports whether VideoSourceSum is FileVideoSource. +func (s VideoSourceSum) IsFileVideoSource() bool { return s.Type == FileVideoSourceVideoSourceSum } + +// SetBase64VideoSource sets VideoSourceSum to Base64VideoSource. +func (s *VideoSourceSum) SetBase64VideoSource(v Base64VideoSource) { + s.Type = Base64VideoSourceVideoSourceSum + s.Base64VideoSource = v +} + +// GetBase64VideoSource returns Base64VideoSource and true boolean if VideoSourceSum is Base64VideoSource. +func (s VideoSourceSum) GetBase64VideoSource() (v Base64VideoSource, ok bool) { + if !s.IsBase64VideoSource() { + return v, false + } + return s.Base64VideoSource, true +} + +// NewBase64VideoSourceVideoSourceSum returns new VideoSourceSum from Base64VideoSource. +func NewBase64VideoSourceVideoSourceSum(v Base64VideoSource) VideoSourceSum { + var s VideoSourceSum + s.SetBase64VideoSource(v) + return s +} + +// SetUrlVideoSource sets VideoSourceSum to UrlVideoSource. +func (s *VideoSourceSum) SetUrlVideoSource(v UrlVideoSource) { + s.Type = UrlVideoSourceVideoSourceSum + s.UrlVideoSource = v +} + +// GetUrlVideoSource returns UrlVideoSource and true boolean if VideoSourceSum is UrlVideoSource. +func (s VideoSourceSum) GetUrlVideoSource() (v UrlVideoSource, ok bool) { + if !s.IsUrlVideoSource() { + return v, false + } + return s.UrlVideoSource, true +} + +// NewUrlVideoSourceVideoSourceSum returns new VideoSourceSum from UrlVideoSource. +func NewUrlVideoSourceVideoSourceSum(v UrlVideoSource) VideoSourceSum { + var s VideoSourceSum + s.SetUrlVideoSource(v) + return s +} + +// SetFileVideoSource sets VideoSourceSum to FileVideoSource. +func (s *VideoSourceSum) SetFileVideoSource(v FileVideoSource) { + s.Type = FileVideoSourceVideoSourceSum + s.FileVideoSource = v +} + +// GetFileVideoSource returns FileVideoSource and true boolean if VideoSourceSum is FileVideoSource. +func (s VideoSourceSum) GetFileVideoSource() (v FileVideoSource, ok bool) { + if !s.IsFileVideoSource() { + return v, false + } + return s.FileVideoSource, true +} + +// NewFileVideoSourceVideoSourceSum returns new VideoSourceSum from FileVideoSource. +func NewFileVideoSourceVideoSourceSum(v FileVideoSource) VideoSourceSum { + var s VideoSourceSum + s.SetFileVideoSource(v) + return s +} diff --git a/arkruntime/model/session/oas_validators_gen.go b/arkruntime/model/session/oas_validators_gen.go index a2efbd7..b75aa67 100644 --- a/arkruntime/model/session/oas_validators_gen.go +++ b/arkruntime/model/session/oas_validators_gen.go @@ -88,6 +88,120 @@ func (s AgentWithUpgradesType) Validate() error { } } +func (s *Base64DocumentSource) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s Base64DocumentSourceType) Validate() error { + switch s { + case "base64": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *Base64ImageSource) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s Base64ImageSourceType) Validate() error { + switch s { + case "base64": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *Base64VideoSource) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Fps.Get(); ok { + if err := func() error { + if err := (validate.Float{}).Validate(float64(value)); err != nil { + return errors.Wrap(err, "float") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "fps", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s Base64VideoSourceType) Validate() error { + switch s { + case "base64": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + func (s *CheckpointComponent) Validate() error { if s == nil { return validate.ErrNilPointer @@ -404,6 +518,56 @@ func (s *DeleteSessionCheckpointResponse) Validate() error { return nil } +func (s *DocumentSource) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.OneOf.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "OneOf", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s DocumentSourceSum) Validate() error { + switch s.Type { + case Base64DocumentSourceDocumentSourceSum: + if err := s.Base64DocumentSource.Validate(); err != nil { + return err + } + return nil + case PlainTextDocumentSourceDocumentSourceSum: + if err := s.PlainTextDocumentSource.Validate(); err != nil { + return err + } + return nil + case UrlDocumentSourceDocumentSourceSum: + if err := s.UrlDocumentSource.Validate(); err != nil { + return err + } + return nil + case FileDocumentSourceDocumentSourceSum: + if err := s.FileDocumentSource.Validate(); err != nil { + return err + } + return nil + default: + return errors.Errorf("invalid type %q", s.Type) + } +} + func (s *EnvironmentConfigOverride) Validate() error { if s == nil { return validate.ErrNilPointer @@ -573,20 +737,20 @@ func (s EnvironmentWithUpgradesType) Validate() error { } } -func (s *GetSessionCheckpointResponse) Validate() error { +func (s *FileDocumentSource) Validate() error { if s == nil { return validate.ErrNilPointer } var failures []validate.FieldError if err := func() error { - if err := s.Checkpoint.Validate(); err != nil { + if err := s.Type.Validate(); err != nil { return err } return nil }(); err != nil { failures = append(failures, validate.FieldError{ - Name: "checkpoint", + Name: "type", Error: err, }) } @@ -596,37 +760,29 @@ func (s *GetSessionCheckpointResponse) Validate() error { return nil } -func (s *ListSessionCheckpointsResponse) Validate() error { +func (s FileDocumentSourceType) Validate() error { + switch s { + case "file": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *FileImageSource) Validate() error { if s == nil { return validate.ErrNilPointer } var failures []validate.FieldError if err := func() error { - if s.Data == nil { - return errors.New("nil is invalid value") - } - var failures []validate.FieldError - for i, elem := range s.Data { - if err := func() error { - if err := elem.Validate(); err != nil { - return err - } - return nil - }(); err != nil { - failures = append(failures, validate.FieldError{ - Name: fmt.Sprintf("[%d]", i), - Error: err, - }) - } - } - if len(failures) > 0 { - return &validate.Error{Fields: failures} + if err := s.Type.Validate(); err != nil { + return err } return nil }(); err != nil { failures = append(failures, validate.FieldError{ - Name: "data", + Name: "type", Error: err, }) } @@ -636,60 +792,47 @@ func (s *ListSessionCheckpointsResponse) Validate() error { return nil } -func (s *ListSessionEventsResponseWire) Validate() error { +func (s FileImageSourceType) Validate() error { + switch s { + case "file": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *FileVideoSource) Validate() error { if s == nil { return validate.ErrNilPointer } var failures []validate.FieldError if err := func() error { - if s.Data == nil { - return errors.New("nil is invalid value") + if err := s.Type.Validate(); err != nil { + return err } return nil }(); err != nil { failures = append(failures, validate.FieldError{ - Name: "data", + Name: "type", Error: err, }) } - if len(failures) > 0 { - return &validate.Error{Fields: failures} - } - return nil -} - -func (s *ListSessionResourcesResponse) Validate() error { - if s == nil { - return validate.ErrNilPointer - } - - var failures []validate.FieldError if err := func() error { - if s.Data == nil { - return errors.New("nil is invalid value") - } - var failures []validate.FieldError - for i, elem := range s.Data { + if value, ok := s.Fps.Get(); ok { if err := func() error { - if err := elem.Validate(); err != nil { - return err + if err := (validate.Float{}).Validate(float64(value)); err != nil { + return errors.Wrap(err, "float") } return nil }(); err != nil { - failures = append(failures, validate.FieldError{ - Name: fmt.Sprintf("[%d]", i), - Error: err, - }) + return err } } - if len(failures) > 0 { - return &validate.Error{Fields: failures} - } return nil }(); err != nil { failures = append(failures, validate.FieldError{ - Name: "data", + Name: "fps", Error: err, }) } @@ -699,37 +842,29 @@ func (s *ListSessionResourcesResponse) Validate() error { return nil } -func (s *ListSessionThreadsResponse) Validate() error { +func (s FileVideoSourceType) Validate() error { + switch s { + case "file": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *GetSessionCheckpointResponse) Validate() error { if s == nil { return validate.ErrNilPointer } var failures []validate.FieldError if err := func() error { - if s.Data == nil { - return errors.New("nil is invalid value") - } - var failures []validate.FieldError - for i, elem := range s.Data { - if err := func() error { - if err := elem.Validate(); err != nil { - return err - } - return nil - }(); err != nil { - failures = append(failures, validate.FieldError{ - Name: fmt.Sprintf("[%d]", i), - Error: err, - }) - } - } - if len(failures) > 0 { - return &validate.Error{Fields: failures} + if err := s.Checkpoint.Validate(); err != nil { + return err } return nil }(); err != nil { failures = append(failures, validate.FieldError{ - Name: "data", + Name: "checkpoint", Error: err, }) } @@ -739,8 +874,196 @@ func (s *ListSessionThreadsResponse) Validate() error { return nil } -func (s ListSessionsOrder) Validate() error { - switch s { +func (s *ImageSource) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.OneOf.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "OneOf", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ImageSourceSum) Validate() error { + switch s.Type { + case Base64ImageSourceImageSourceSum: + if err := s.Base64ImageSource.Validate(); err != nil { + return err + } + return nil + case UrlImageSourceImageSourceSum: + if err := s.UrlImageSource.Validate(); err != nil { + return err + } + return nil + case FileImageSourceImageSourceSum: + if err := s.FileImageSource.Validate(); err != nil { + return err + } + return nil + default: + return errors.Errorf("invalid type %q", s.Type) + } +} + +func (s *ListSessionCheckpointsResponse) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if s.Data == nil { + return errors.New("nil is invalid value") + } + var failures []validate.FieldError + for i, elem := range s.Data { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "data", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *ListSessionEventsResponseWire) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if s.Data == nil { + return errors.New("nil is invalid value") + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "data", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *ListSessionResourcesResponse) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if s.Data == nil { + return errors.New("nil is invalid value") + } + var failures []validate.FieldError + for i, elem := range s.Data { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "data", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *ListSessionThreadsResponse) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if s.Data == nil { + return errors.New("nil is invalid value") + } + var failures []validate.FieldError + for i, elem := range s.Data { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "data", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ListSessionsOrder) Validate() error { + switch s { case "asc": return nil case "desc": @@ -790,6 +1113,49 @@ func (s *ListSessionsResponse) Validate() error { return nil } +func (s *ManagedAgentsDocumentBlock) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if err := func() error { + if err := s.Source.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "source", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ManagedAgentsDocumentBlockType) Validate() error { + switch s { + case "document": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + func (s *ManagedAgentsEventParams) Validate() error { if s == nil { return validate.ErrNilPointer @@ -816,9 +1182,15 @@ func (s *ManagedAgentsEventParams) Validate() error { func (s ManagedAgentsEventParamsSum) Validate() error { switch s.Type { case ManagedAgentsUserMessageEventParamsManagedAgentsEventParamsSum: - return nil // no validation needed + if err := s.ManagedAgentsUserMessageEventParams.Validate(); err != nil { + return err + } + return nil case ManagedAgentsSystemMessageEventParamsManagedAgentsEventParamsSum: - return nil // no validation needed + if err := s.ManagedAgentsSystemMessageEventParams.Validate(); err != nil { + return err + } + return nil case ManagedAgentsUserInterruptEventParamsManagedAgentsEventParamsSum: return nil // no validation needed case ManagedAgentsUserToolConfirmationEventParamsManagedAgentsEventParamsSum: @@ -843,16 +1215,218 @@ func (s ManagedAgentsEventParamsSum) Validate() error { } } +func (s *ManagedAgentsImageBlock) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if err := func() error { + if err := s.Source.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "source", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ManagedAgentsImageBlockType) Validate() error { + switch s { + case "image": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *ManagedAgentsMessageContentBlock) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.OneOf.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "OneOf", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ManagedAgentsMessageContentBlockSum) Validate() error { + switch s.Type { + case ManagedAgentsTextBlockManagedAgentsMessageContentBlockSum: + if err := s.ManagedAgentsTextBlock.Validate(); err != nil { + return err + } + return nil + case ManagedAgentsImageBlockManagedAgentsMessageContentBlockSum: + if err := s.ManagedAgentsImageBlock.Validate(); err != nil { + return err + } + return nil + case ManagedAgentsDocumentBlockManagedAgentsMessageContentBlockSum: + if err := s.ManagedAgentsDocumentBlock.Validate(); err != nil { + return err + } + return nil + case ManagedAgentsVideoBlockManagedAgentsMessageContentBlockSum: + if err := s.ManagedAgentsVideoBlock.Validate(); err != nil { + return err + } + return nil + default: + return errors.Errorf("invalid type %q", s.Type) + } +} + func (s *ManagedAgentsSearchResultBlock) Validate() error { if s == nil { return validate.ErrNilPointer } var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } if err := func() error { if s.Content == nil { return errors.New("nil is invalid value") } + var failures []validate.FieldError + for i, elem := range s.Content { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "content", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ManagedAgentsSearchResultBlockType) Validate() error { + switch s { + case "search_result": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *ManagedAgentsSystemContentBlock) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.OneOf.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "OneOf", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ManagedAgentsSystemContentBlockSum) Validate() error { + switch s.Type { + case ManagedAgentsTextBlockManagedAgentsSystemContentBlockSum: + if err := s.ManagedAgentsTextBlock.Validate(); err != nil { + return err + } + return nil + default: + return errors.Errorf("invalid type %q", s.Type) + } +} + +func (s *ManagedAgentsSystemMessageEventParams) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + var failures []validate.FieldError + for i, elem := range s.Content { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } return nil }(); err != nil { failures = append(failures, validate.FieldError{ @@ -866,6 +1440,38 @@ func (s *ManagedAgentsSearchResultBlock) Validate() error { return nil } +func (s *ManagedAgentsTextBlock) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ManagedAgentsTextBlockType) Validate() error { + switch s { + case "text": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + func (s *ManagedAgentsToolResultContentBlock) Validate() error { if s == nil { return validate.ErrNilPointer @@ -879,7 +1485,76 @@ func (s *ManagedAgentsToolResultContentBlock) Validate() error { return nil }(); err != nil { failures = append(failures, validate.FieldError{ - Name: "OneOf", + Name: "OneOf", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ManagedAgentsToolResultContentBlockSum) Validate() error { + switch s.Type { + case ManagedAgentsTextBlockManagedAgentsToolResultContentBlockSum: + if err := s.ManagedAgentsTextBlock.Validate(); err != nil { + return err + } + return nil + case ManagedAgentsImageBlockManagedAgentsToolResultContentBlockSum: + if err := s.ManagedAgentsImageBlock.Validate(); err != nil { + return err + } + return nil + case ManagedAgentsDocumentBlockManagedAgentsToolResultContentBlockSum: + if err := s.ManagedAgentsDocumentBlock.Validate(); err != nil { + return err + } + return nil + case ManagedAgentsSearchResultBlockManagedAgentsToolResultContentBlockSum: + if err := s.ManagedAgentsSearchResultBlock.Validate(); err != nil { + return err + } + return nil + case ManagedAgentsVideoBlockManagedAgentsToolResultContentBlockSum: + if err := s.ManagedAgentsVideoBlock.Validate(); err != nil { + return err + } + return nil + default: + return errors.Errorf("invalid type %q", s.Type) + } +} + +func (s *ManagedAgentsUserCustomToolResultEventParams) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + var failures []validate.FieldError + for i, elem := range s.Content { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "content", Error: err, }) } @@ -889,25 +1564,7 @@ func (s *ManagedAgentsToolResultContentBlock) Validate() error { return nil } -func (s ManagedAgentsToolResultContentBlockSum) Validate() error { - switch s.Type { - case ManagedAgentsTextBlockManagedAgentsToolResultContentBlockSum: - return nil // no validation needed - case ManagedAgentsImageBlockManagedAgentsToolResultContentBlockSum: - return nil // no validation needed - case ManagedAgentsDocumentBlockManagedAgentsToolResultContentBlockSum: - return nil // no validation needed - case ManagedAgentsSearchResultBlockManagedAgentsToolResultContentBlockSum: - if err := s.ManagedAgentsSearchResultBlock.Validate(); err != nil { - return err - } - return nil - default: - return errors.Errorf("invalid type %q", s.Type) - } -} - -func (s *ManagedAgentsUserCustomToolResultEventParams) Validate() error { +func (s *ManagedAgentsUserMessageEventParams) Validate() error { if s == nil { return validate.ErrNilPointer } @@ -1004,6 +1661,49 @@ func (s *ManagedAgentsUserToolResultEventParams) Validate() error { return nil } +func (s *ManagedAgentsVideoBlock) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if err := func() error { + if err := s.Source.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "source", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ManagedAgentsVideoBlockType) Validate() error { + switch s { + case "video": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + func (s *ModelOverrides) Validate() error { if s == nil { return validate.ErrNilPointer @@ -1109,6 +1809,70 @@ func (s *OverrideTokenLimits) Validate() error { return nil } +func (s *PlainTextDocumentSource) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s PlainTextDocumentSourceType) Validate() error { + switch s { + case "text": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *SearchResultContent) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s SearchResultContentType) Validate() error { + switch s { + case "text": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + func (s *SendSessionEventsRequest) Validate() error { if s == nil { return validate.ErrNilPointer @@ -1506,3 +2270,162 @@ func (s ToolConfirmationResult) Validate() error { return errors.Errorf("invalid value: %v", s) } } + +func (s *UrlDocumentSource) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s UrlDocumentSourceType) Validate() error { + switch s { + case "url": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *UrlImageSource) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s UrlImageSourceType) Validate() error { + switch s { + case "url": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *UrlVideoSource) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Fps.Get(); ok { + if err := func() error { + if err := (validate.Float{}).Validate(float64(value)); err != nil { + return errors.Wrap(err, "float") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "fps", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s UrlVideoSourceType) Validate() error { + switch s { + case "url": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *VideoSource) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.OneOf.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "OneOf", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s VideoSourceSum) Validate() error { + switch s.Type { + case Base64VideoSourceVideoSourceSum: + if err := s.Base64VideoSource.Validate(); err != nil { + return err + } + return nil + case UrlVideoSourceVideoSourceSum: + if err := s.UrlVideoSource.Validate(); err != nil { + return err + } + return nil + case FileVideoSourceVideoSourceSum: + if err := s.FileVideoSource.Validate(); err != nil { + return err + } + return nil + default: + return errors.Errorf("invalid type %q", s.Type) + } +} diff --git a/arkruntime/model/systemone/oas_cfg_gen.go b/arkruntime/model/systemone/oas_cfg_gen.go new file mode 100644 index 0000000..c50c5f8 --- /dev/null +++ b/arkruntime/model/systemone/oas_cfg_gen.go @@ -0,0 +1,14 @@ +// Copyright (c) 2026 ByteDance Ltd. and/or its affiliates. +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by ogen, DO NOT EDIT. + +package systemone + +import ( + "github.com/volcengine/ark-runtime-go/arkruntime/internal/ogenregex" +) + +var regexMap = map[string]ogenregex.Regexp{ + "\\S": ogenregex.MustCompile("\\S"), +} diff --git a/arkruntime/model/systemone/oas_interfaces_gen.go b/arkruntime/model/systemone/oas_interfaces_gen.go new file mode 100644 index 0000000..5c768ec --- /dev/null +++ b/arkruntime/model/systemone/oas_interfaces_gen.go @@ -0,0 +1,9 @@ +// Copyright (c) 2026 ByteDance Ltd. and/or its affiliates. +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by ogen, DO NOT EDIT. +package systemone + +type SystemOneEvaluateRes interface { + systemOneEvaluateRes() +} diff --git a/arkruntime/model/systemone/oas_json_gen.go b/arkruntime/model/systemone/oas_json_gen.go new file mode 100644 index 0000000..ca718d0 --- /dev/null +++ b/arkruntime/model/systemone/oas_json_gen.go @@ -0,0 +1,3471 @@ +// Copyright (c) 2026 ByteDance Ltd. and/or its affiliates. +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by ogen, DO NOT EDIT. + +package systemone + +import ( + "math/bits" + "strconv" + "strings" + + "github.com/go-faster/errors" + "github.com/go-faster/jx" + "github.com/volcengine/ark-runtime-go/arkruntime/internal/validate" +) + +// Encode implements json.Marshaler. +func (s *Answer) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *Answer) encodeFields(e *jx.Encoder) { + s.OneOf.encodeFields(e) +} + +var jsonFieldsNameOfAnswer = [0]string{} + +// Decode decodes Answer from json. +func (s *Answer) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Answer to nil") + } + if err := d.Capture(func(d *jx.Decoder) error { + return s.OneOf.Decode(d) + }); err != nil { + return errors.Wrap(err, "decode field OneOf") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + default: + return d.Skip() + } + }); err != nil { + return errors.Wrap(err, "decode Answer") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *Answer) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *Answer) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes AnswerSum as json. +func (s AnswerSum) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +func (s AnswerSum) encodeFields(e *jx.Encoder) { + if s.Type == "" && s.unknownType != "" { + // Decode validated this private object. Replay its fields, including + // when called by an enclosing object with an inline union. + raw := strings.TrimSpace(s.unknownJSON) + e.RawStr(raw[1 : len(raw)-1]) + return + } + switch s.Type { + case NoulAnswerAnswerSum: + e.FieldStart("type") + e.Str("noul") + { + s := s.NoulAnswer + { + e.FieldStart("noul") + s.Noul.Encode(e) + } + } + case ChoiceAnswerAnswerSum: + e.FieldStart("type") + e.Str("choice") + { + s := s.ChoiceAnswer + { + e.FieldStart("choice") + e.Str(s.Choice) + } + { + e.FieldStart("probabilities") + s.Probabilities.Encode(e) + } + { + e.FieldStart("confidence") + s.Confidence.Encode(e) + } + } + case ScoreAnswerAnswerSum: + e.FieldStart("type") + e.Str("score") + { + s := s.ScoreAnswer + { + e.FieldStart("score") + s.Score.Encode(e) + } + { + e.FieldStart("legend") + s.Legend.Encode(e) + } + { + e.FieldStart("probabilities") + s.Probabilities.Encode(e) + } + { + e.FieldStart("confidence") + s.Confidence.Encode(e) + } + } + } +} + +// Decode decodes AnswerSum from json. +func (s *AnswerSum) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode AnswerSum to nil") + } + // Sum type discriminator. + if typ := d.Next(); typ != jx.Object { + return errors.Errorf("unexpected json type %q", typ) + } + // Buffer one complete value before peeking. Capture must not rewind a + // reader-backed decoder after its input buffer has been refilled. + raw, err := d.Raw() + if err != nil { + return err + } + d = jx.DecodeBytes(raw) + s.unknownType = "" + s.unknownJSON = "" + var unknownType string + + var found bool + if err := d.Capture(func(d *jx.Decoder) error { + return d.ObjBytes(func(d *jx.Decoder, key []byte) error { + if found { + return d.Skip() + } + switch string(key) { + case "type": + typ, err := d.Str() + if err != nil { + return err + } + switch typ { + case "noul": + s.Type = NoulAnswerAnswerSum + found = true + case "choice": + s.Type = ChoiceAnswerAnswerSum + found = true + case "score": + s.Type = ScoreAnswerAnswerSum + found = true + default: + if typ == "" { + return errors.New("empty sum type discriminator") + } + unknownType = typ + found = true + } + return nil + } + return d.Skip() + }) + }); err != nil { + return errors.Wrap(err, "capture") + } + if unknownType != "" { + // Copy bytes: decoder buffers can be reused after this call. + // Reset known members so a reused object cannot expose stale data. + *s = AnswerSum{unknownType: unknownType, unknownJSON: string(raw)} + return nil + } + if !found { + return errors.New("unable to detect sum type variant") + } + switch s.Type { + case NoulAnswerAnswerSum: + if err := s.NoulAnswer.Decode(d); err != nil { + return err + } + case ChoiceAnswerAnswerSum: + if err := s.ChoiceAnswer.Decode(d); err != nil { + return err + } + case ScoreAnswerAnswerSum: + if err := s.ScoreAnswer.Decode(d); err != nil { + return err + } + default: + return errors.Errorf("inferred invalid type: %s", s.Type) + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s AnswerSum) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *AnswerSum) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ChoiceAnswer) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ChoiceAnswer) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } + { + e.FieldStart("choice") + e.Str(s.Choice) + } + { + e.FieldStart("probabilities") + s.Probabilities.Encode(e) + } + { + e.FieldStart("confidence") + s.Confidence.Encode(e) + } +} + +var jsonFieldsNameOfChoiceAnswer = [4]string{ + 0: "type", + 1: "choice", + 2: "probabilities", + 3: "confidence", +} + +// Decode decodes ChoiceAnswer from json. +func (s *ChoiceAnswer) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ChoiceAnswer to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "type": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "choice": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.Choice = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"choice\"") + } + case "probabilities": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Probabilities.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"probabilities\"") + } + case "confidence": + requiredBitSet[0] |= 1 << 3 + if err := func() error { + if err := s.Confidence.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"confidence\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ChoiceAnswer") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00001111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfChoiceAnswer) { + name = jsonFieldsNameOfChoiceAnswer[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ChoiceAnswer) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ChoiceAnswer) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s ChoiceAnswerProbabilities) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields implements json.Marshaler. +func (s ChoiceAnswerProbabilities) encodeFields(e *jx.Encoder) { + for k, elem := range s { + e.FieldStart(k) + + elem.Encode(e) + } +} + +// Decode decodes ChoiceAnswerProbabilities from json. +func (s *ChoiceAnswerProbabilities) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ChoiceAnswerProbabilities to nil") + } + m := s.init() + var propertiesCount int + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + propertiesCount++ + var elem Probability + if err := func() error { + if err := elem.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrapf(err, "decode field %q", k) + } + m[string(k)] = elem + return nil + }); err != nil { + return errors.Wrap(err, "decode ChoiceAnswerProbabilities") + } + // Validate properties count. + if err := (validate.Object{ + MinProperties: 1, + MinPropertiesSet: true, + MaxProperties: 0, + MaxPropertiesSet: false, + }).ValidateProperties(propertiesCount); err != nil { + return errors.Wrap(err, "object") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ChoiceAnswerProbabilities) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ChoiceAnswerProbabilities) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ChoiceAnswerType as json. +func (s ChoiceAnswerType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes ChoiceAnswerType from json. +func (s *ChoiceAnswerType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ChoiceAnswerType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch ChoiceAnswerType(v) { + case ChoiceAnswerTypeChoice: + *s = ChoiceAnswerTypeChoice + default: + *s = ChoiceAnswerType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ChoiceAnswerType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ChoiceAnswerType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s ChoiceCriteria) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields implements json.Marshaler. +func (s ChoiceCriteria) encodeFields(e *jx.Encoder) { + for k, elem := range s { + e.FieldStart(k) + + elem.Encode(e) + } +} + +// Decode decodes ChoiceCriteria from json. +func (s *ChoiceCriteria) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ChoiceCriteria to nil") + } + m := s.init() + var propertiesCount int + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + propertiesCount++ + var elem ChoiceDescription + if err := func() error { + if err := elem.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrapf(err, "decode field %q", k) + } + m[string(k)] = elem + return nil + }); err != nil { + return errors.Wrap(err, "decode ChoiceCriteria") + } + // Validate properties count. + if err := (validate.Object{ + MinProperties: 1, + MinPropertiesSet: true, + MaxProperties: 255, + MaxPropertiesSet: true, + }).ValidateProperties(propertiesCount); err != nil { + return errors.Wrap(err, "object") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ChoiceCriteria) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ChoiceCriteria) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ChoiceDescription as json. +func (s ChoiceDescription) Encode(e *jx.Encoder) { + switch s.Type { + case StringChoiceDescription: + e.Str(s.String) + case JSONObjectChoiceDescription: + s.JSONObject.Encode(e) + case AnyArrayChoiceDescription: + e.ArrStart() + for _, elem := range s.AnyArray { + if len(elem) != 0 { + e.Raw(elem) + } + } + e.ArrEnd() + case NullChoiceDescription: + _ = s.Null + e.Null() + } +} + +// Decode decodes ChoiceDescription from json. +func (s *ChoiceDescription) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ChoiceDescription to nil") + } + // Sum type type_discriminator. + switch t := d.Next(); t { + case jx.Array: + s.AnyArray = make([]jx.Raw, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem jx.Raw + v, err := d.RawAppend(nil) + elem = jx.Raw(v) + if err != nil { + return err + } + s.AnyArray = append(s.AnyArray, elem) + return nil + }); err != nil { + return err + } + s.Type = AnyArrayChoiceDescription + case jx.Null: + if err := d.Null(); err != nil { + return err + } + s.Type = NullChoiceDescription + case jx.Object: + if err := s.JSONObject.Decode(d); err != nil { + return err + } + s.Type = JSONObjectChoiceDescription + case jx.String: + v, err := d.Str() + s.String = string(v) + if err != nil { + return err + } + s.Type = StringChoiceDescription + default: + return errors.Errorf("unexpected json type %q", t) + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ChoiceDescription) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ChoiceDescription) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ChoiceQuestion) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ChoiceQuestion) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } + { + if s.Instructions.Set { + e.FieldStart("instructions") + s.Instructions.Encode(e) + } + } + { + e.FieldStart("criteria") + s.Criteria.Encode(e) + } +} + +var jsonFieldsNameOfChoiceQuestion = [3]string{ + 0: "type", + 1: "instructions", + 2: "criteria", +} + +// Decode decodes ChoiceQuestion from json. +func (s *ChoiceQuestion) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ChoiceQuestion to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "type": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "instructions": + if err := func() error { + s.Instructions.Reset() + if err := s.Instructions.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"instructions\"") + } + case "criteria": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Criteria.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"criteria\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ChoiceQuestion") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000101, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfChoiceQuestion) { + name = jsonFieldsNameOfChoiceQuestion[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ChoiceQuestion) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ChoiceQuestion) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ChoiceQuestionType as json. +func (s ChoiceQuestionType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes ChoiceQuestionType from json. +func (s *ChoiceQuestionType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ChoiceQuestionType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch ChoiceQuestionType(v) { + case ChoiceQuestionTypeChoice: + *s = ChoiceQuestionTypeChoice + default: + *s = ChoiceQuestionType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ChoiceQuestionType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ChoiceQuestionType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ErrorDetail) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ErrorDetail) encodeFields(e *jx.Encoder) { + { + e.FieldStart("code") + e.Str(s.Code) + } + { + e.FieldStart("message") + e.Str(s.Message) + } + { + e.FieldStart("param") + e.Str(s.Param) + } + { + e.FieldStart("type") + e.Str(s.Type) + } +} + +var jsonFieldsNameOfErrorDetail = [4]string{ + 0: "code", + 1: "message", + 2: "param", + 3: "type", +} + +// Decode decodes ErrorDetail from json. +func (s *ErrorDetail) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ErrorDetail to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "code": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Str() + s.Code = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"code\"") + } + case "message": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.Message = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"message\"") + } + case "param": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + v, err := d.Str() + s.Param = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"param\"") + } + case "type": + requiredBitSet[0] |= 1 << 3 + if err := func() error { + v, err := d.Str() + s.Type = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ErrorDetail") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00001111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfErrorDetail) { + name = jsonFieldsNameOfErrorDetail[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ErrorDetail) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ErrorDetail) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ErrorResponse) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ErrorResponse) encodeFields(e *jx.Encoder) { + { + e.FieldStart("error") + s.Error.Encode(e) + } +} + +var jsonFieldsNameOfErrorResponse = [1]string{ + 0: "error", +} + +// Decode decodes ErrorResponse from json. +func (s *ErrorResponse) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ErrorResponse to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "error": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Error.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"error\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ErrorResponse") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000001, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfErrorResponse) { + name = jsonFieldsNameOfErrorResponse[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ErrorResponse) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ErrorResponse) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ForbiddenResponse) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ForbiddenResponse) encodeFields(e *jx.Encoder) { + { + if s.Error.Set { + e.FieldStart("error") + s.Error.Encode(e) + } + } + { + if s.ErrorCode.Set { + e.FieldStart("error_code") + s.ErrorCode.Encode(e) + } + } + { + if s.ErrorMsg.Set { + e.FieldStart("error_msg") + s.ErrorMsg.Encode(e) + } + } +} + +var jsonFieldsNameOfForbiddenResponse = [3]string{ + 0: "error", + 1: "error_code", + 2: "error_msg", +} + +// Decode decodes ForbiddenResponse from json. +func (s *ForbiddenResponse) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ForbiddenResponse to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "error": + if err := func() error { + s.Error.Reset() + if err := s.Error.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"error\"") + } + case "error_code": + if err := func() error { + s.ErrorCode.Reset() + if err := s.ErrorCode.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"error_code\"") + } + case "error_msg": + if err := func() error { + s.ErrorMsg.Reset() + if err := s.ErrorMsg.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"error_msg\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ForbiddenResponse") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ForbiddenResponse) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ForbiddenResponse) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes Instructions as json. +func (s Instructions) Encode(e *jx.Encoder) { + switch s.Type { + case StringInstructions: + e.Str(s.String) + case JSONObjectInstructions: + s.JSONObject.Encode(e) + case AnyArrayInstructions: + e.ArrStart() + for _, elem := range s.AnyArray { + if len(elem) != 0 { + e.Raw(elem) + } + } + e.ArrEnd() + } +} + +// Decode decodes Instructions from json. +func (s *Instructions) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Instructions to nil") + } + // Sum type type_discriminator. + switch t := d.Next(); t { + case jx.Array: + s.AnyArray = make([]jx.Raw, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem jx.Raw + v, err := d.RawAppend(nil) + elem = jx.Raw(v) + if err != nil { + return err + } + s.AnyArray = append(s.AnyArray, elem) + return nil + }); err != nil { + return err + } + s.Type = AnyArrayInstructions + case jx.Object: + if err := s.JSONObject.Decode(d); err != nil { + return err + } + s.Type = JSONObjectInstructions + case jx.String: + v, err := d.Str() + s.String = string(v) + if err != nil { + return err + } + s.Type = StringInstructions + default: + return errors.Errorf("unexpected json type %q", t) + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s Instructions) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *Instructions) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s JSONObject) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields implements json.Marshaler. +func (s JSONObject) encodeFields(e *jx.Encoder) { + for k, elem := range s { + e.FieldStart(k) + + if len(elem) != 0 { + e.Raw(elem) + } + } +} + +// Decode decodes JSONObject from json. +func (s *JSONObject) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode JSONObject to nil") + } + m := s.init() + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + var elem jx.Raw + if err := func() error { + v, err := d.RawAppend(nil) + elem = jx.Raw(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrapf(err, "decode field %q", k) + } + m[string(k)] = elem + return nil + }); err != nil { + return errors.Wrap(err, "decode JSONObject") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s JSONObject) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *JSONObject) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ModelID as json. +func (s ModelID) Encode(e *jx.Encoder) { + unwrapped := string(s) + + e.Str(unwrapped) +} + +// Decode decodes ModelID from json. +func (s *ModelID) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ModelID to nil") + } + var unwrapped string + if err := func() error { + v, err := d.Str() + unwrapped = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = ModelID(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ModelID) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ModelID) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NoulAnswer) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NoulAnswer) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } + { + e.FieldStart("noul") + s.Noul.Encode(e) + } +} + +var jsonFieldsNameOfNoulAnswer = [2]string{ + 0: "type", + 1: "noul", +} + +// Decode decodes NoulAnswer from json. +func (s *NoulAnswer) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NoulAnswer to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "type": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "noul": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Noul.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"noul\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NoulAnswer") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNoulAnswer) { + name = jsonFieldsNameOfNoulAnswer[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NoulAnswer) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NoulAnswer) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NoulAnswerType as json. +func (s NoulAnswerType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes NoulAnswerType from json. +func (s *NoulAnswerType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NoulAnswerType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch NoulAnswerType(v) { + case NoulAnswerTypeNoul: + *s = NoulAnswerTypeNoul + default: + *s = NoulAnswerType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NoulAnswerType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NoulAnswerType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NoulCriteria) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NoulCriteria) encodeFields(e *jx.Encoder) { + { + if s.True.Set { + e.FieldStart("true") + s.True.Encode(e) + } + } + { + if s.False.Set { + e.FieldStart("false") + s.False.Encode(e) + } + } + for k, elem := range s.AdditionalProps { + e.FieldStart(k) + + if len(elem) != 0 { + e.Raw(elem) + } + } +} + +var jsonFieldsNameOfNoulCriteria = [2]string{ + 0: "true", + 1: "false", +} + +// Decode decodes NoulCriteria from json. +func (s *NoulCriteria) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NoulCriteria to nil") + } + s.AdditionalProps = map[string]jx.Raw{} + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "true": + if err := func() error { + s.True.Reset() + if err := s.True.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"true\"") + } + case "false": + if err := func() error { + s.False.Reset() + if err := s.False.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"false\"") + } + default: + var elem jx.Raw + if err := func() error { + v, err := d.RawAppend(nil) + elem = jx.Raw(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrapf(err, "decode field %q", k) + } + s.AdditionalProps[string(k)] = elem + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NoulCriteria") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NoulCriteria) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NoulCriteria) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s NoulCriteriaAdditional) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields implements json.Marshaler. +func (s NoulCriteriaAdditional) encodeFields(e *jx.Encoder) { + for k, elem := range s { + e.FieldStart(k) + + if len(elem) != 0 { + e.Raw(elem) + } + } +} + +// Decode decodes NoulCriteriaAdditional from json. +func (s *NoulCriteriaAdditional) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NoulCriteriaAdditional to nil") + } + m := s.init() + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + var elem jx.Raw + if err := func() error { + v, err := d.RawAppend(nil) + elem = jx.Raw(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrapf(err, "decode field %q", k) + } + m[string(k)] = elem + return nil + }); err != nil { + return errors.Wrap(err, "decode NoulCriteriaAdditional") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NoulCriteriaAdditional) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NoulCriteriaAdditional) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *NoulQuestion) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *NoulQuestion) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } + { + if s.Instructions.Set { + e.FieldStart("instructions") + s.Instructions.Encode(e) + } + } + { + if s.Criteria.Set { + e.FieldStart("criteria") + s.Criteria.Encode(e) + } + } +} + +var jsonFieldsNameOfNoulQuestion = [3]string{ + 0: "type", + 1: "instructions", + 2: "criteria", +} + +// Decode decodes NoulQuestion from json. +func (s *NoulQuestion) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NoulQuestion to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "type": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "instructions": + if err := func() error { + s.Instructions.Reset() + if err := s.Instructions.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"instructions\"") + } + case "criteria": + if err := func() error { + s.Criteria.Reset() + if err := s.Criteria.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"criteria\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode NoulQuestion") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000001, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfNoulQuestion) { + name = jsonFieldsNameOfNoulQuestion[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *NoulQuestion) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NoulQuestion) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NoulQuestionType as json. +func (s NoulQuestionType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes NoulQuestionType from json. +func (s *NoulQuestionType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NoulQuestionType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch NoulQuestionType(v) { + case NoulQuestionTypeNoul: + *s = NoulQuestionTypeNoul + default: + *s = NoulQuestionType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NoulQuestionType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NoulQuestionType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NullableInstructions as json. +func (s NullableInstructions) Encode(e *jx.Encoder) { + switch s.Type { + case StringNullableInstructions: + e.Str(s.String) + case JSONObjectNullableInstructions: + s.JSONObject.Encode(e) + case AnyArrayNullableInstructions: + e.ArrStart() + for _, elem := range s.AnyArray { + if len(elem) != 0 { + e.Raw(elem) + } + } + e.ArrEnd() + case NullNullableInstructions: + _ = s.Null + e.Null() + } +} + +// Decode decodes NullableInstructions from json. +func (s *NullableInstructions) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode NullableInstructions to nil") + } + // Sum type type_discriminator. + switch t := d.Next(); t { + case jx.Array: + s.AnyArray = make([]jx.Raw, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem jx.Raw + v, err := d.RawAppend(nil) + elem = jx.Raw(v) + if err != nil { + return err + } + s.AnyArray = append(s.AnyArray, elem) + return nil + }); err != nil { + return err + } + s.Type = AnyArrayNullableInstructions + case jx.Null: + if err := d.Null(); err != nil { + return err + } + s.Type = NullNullableInstructions + case jx.Object: + if err := s.JSONObject.Decode(d); err != nil { + return err + } + s.Type = JSONObjectNullableInstructions + case jx.String: + v, err := d.Str() + s.String = string(v) + if err != nil { + return err + } + s.Type = StringNullableInstructions + default: + return errors.Errorf("unexpected json type %q", t) + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s NullableInstructions) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *NullableInstructions) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ErrorDetail as json. +func (o OptErrorDetail) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes ErrorDetail from json. +func (o *OptErrorDetail) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptErrorDetail to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptErrorDetail) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptErrorDetail) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NoulCriteria as json. +func (o OptNoulCriteria) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes NoulCriteria from json. +func (o *OptNoulCriteria) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptNoulCriteria to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptNoulCriteria) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptNoulCriteria) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes NullableInstructions as json. +func (o OptNullableInstructions) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes NullableInstructions from json. +func (o *OptNullableInstructions) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptNullableInstructions to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptNullableInstructions) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptNullableInstructions) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes string as json. +func (o OptString) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes string from json. +func (o *OptString) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptString to nil") + } + o.Set = true + v, err := d.Str() + if err != nil { + return err + } + o.Value = string(v) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptString) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptString) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes Probability as json. +func (s Probability) Encode(e *jx.Encoder) { + unwrapped := float64(s) + + e.Float64(unwrapped) +} + +// Decode decodes Probability from json. +func (s *Probability) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Probability to nil") + } + var unwrapped float64 + if err := func() error { + v, err := d.Float64() + unwrapped = float64(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = Probability(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s Probability) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *Probability) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *Question) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *Question) encodeFields(e *jx.Encoder) { + s.OneOf.encodeFields(e) +} + +var jsonFieldsNameOfQuestion = [0]string{} + +// Decode decodes Question from json. +func (s *Question) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Question to nil") + } + if err := d.Capture(func(d *jx.Decoder) error { + return s.OneOf.Decode(d) + }); err != nil { + return errors.Wrap(err, "decode field OneOf") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + default: + return d.Skip() + } + }); err != nil { + return errors.Wrap(err, "decode Question") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *Question) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *Question) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes QuestionSum as json. +func (s QuestionSum) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +func (s QuestionSum) encodeFields(e *jx.Encoder) { + switch s.Type { + case NoulQuestionQuestionSum: + e.FieldStart("type") + e.Str("noul") + { + s := s.NoulQuestion + { + if s.Instructions.Set { + e.FieldStart("instructions") + s.Instructions.Encode(e) + } + } + { + if s.Criteria.Set { + e.FieldStart("criteria") + s.Criteria.Encode(e) + } + } + } + case ChoiceQuestionQuestionSum: + e.FieldStart("type") + e.Str("choice") + { + s := s.ChoiceQuestion + { + if s.Instructions.Set { + e.FieldStart("instructions") + s.Instructions.Encode(e) + } + } + { + e.FieldStart("criteria") + s.Criteria.Encode(e) + } + } + case ScoreQuestionQuestionSum: + e.FieldStart("type") + e.Str("score") + { + s := s.ScoreQuestion + { + if s.Instructions.Set { + e.FieldStart("instructions") + s.Instructions.Encode(e) + } + } + { + e.FieldStart("criteria") + s.Criteria.Encode(e) + } + } + } +} + +// Decode decodes QuestionSum from json. +func (s *QuestionSum) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode QuestionSum to nil") + } + // Sum type discriminator. + if typ := d.Next(); typ != jx.Object { + return errors.Errorf("unexpected json type %q", typ) + } + + var found bool + if err := d.Capture(func(d *jx.Decoder) error { + return d.ObjBytes(func(d *jx.Decoder, key []byte) error { + if found { + return d.Skip() + } + switch string(key) { + case "type": + typ, err := d.Str() + if err != nil { + return err + } + switch typ { + case "noul": + s.Type = NoulQuestionQuestionSum + found = true + case "choice": + s.Type = ChoiceQuestionQuestionSum + found = true + case "score": + s.Type = ScoreQuestionQuestionSum + found = true + default: + return errors.Errorf("unknown type %s", typ) + } + return nil + } + return d.Skip() + }) + }); err != nil { + return errors.Wrap(err, "capture") + } + if !found { + return errors.New("unable to detect sum type variant") + } + switch s.Type { + case NoulQuestionQuestionSum: + if err := s.NoulQuestion.Decode(d); err != nil { + return err + } + case ChoiceQuestionQuestionSum: + if err := s.ChoiceQuestion.Decode(d); err != nil { + return err + } + case ScoreQuestionQuestionSum: + if err := s.ScoreQuestion.Decode(d); err != nil { + return err + } + default: + return errors.Errorf("inferred invalid type: %s", s.Type) + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s QuestionSum) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *QuestionSum) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s Questions) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields implements json.Marshaler. +func (s Questions) encodeFields(e *jx.Encoder) { + for k, elem := range s { + e.FieldStart(k) + + elem.Encode(e) + } +} + +// Decode decodes Questions from json. +func (s *Questions) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Questions to nil") + } + m := s.init() + var propertiesCount int + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + propertiesCount++ + var elem Question + if err := func() error { + if err := elem.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrapf(err, "decode field %q", k) + } + m[string(k)] = elem + return nil + }); err != nil { + return errors.Wrap(err, "decode Questions") + } + // Validate properties count. + if err := (validate.Object{ + MinProperties: 1, + MinPropertiesSet: true, + MaxProperties: 0, + MaxPropertiesSet: false, + }).ValidateProperties(propertiesCount); err != nil { + return errors.Wrap(err, "object") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s Questions) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *Questions) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ScoreAnswer) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ScoreAnswer) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } + { + e.FieldStart("score") + s.Score.Encode(e) + } + { + e.FieldStart("legend") + s.Legend.Encode(e) + } + { + e.FieldStart("probabilities") + s.Probabilities.Encode(e) + } + { + e.FieldStart("confidence") + s.Confidence.Encode(e) + } +} + +var jsonFieldsNameOfScoreAnswer = [5]string{ + 0: "type", + 1: "score", + 2: "legend", + 3: "probabilities", + 4: "confidence", +} + +// Decode decodes ScoreAnswer from json. +func (s *ScoreAnswer) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ScoreAnswer to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "type": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "score": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Score.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"score\"") + } + case "legend": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Legend.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"legend\"") + } + case "probabilities": + requiredBitSet[0] |= 1 << 3 + if err := func() error { + if err := s.Probabilities.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"probabilities\"") + } + case "confidence": + requiredBitSet[0] |= 1 << 4 + if err := func() error { + if err := s.Confidence.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"confidence\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ScoreAnswer") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00011111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfScoreAnswer) { + name = jsonFieldsNameOfScoreAnswer[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ScoreAnswer) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ScoreAnswer) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s ScoreAnswerLegend) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields implements json.Marshaler. +func (s ScoreAnswerLegend) encodeFields(e *jx.Encoder) { + for k, elem := range s { + e.FieldStart(k) + + elem.Encode(e) + } +} + +// Decode decodes ScoreAnswerLegend from json. +func (s *ScoreAnswerLegend) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ScoreAnswerLegend to nil") + } + m := s.init() + var propertiesCount int + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + propertiesCount++ + var elem Instructions + if err := func() error { + if err := elem.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrapf(err, "decode field %q", k) + } + m[string(k)] = elem + return nil + }); err != nil { + return errors.Wrap(err, "decode ScoreAnswerLegend") + } + // Validate properties count. + if err := (validate.Object{ + MinProperties: 1, + MinPropertiesSet: true, + MaxProperties: 0, + MaxPropertiesSet: false, + }).ValidateProperties(propertiesCount); err != nil { + return errors.Wrap(err, "object") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ScoreAnswerLegend) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ScoreAnswerLegend) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s ScoreAnswerProbabilities) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields implements json.Marshaler. +func (s ScoreAnswerProbabilities) encodeFields(e *jx.Encoder) { + for k, elem := range s { + e.FieldStart(k) + + elem.Encode(e) + } +} + +// Decode decodes ScoreAnswerProbabilities from json. +func (s *ScoreAnswerProbabilities) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ScoreAnswerProbabilities to nil") + } + m := s.init() + var propertiesCount int + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + propertiesCount++ + var elem Probability + if err := func() error { + if err := elem.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrapf(err, "decode field %q", k) + } + m[string(k)] = elem + return nil + }); err != nil { + return errors.Wrap(err, "decode ScoreAnswerProbabilities") + } + // Validate properties count. + if err := (validate.Object{ + MinProperties: 1, + MinPropertiesSet: true, + MaxProperties: 0, + MaxPropertiesSet: false, + }).ValidateProperties(propertiesCount); err != nil { + return errors.Wrap(err, "object") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ScoreAnswerProbabilities) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ScoreAnswerProbabilities) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ScoreAnswerType as json. +func (s ScoreAnswerType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes ScoreAnswerType from json. +func (s *ScoreAnswerType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ScoreAnswerType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch ScoreAnswerType(v) { + case ScoreAnswerTypeScore: + *s = ScoreAnswerTypeScore + default: + *s = ScoreAnswerType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ScoreAnswerType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ScoreAnswerType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ScoreCriteria as json. +func (s ScoreCriteria) Encode(e *jx.Encoder) { + unwrapped := []Instructions(s) + + e.ArrStart() + for _, elem := range unwrapped { + elem.Encode(e) + } + e.ArrEnd() +} + +// Decode decodes ScoreCriteria from json. +func (s *ScoreCriteria) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ScoreCriteria to nil") + } + var unwrapped []Instructions + if err := func() error { + unwrapped = make([]Instructions, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem Instructions + if err := elem.Decode(d); err != nil { + return err + } + unwrapped = append(unwrapped, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = ScoreCriteria(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ScoreCriteria) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ScoreCriteria) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ScoreQuestion) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ScoreQuestion) encodeFields(e *jx.Encoder) { + { + e.FieldStart("type") + s.Type.Encode(e) + } + { + if s.Instructions.Set { + e.FieldStart("instructions") + s.Instructions.Encode(e) + } + } + { + e.FieldStart("criteria") + s.Criteria.Encode(e) + } +} + +var jsonFieldsNameOfScoreQuestion = [3]string{ + 0: "type", + 1: "instructions", + 2: "criteria", +} + +// Decode decodes ScoreQuestion from json. +func (s *ScoreQuestion) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ScoreQuestion to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "type": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "instructions": + if err := func() error { + s.Instructions.Reset() + if err := s.Instructions.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"instructions\"") + } + case "criteria": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Criteria.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"criteria\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ScoreQuestion") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000101, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfScoreQuestion) { + name = jsonFieldsNameOfScoreQuestion[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ScoreQuestion) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ScoreQuestion) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ScoreQuestionType as json. +func (s ScoreQuestionType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes ScoreQuestionType from json. +func (s *ScoreQuestionType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ScoreQuestionType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch ScoreQuestionType(v) { + case ScoreQuestionTypeScore: + *s = ScoreQuestionTypeScore + default: + *s = ScoreQuestionType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ScoreQuestionType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ScoreQuestionType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ScoreValue as json. +func (s ScoreValue) Encode(e *jx.Encoder) { + unwrapped := float64(s) + + e.Float64(unwrapped) +} + +// Decode decodes ScoreValue from json. +func (s *ScoreValue) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ScoreValue to nil") + } + var unwrapped float64 + if err := func() error { + v, err := d.Float64() + unwrapped = float64(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = ScoreValue(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ScoreValue) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ScoreValue) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes State as json. +func (s State) Encode(e *jx.Encoder) { + switch s.Type { + case StringState: + e.Str(s.String) + case JSONObjectState: + s.JSONObject.Encode(e) + case StateArrayState: + s.StateArray.Encode(e) + } +} + +// Decode decodes State from json. +func (s *State) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode State to nil") + } + // Sum type type_discriminator. + switch t := d.Next(); t { + case jx.Array: + if err := s.StateArray.Decode(d); err != nil { + return err + } + s.Type = StateArrayState + case jx.Object: + if err := s.JSONObject.Decode(d); err != nil { + return err + } + s.Type = JSONObjectState + case jx.String: + v, err := d.Str() + s.String = string(v) + if err != nil { + return err + } + s.Type = StringState + default: + return errors.Errorf("unexpected json type %q", t) + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s State) MarshalJSON() ([]byte, error) { + if err := s.Validate(); err != nil { + return nil, err + } + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *State) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes StateArray as json. +func (s StateArray) Encode(e *jx.Encoder) { + unwrapped := []StateArrayItem(s) + + e.ArrStart() + for _, elem := range unwrapped { + elem.Encode(e) + } + e.ArrEnd() +} + +// Decode decodes StateArray from json. +func (s *StateArray) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode StateArray to nil") + } + var unwrapped []StateArrayItem + if err := func() error { + unwrapped = make([]StateArrayItem, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem StateArrayItem + if err := elem.Decode(d); err != nil { + return err + } + unwrapped = append(unwrapped, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + if err := StateArray(unwrapped).validateHomogeneity(); err != nil { + return err + } + *s = StateArray(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s StateArray) MarshalJSON() ([]byte, error) { + if err := s.validateHomogeneity(); err != nil { + return nil, err + } + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *StateArray) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes StateArrayItem as json. +func (s StateArrayItem) Encode(e *jx.Encoder) { + switch s.Type { + case StringStateArrayItem: + e.Str(s.String) + case JSONObjectStateArrayItem: + s.JSONObject.Encode(e) + } +} + +// Decode decodes StateArrayItem from json. +func (s *StateArrayItem) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode StateArrayItem to nil") + } + // Sum type type_discriminator. + switch t := d.Next(); t { + case jx.Object: + if err := s.JSONObject.Decode(d); err != nil { + return err + } + s.Type = JSONObjectStateArrayItem + case jx.String: + v, err := d.Str() + s.String = string(v) + if err != nil { + return err + } + s.Type = StringStateArrayItem + default: + return errors.Errorf("unexpected json type %q", t) + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s StateArrayItem) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *StateArrayItem) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *SystemOneRequest) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *SystemOneRequest) encodeFields(e *jx.Encoder) { + { + e.FieldStart("model") + s.Model.Encode(e) + } + { + e.FieldStart("state") + s.State.Encode(e) + } + { + e.FieldStart("questions") + s.Questions.Encode(e) + } +} + +var jsonFieldsNameOfSystemOneRequest = [3]string{ + 0: "model", + 1: "state", + 2: "questions", +} + +// Decode decodes SystemOneRequest from json. +func (s *SystemOneRequest) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode SystemOneRequest to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "model": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Model.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"model\"") + } + case "state": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.State.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"state\"") + } + case "questions": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Questions.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"questions\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode SystemOneRequest") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfSystemOneRequest) { + name = jsonFieldsNameOfSystemOneRequest[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *SystemOneRequest) MarshalJSON() ([]byte, error) { + if err := s.State.Validate(); err != nil { + return nil, err + } + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *SystemOneRequest) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *SystemOneResponse) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *SystemOneResponse) encodeFields(e *jx.Encoder) { + { + e.FieldStart("model") + s.Model.Encode(e) + } + { + e.FieldStart("answers") + s.Answers.Encode(e) + } + { + e.FieldStart("usage") + s.Usage.Encode(e) + } +} + +var jsonFieldsNameOfSystemOneResponse = [3]string{ + 0: "model", + 1: "answers", + 2: "usage", +} + +// Decode decodes SystemOneResponse from json. +func (s *SystemOneResponse) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode SystemOneResponse to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "model": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Model.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"model\"") + } + case "answers": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Answers.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"answers\"") + } + case "usage": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Usage.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"usage\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode SystemOneResponse") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfSystemOneResponse) { + name = jsonFieldsNameOfSystemOneResponse[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *SystemOneResponse) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *SystemOneResponse) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s SystemOneResponseAnswers) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields implements json.Marshaler. +func (s SystemOneResponseAnswers) encodeFields(e *jx.Encoder) { + for k, elem := range s { + e.FieldStart(k) + + elem.Encode(e) + } +} + +// Decode decodes SystemOneResponseAnswers from json. +func (s *SystemOneResponseAnswers) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode SystemOneResponseAnswers to nil") + } + m := s.init() + var propertiesCount int + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + propertiesCount++ + var elem Answer + if err := func() error { + if err := elem.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrapf(err, "decode field %q", k) + } + m[string(k)] = elem + return nil + }); err != nil { + return errors.Wrap(err, "decode SystemOneResponseAnswers") + } + // Validate properties count. + if err := (validate.Object{ + MinProperties: 1, + MinPropertiesSet: true, + MaxProperties: 0, + MaxPropertiesSet: false, + }).ValidateProperties(propertiesCount); err != nil { + return errors.Wrap(err, "object") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s SystemOneResponseAnswers) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *SystemOneResponseAnswers) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes TokenCount as json. +func (s TokenCount) Encode(e *jx.Encoder) { + unwrapped := int64(s) + + e.Int64(unwrapped) +} + +// Decode decodes TokenCount from json. +func (s *TokenCount) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode TokenCount to nil") + } + var unwrapped int64 + if err := func() error { + v, err := d.Int64() + unwrapped = int64(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = TokenCount(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s TokenCount) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *TokenCount) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *Usage) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *Usage) encodeFields(e *jx.Encoder) { + { + e.FieldStart("input_tokens") + s.InputTokens.Encode(e) + } + { + e.FieldStart("output_tokens") + s.OutputTokens.Encode(e) + } +} + +var jsonFieldsNameOfUsage = [2]string{ + 0: "input_tokens", + 1: "output_tokens", +} + +// Decode decodes Usage from json. +func (s *Usage) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Usage to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "input_tokens": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.InputTokens.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"input_tokens\"") + } + case "output_tokens": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.OutputTokens.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"output_tokens\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode Usage") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfUsage) { + name = jsonFieldsNameOfUsage[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *Usage) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *Usage) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} diff --git a/arkruntime/model/systemone/oas_parameters_gen.go b/arkruntime/model/systemone/oas_parameters_gen.go new file mode 100644 index 0000000..2653315 --- /dev/null +++ b/arkruntime/model/systemone/oas_parameters_gen.go @@ -0,0 +1,14 @@ +// Copyright (c) 2026 ByteDance Ltd. and/or its affiliates. +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by ogen, DO NOT EDIT. + +package systemone + +// SystemOneEvaluateParams is parameters of SystemOne_evaluate operation. +type SystemOneEvaluateParams struct { + // Temporary System One beta opt-in header, required during the current beta. Send the literal string + // true through configurable request headers. The opt-in requirement may be removed in a future + // release. + ArkBetaSystemoneAPI SystemOneEvaluateArkBetaSystemoneAPI +} diff --git a/arkruntime/model/systemone/oas_schemas_gen.go b/arkruntime/model/systemone/oas_schemas_gen.go new file mode 100644 index 0000000..850fa60 --- /dev/null +++ b/arkruntime/model/systemone/oas_schemas_gen.go @@ -0,0 +1,2039 @@ +// Copyright (c) 2026 ByteDance Ltd. and/or its affiliates. +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by ogen, DO NOT EDIT. + +package systemone + +import ( + "github.com/go-faster/errors" + "github.com/go-faster/jx" +) + +// Answer variant matching the corresponding question type. +// Ref: #/components/schemas/Answer +type Answer struct { + OneOf AnswerSum +} + +// GetOneOf returns the value of OneOf. +func (s *Answer) GetOneOf() AnswerSum { + return s.OneOf +} + +// SetOneOf sets the value of OneOf. +func (s *Answer) SetOneOf(val AnswerSum) { + s.OneOf = val +} + +// AnswerSum represents sum type. +type AnswerSum struct { + // Only populated for unknown wire variants; no known member is selected. + unknownType string + unknownJSON string + Type AnswerSumType // switch on this field + NoulAnswer NoulAnswer + ChoiceAnswer ChoiceAnswer + ScoreAnswer ScoreAnswer +} + +// GetUnknown returns the discriminator and original JSON for an unknown variant. +// The bool is false for known variants and zero values. Explicit validation +// remains strict; selecting a known member makes the fallback inactive. +func (s AnswerSum) GetUnknown() (string, string, bool) { + if s.Type != "" || s.unknownType == "" { + return "", "", false + } + return s.unknownType, s.unknownJSON, true +} + +// AnswerSumType is oneOf type of AnswerSum. +type AnswerSumType string + +// Possible values for AnswerSumType. +const ( + NoulAnswerAnswerSum AnswerSumType = "noul" + ChoiceAnswerAnswerSum AnswerSumType = "choice" + ScoreAnswerAnswerSum AnswerSumType = "score" +) + +// IsNoulAnswer reports whether AnswerSum is NoulAnswer. +func (s AnswerSum) IsNoulAnswer() bool { return s.Type == NoulAnswerAnswerSum } + +// IsChoiceAnswer reports whether AnswerSum is ChoiceAnswer. +func (s AnswerSum) IsChoiceAnswer() bool { return s.Type == ChoiceAnswerAnswerSum } + +// IsScoreAnswer reports whether AnswerSum is ScoreAnswer. +func (s AnswerSum) IsScoreAnswer() bool { return s.Type == ScoreAnswerAnswerSum } + +// SetNoulAnswer sets AnswerSum to NoulAnswer. +func (s *AnswerSum) SetNoulAnswer(v NoulAnswer) { + s.Type = NoulAnswerAnswerSum + s.unknownType = "" + s.unknownJSON = "" + s.NoulAnswer = v +} + +// GetNoulAnswer returns NoulAnswer and true boolean if AnswerSum is NoulAnswer. +func (s AnswerSum) GetNoulAnswer() (v NoulAnswer, ok bool) { + if !s.IsNoulAnswer() { + return v, false + } + return s.NoulAnswer, true +} + +// NewNoulAnswerAnswerSum returns new AnswerSum from NoulAnswer. +func NewNoulAnswerAnswerSum(v NoulAnswer) AnswerSum { + var s AnswerSum + s.SetNoulAnswer(v) + return s +} + +// SetChoiceAnswer sets AnswerSum to ChoiceAnswer. +func (s *AnswerSum) SetChoiceAnswer(v ChoiceAnswer) { + s.Type = ChoiceAnswerAnswerSum + s.unknownType = "" + s.unknownJSON = "" + s.ChoiceAnswer = v +} + +// GetChoiceAnswer returns ChoiceAnswer and true boolean if AnswerSum is ChoiceAnswer. +func (s AnswerSum) GetChoiceAnswer() (v ChoiceAnswer, ok bool) { + if !s.IsChoiceAnswer() { + return v, false + } + return s.ChoiceAnswer, true +} + +// NewChoiceAnswerAnswerSum returns new AnswerSum from ChoiceAnswer. +func NewChoiceAnswerAnswerSum(v ChoiceAnswer) AnswerSum { + var s AnswerSum + s.SetChoiceAnswer(v) + return s +} + +// SetScoreAnswer sets AnswerSum to ScoreAnswer. +func (s *AnswerSum) SetScoreAnswer(v ScoreAnswer) { + s.Type = ScoreAnswerAnswerSum + s.unknownType = "" + s.unknownJSON = "" + s.ScoreAnswer = v +} + +// GetScoreAnswer returns ScoreAnswer and true boolean if AnswerSum is ScoreAnswer. +func (s AnswerSum) GetScoreAnswer() (v ScoreAnswer, ok bool) { + if !s.IsScoreAnswer() { + return v, false + } + return s.ScoreAnswer, true +} + +// NewScoreAnswerAnswerSum returns new AnswerSum from ScoreAnswer. +func NewScoreAnswerAnswerSum(v ScoreAnswer) AnswerSum { + var s AnswerSum + s.SetScoreAnswer(v) + return s +} + +type BearerAuth struct { + Token string + Roles []string +} + +// GetToken returns the value of Token. +func (s *BearerAuth) GetToken() string { + return s.Token +} + +// GetRoles returns the value of Roles. +func (s *BearerAuth) GetRoles() []string { + return s.Roles +} + +// SetToken sets the value of Token. +func (s *BearerAuth) SetToken(val string) { + s.Token = val +} + +// SetRoles sets the value of Roles. +func (s *BearerAuth) SetRoles(val []string) { + s.Roles = val +} + +// Most likely choice and the probability of every supplied option. +// Ref: #/components/schemas/ChoiceAnswer +type ChoiceAnswer struct { + // Answer type; matches the question type. + Type ChoiceAnswerType `json:"type"` + // An option with the maximum probability, using the original criteria key. + Choice string `json:"choice"` + // Every option, including zero probabilities; values sum to 1 within floating-point tolerance. + Probabilities ChoiceAnswerProbabilities `json:"probabilities"` + // Confidence in the classification, from 0 to 1 inclusive. It is distinct from an individual option + // probability; its calculation depends on the model. + Confidence Probability `json:"confidence"` +} + +// GetType returns the value of Type. +func (s *ChoiceAnswer) GetType() ChoiceAnswerType { + return s.Type +} + +// GetChoice returns the value of Choice. +func (s *ChoiceAnswer) GetChoice() string { + return s.Choice +} + +// GetProbabilities returns the value of Probabilities. +func (s *ChoiceAnswer) GetProbabilities() ChoiceAnswerProbabilities { + return s.Probabilities +} + +// GetConfidence returns the value of Confidence. +func (s *ChoiceAnswer) GetConfidence() Probability { + return s.Confidence +} + +// SetType sets the value of Type. +func (s *ChoiceAnswer) SetType(val ChoiceAnswerType) { + s.Type = val +} + +// SetChoice sets the value of Choice. +func (s *ChoiceAnswer) SetChoice(val string) { + s.Choice = val +} + +// SetProbabilities sets the value of Probabilities. +func (s *ChoiceAnswer) SetProbabilities(val ChoiceAnswerProbabilities) { + s.Probabilities = val +} + +// SetConfidence sets the value of Confidence. +func (s *ChoiceAnswer) SetConfidence(val Probability) { + s.Confidence = val +} + +// Every option, including zero probabilities; values sum to 1 within floating-point tolerance. +type ChoiceAnswerProbabilities map[string]Probability + +func (s *ChoiceAnswerProbabilities) init() ChoiceAnswerProbabilities { + m := *s + if m == nil { + m = map[string]Probability{} + *s = m + } + return m +} + +// Answer type; matches the question type. +type ChoiceAnswerType string + +const ( + ChoiceAnswerTypeChoice ChoiceAnswerType = "choice" +) + +// AllValues returns all ChoiceAnswerType values. +func (ChoiceAnswerType) AllValues() []ChoiceAnswerType { + return []ChoiceAnswerType{ + ChoiceAnswerTypeChoice, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s ChoiceAnswerType) MarshalText() ([]byte, error) { + switch s { + case ChoiceAnswerTypeChoice: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *ChoiceAnswerType) UnmarshalText(data []byte) error { + switch ChoiceAnswerType(data) { + case ChoiceAnswerTypeChoice: + *s = ChoiceAnswerTypeChoice + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// Map from option names to descriptions. Each question accepts 1-255 options, inclusive; a single +// option is valid and an empty object is invalid. Option names, including empty or whitespace names, +// are passed through unchanged and take part in evaluation. The service preserves the option order +// it receives; JSON map serialization in an SDK may determine that order. Use distinct, mutually +// exclusive options and add an explicit fallback option when needed. Duplicate JSON keys use the +// last value; send unique names to avoid ambiguity. +// Ref: #/components/schemas/ChoiceCriteria +type ChoiceCriteria map[string]ChoiceDescription + +func (s *ChoiceCriteria) init() ChoiceCriteria { + m := *s + if m == nil { + m = map[string]ChoiceDescription{} + *s = m + } + return m +} + +// Description of one choice option. Explicit null means that the option has no additional +// description. +// Ref: #/components/schemas/ChoiceDescription +// ChoiceDescription represents sum type. +type ChoiceDescription struct { + Type ChoiceDescriptionType // switch on this field + String string + JSONObject JSONObject + AnyArray []jx.Raw + Null struct{} +} + +// ChoiceDescriptionType is oneOf type of ChoiceDescription. +type ChoiceDescriptionType string + +// Possible values for ChoiceDescriptionType. +const ( + StringChoiceDescription ChoiceDescriptionType = "string" + JSONObjectChoiceDescription ChoiceDescriptionType = "JSONObject" + AnyArrayChoiceDescription ChoiceDescriptionType = "[]jx.Raw" + NullChoiceDescription ChoiceDescriptionType = "struct{}" +) + +// IsString reports whether ChoiceDescription is string. +func (s ChoiceDescription) IsString() bool { return s.Type == StringChoiceDescription } + +// IsJSONObject reports whether ChoiceDescription is JSONObject. +func (s ChoiceDescription) IsJSONObject() bool { return s.Type == JSONObjectChoiceDescription } + +// IsAnyArray reports whether ChoiceDescription is []jx.Raw. +func (s ChoiceDescription) IsAnyArray() bool { return s.Type == AnyArrayChoiceDescription } + +// IsNull reports whether ChoiceDescription is struct{}. +func (s ChoiceDescription) IsNull() bool { return s.Type == NullChoiceDescription } + +// SetString sets ChoiceDescription to string. +func (s *ChoiceDescription) SetString(v string) { + s.Type = StringChoiceDescription + s.String = v +} + +// GetString returns string and true boolean if ChoiceDescription is string. +func (s ChoiceDescription) GetString() (v string, ok bool) { + if !s.IsString() { + return v, false + } + return s.String, true +} + +// NewStringChoiceDescription returns new ChoiceDescription from string. +func NewStringChoiceDescription(v string) ChoiceDescription { + var s ChoiceDescription + s.SetString(v) + return s +} + +// SetJSONObject sets ChoiceDescription to JSONObject. +func (s *ChoiceDescription) SetJSONObject(v JSONObject) { + s.Type = JSONObjectChoiceDescription + s.JSONObject = v +} + +// GetJSONObject returns JSONObject and true boolean if ChoiceDescription is JSONObject. +func (s ChoiceDescription) GetJSONObject() (v JSONObject, ok bool) { + if !s.IsJSONObject() { + return v, false + } + return s.JSONObject, true +} + +// NewJSONObjectChoiceDescription returns new ChoiceDescription from JSONObject. +func NewJSONObjectChoiceDescription(v JSONObject) ChoiceDescription { + var s ChoiceDescription + s.SetJSONObject(v) + return s +} + +// SetAnyArray sets ChoiceDescription to []jx.Raw. +func (s *ChoiceDescription) SetAnyArray(v []jx.Raw) { + s.Type = AnyArrayChoiceDescription + s.AnyArray = v +} + +// GetAnyArray returns []jx.Raw and true boolean if ChoiceDescription is []jx.Raw. +func (s ChoiceDescription) GetAnyArray() (v []jx.Raw, ok bool) { + if !s.IsAnyArray() { + return v, false + } + return s.AnyArray, true +} + +// NewAnyArrayChoiceDescription returns new ChoiceDescription from []jx.Raw. +func NewAnyArrayChoiceDescription(v []jx.Raw) ChoiceDescription { + var s ChoiceDescription + s.SetAnyArray(v) + return s +} + +// SetNull sets ChoiceDescription to struct{}. +func (s *ChoiceDescription) SetNull(v struct{}) { + s.Type = NullChoiceDescription + s.Null = v +} + +// GetNull returns struct{} and true boolean if ChoiceDescription is struct{}. +func (s ChoiceDescription) GetNull() (v struct{}, ok bool) { + if !s.IsNull() { + return v, false + } + return s.Null, true +} + +// NewNullChoiceDescription returns new ChoiceDescription from struct{}. +func NewNullChoiceDescription(v struct{}) ChoiceDescription { + var s ChoiceDescription + s.SetNull(v) + return s +} + +// A classification question. The answer selects one of the supplied criteria keys. +// Ref: #/components/schemas/ChoiceQuestion +type ChoiceQuestion struct { + // Question type. Use choice to select the most likely option. + Type ChoiceQuestionType `json:"type"` + // Optional evaluation instructions. Omitted or null uses the model's defaults; does not inherit + // instructions from other questions. + Instructions OptNullableInstructions `json:"instructions"` + // Candidate options and descriptions. Required; 1-255 options per question, inclusive. + Criteria ChoiceCriteria `json:"criteria"` +} + +// GetType returns the value of Type. +func (s *ChoiceQuestion) GetType() ChoiceQuestionType { + return s.Type +} + +// GetInstructions returns the value of Instructions. +func (s *ChoiceQuestion) GetInstructions() OptNullableInstructions { + return s.Instructions +} + +// GetCriteria returns the value of Criteria. +func (s *ChoiceQuestion) GetCriteria() ChoiceCriteria { + return s.Criteria +} + +// SetType sets the value of Type. +func (s *ChoiceQuestion) SetType(val ChoiceQuestionType) { + s.Type = val +} + +// SetInstructions sets the value of Instructions. +func (s *ChoiceQuestion) SetInstructions(val OptNullableInstructions) { + s.Instructions = val +} + +// SetCriteria sets the value of Criteria. +func (s *ChoiceQuestion) SetCriteria(val ChoiceCriteria) { + s.Criteria = val +} + +// Question type. Use choice to select the most likely option. +type ChoiceQuestionType string + +const ( + ChoiceQuestionTypeChoice ChoiceQuestionType = "choice" +) + +// AllValues returns all ChoiceQuestionType values. +func (ChoiceQuestionType) AllValues() []ChoiceQuestionType { + return []ChoiceQuestionType{ + ChoiceQuestionTypeChoice, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s ChoiceQuestionType) MarshalText() ([]byte, error) { + switch s { + case ChoiceQuestionTypeChoice: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *ChoiceQuestionType) UnmarshalText(data []byte) error { + switch ChoiceQuestionType(data) { + case ChoiceQuestionTypeChoice: + *s = ChoiceQuestionTypeChoice + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// Public error details. Use code for programmatic handling; message can change. +// Ref: #/components/schemas/ErrorDetail +type ErrorDetail struct { + // Stable error code, such as InvalidParameter, AuthenticationError or ServerOverloaded. + Code string `json:"code"` + // Human-readable cause and, when available, the request ID. Size and length errors identify the + // exceeded limit and its value. Do not parse this string for business logic. + Message string `json:"message"` + // Invalid parameter path, such as questions["q"].criteria or state[0].image_url. "body format" + // denotes invalid JSON syntax; body denotes an invalid overall request structure or an aggregate + // request/text limit; Content-Type denotes an invalid request media type. May be empty for errors + // not associated with a field or errors returned before parameter validation. + Param string `json:"param"` + // Error category, such as BadRequest, Unauthorized or ServiceUnavailable. Prefer code when handling + // errors. + Type string `json:"type"` +} + +// GetCode returns the value of Code. +func (s *ErrorDetail) GetCode() string { + return s.Code +} + +// GetMessage returns the value of Message. +func (s *ErrorDetail) GetMessage() string { + return s.Message +} + +// GetParam returns the value of Param. +func (s *ErrorDetail) GetParam() string { + return s.Param +} + +// GetType returns the value of Type. +func (s *ErrorDetail) GetType() string { + return s.Type +} + +// SetCode sets the value of Code. +func (s *ErrorDetail) SetCode(val string) { + s.Code = val +} + +// SetMessage sets the value of Message. +func (s *ErrorDetail) SetMessage(val string) { + s.Message = val +} + +// SetParam sets the value of Param. +func (s *ErrorDetail) SetParam(val string) { + s.Param = val +} + +// SetType sets the value of Type. +func (s *ErrorDetail) SetType(val string) { + s.Type = val +} + +// Standard JSON error envelope. Save the response X-Request-Id header when reporting a failure. +// Ref: #/components/schemas/ErrorResponse +type ErrorResponse struct { + // Error code, description and parameter location. + Error ErrorDetail `json:"error"` +} + +// GetError returns the value of Error. +func (s *ErrorResponse) GetError() ErrorDetail { + return s.Error +} + +// SetError sets the value of Error. +func (s *ErrorResponse) SetError(val ErrorDetail) { + s.Error = val +} + +// ErrorResponseHeaders wraps ErrorResponse with response headers. +type ErrorResponseHeaders struct { + XRequestID OptString + Response ErrorResponse +} + +// GetXRequestID returns the value of XRequestID. +func (s *ErrorResponseHeaders) GetXRequestID() OptString { + return s.XRequestID +} + +// GetResponse returns the value of Response. +func (s *ErrorResponseHeaders) GetResponse() ErrorResponse { + return s.Response +} + +// SetXRequestID sets the value of XRequestID. +func (s *ErrorResponseHeaders) SetXRequestID(val OptString) { + s.XRequestID = val +} + +// SetResponse sets the value of Response. +func (s *ErrorResponseHeaders) SetResponse(val ErrorResponse) { + s.Response = val +} + +// Access restrictions normally use the standard error object, including at the API entry. Some entry +// routes instead return the legacy error_code/error_msg envelope. The two envelopes are mutually +// exclusive; the envelope alone does not identify which component denied access. +// Ref: #/components/schemas/ForbiddenResponse +type ForbiddenResponse struct { + // Standard access-denial error. If present, error_code and error_msg are absent. + Error OptErrorDetail `json:"error"` + // Gateway error code, normally AccessDenied. Required with error_msg when error is absent. + ErrorCode OptString `json:"error_code"` + // Gateway access-denial message, potentially including RequestId. Required with error_code when + // error is absent. + ErrorMsg OptString `json:"error_msg"` +} + +// GetError returns the value of Error. +func (s *ForbiddenResponse) GetError() OptErrorDetail { + return s.Error +} + +// GetErrorCode returns the value of ErrorCode. +func (s *ForbiddenResponse) GetErrorCode() OptString { + return s.ErrorCode +} + +// GetErrorMsg returns the value of ErrorMsg. +func (s *ForbiddenResponse) GetErrorMsg() OptString { + return s.ErrorMsg +} + +// SetError sets the value of Error. +func (s *ForbiddenResponse) SetError(val OptErrorDetail) { + s.Error = val +} + +// SetErrorCode sets the value of ErrorCode. +func (s *ForbiddenResponse) SetErrorCode(val OptString) { + s.ErrorCode = val +} + +// SetErrorMsg sets the value of ErrorMsg. +func (s *ForbiddenResponse) SetErrorMsg(val OptString) { + s.ErrorMsg = val +} + +// ForbiddenResponseHeaders wraps ForbiddenResponse with response headers. +type ForbiddenResponseHeaders struct { + XRequestID OptString + Response ForbiddenResponse +} + +// GetXRequestID returns the value of XRequestID. +func (s *ForbiddenResponseHeaders) GetXRequestID() OptString { + return s.XRequestID +} + +// GetResponse returns the value of Response. +func (s *ForbiddenResponseHeaders) GetResponse() ForbiddenResponse { + return s.Response +} + +// SetXRequestID sets the value of XRequestID. +func (s *ForbiddenResponseHeaders) SetXRequestID(val OptString) { + s.XRequestID = val +} + +// SetResponse sets the value of Response. +func (s *ForbiddenResponseHeaders) SetResponse(val ForbiddenResponse) { + s.Response = val +} + +func (*ForbiddenResponseHeaders) systemOneEvaluateRes() {} + +// One instruction or score-level description: a string, JSON object or array. Nested JSON is +// retained. Top-level null, numbers and booleans are rejected. +// Ref: #/components/schemas/Instructions +// Instructions represents sum type. +type Instructions struct { + Type InstructionsType // switch on this field + String string + JSONObject JSONObject + AnyArray []jx.Raw +} + +// InstructionsType is oneOf type of Instructions. +type InstructionsType string + +// Possible values for InstructionsType. +const ( + StringInstructions InstructionsType = "string" + JSONObjectInstructions InstructionsType = "JSONObject" + AnyArrayInstructions InstructionsType = "[]jx.Raw" +) + +// IsString reports whether Instructions is string. +func (s Instructions) IsString() bool { return s.Type == StringInstructions } + +// IsJSONObject reports whether Instructions is JSONObject. +func (s Instructions) IsJSONObject() bool { return s.Type == JSONObjectInstructions } + +// IsAnyArray reports whether Instructions is []jx.Raw. +func (s Instructions) IsAnyArray() bool { return s.Type == AnyArrayInstructions } + +// SetString sets Instructions to string. +func (s *Instructions) SetString(v string) { + s.Type = StringInstructions + s.String = v +} + +// GetString returns string and true boolean if Instructions is string. +func (s Instructions) GetString() (v string, ok bool) { + if !s.IsString() { + return v, false + } + return s.String, true +} + +// NewStringInstructions returns new Instructions from string. +func NewStringInstructions(v string) Instructions { + var s Instructions + s.SetString(v) + return s +} + +// SetJSONObject sets Instructions to JSONObject. +func (s *Instructions) SetJSONObject(v JSONObject) { + s.Type = JSONObjectInstructions + s.JSONObject = v +} + +// GetJSONObject returns JSONObject and true boolean if Instructions is JSONObject. +func (s Instructions) GetJSONObject() (v JSONObject, ok bool) { + if !s.IsJSONObject() { + return v, false + } + return s.JSONObject, true +} + +// NewJSONObjectInstructions returns new Instructions from JSONObject. +func NewJSONObjectInstructions(v JSONObject) Instructions { + var s Instructions + s.SetJSONObject(v) + return s +} + +// SetAnyArray sets Instructions to []jx.Raw. +func (s *Instructions) SetAnyArray(v []jx.Raw) { + s.Type = AnyArrayInstructions + s.AnyArray = v +} + +// GetAnyArray returns []jx.Raw and true boolean if Instructions is []jx.Raw. +func (s Instructions) GetAnyArray() (v []jx.Raw, ok bool) { + if !s.IsAnyArray() { + return v, false + } + return s.AnyArray, true +} + +// NewAnyArrayInstructions returns new Instructions from []jx.Raw. +func NewAnyArrayInstructions(v []jx.Raw) Instructions { + var s Instructions + s.SetAnyArray(v) + return s +} + +// Arbitrary JSON object. Nested values, including null, are retained as evaluation content. +// Ref: #/components/schemas/JSONObject +type JSONObject map[string]jx.Raw + +func (s *JSONObject) init() JSONObject { + m := *s + if m == nil { + m = map[string]jx.Raw{} + *s = m + } + return m +} + +type ModelID string + +// Probability assigned to a yes/no question. +// Ref: #/components/schemas/NoulAnswer +type NoulAnswer struct { + // Answer type; matches the question type. + Type NoulAnswerType `json:"type"` + // Probability of yes. Zero is present and valid; noul has no confidence field. + Noul Probability `json:"noul"` +} + +// GetType returns the value of Type. +func (s *NoulAnswer) GetType() NoulAnswerType { + return s.Type +} + +// GetNoul returns the value of Noul. +func (s *NoulAnswer) GetNoul() Probability { + return s.Noul +} + +// SetType sets the value of Type. +func (s *NoulAnswer) SetType(val NoulAnswerType) { + s.Type = val +} + +// SetNoul sets the value of Noul. +func (s *NoulAnswer) SetNoul(val Probability) { + s.Noul = val +} + +// Answer type; matches the question type. +type NoulAnswerType string + +const ( + NoulAnswerTypeNoul NoulAnswerType = "noul" +) + +// AllValues returns all NoulAnswerType values. +func (NoulAnswerType) AllValues() []NoulAnswerType { + return []NoulAnswerType{ + NoulAnswerTypeNoul, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s NoulAnswerType) MarshalText() ([]byte, error) { + switch s { + case NoulAnswerTypeNoul: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *NoulAnswerType) UnmarshalText(data []byte) error { + switch NoulAnswerType(data) { + case NoulAnswerTypeNoul: + *s = NoulAnswerTypeNoul + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// Optional descriptions of the true and false outcomes. Omitted or null descriptions use the model's +// defaults. An empty object is accepted; other keys are ignored. The criteria object itself cannot +// be null. +// Ref: #/components/schemas/NoulCriteria +type NoulCriteria struct { + // Meaning of the true outcome. Accepts a string, object, array or null; omitted or null uses the + // model's default description. + True OptNullableInstructions `json:"true"` + // Meaning of the false outcome. Accepts a string, object, array or null; omitted or null uses the + // model's default description. + False OptNullableInstructions `json:"false"` + AdditionalProps NoulCriteriaAdditional +} + +// GetTrue returns the value of True. +func (s *NoulCriteria) GetTrue() OptNullableInstructions { + return s.True +} + +// GetFalse returns the value of False. +func (s *NoulCriteria) GetFalse() OptNullableInstructions { + return s.False +} + +// GetAdditionalProps returns the value of AdditionalProps. +func (s *NoulCriteria) GetAdditionalProps() NoulCriteriaAdditional { + return s.AdditionalProps +} + +// SetTrue sets the value of True. +func (s *NoulCriteria) SetTrue(val OptNullableInstructions) { + s.True = val +} + +// SetFalse sets the value of False. +func (s *NoulCriteria) SetFalse(val OptNullableInstructions) { + s.False = val +} + +// SetAdditionalProps sets the value of AdditionalProps. +func (s *NoulCriteria) SetAdditionalProps(val NoulCriteriaAdditional) { + s.AdditionalProps = val +} + +type NoulCriteriaAdditional map[string]jx.Raw + +func (s *NoulCriteriaAdditional) init() NoulCriteriaAdditional { + m := *s + if m == nil { + m = map[string]jx.Raw{} + *s = m + } + return m +} + +// A yes/no question. The answer is the probability of the true outcome. +// Ref: #/components/schemas/NoulQuestion +type NoulQuestion struct { + // Question type. Use noul for a yes/no probability. + Type NoulQuestionType `json:"type"` + // Optional evaluation instructions. Omitted or null uses the model's defaults. Empty strings and + // containers are accepted. + Instructions OptNullableInstructions `json:"instructions"` + // Optional true/false descriptions. Omit for model defaults. An empty object is valid; null is not. + Criteria OptNoulCriteria `json:"criteria"` +} + +// GetType returns the value of Type. +func (s *NoulQuestion) GetType() NoulQuestionType { + return s.Type +} + +// GetInstructions returns the value of Instructions. +func (s *NoulQuestion) GetInstructions() OptNullableInstructions { + return s.Instructions +} + +// GetCriteria returns the value of Criteria. +func (s *NoulQuestion) GetCriteria() OptNoulCriteria { + return s.Criteria +} + +// SetType sets the value of Type. +func (s *NoulQuestion) SetType(val NoulQuestionType) { + s.Type = val +} + +// SetInstructions sets the value of Instructions. +func (s *NoulQuestion) SetInstructions(val OptNullableInstructions) { + s.Instructions = val +} + +// SetCriteria sets the value of Criteria. +func (s *NoulQuestion) SetCriteria(val OptNoulCriteria) { + s.Criteria = val +} + +// Question type. Use noul for a yes/no probability. +type NoulQuestionType string + +const ( + NoulQuestionTypeNoul NoulQuestionType = "noul" +) + +// AllValues returns all NoulQuestionType values. +func (NoulQuestionType) AllValues() []NoulQuestionType { + return []NoulQuestionType{ + NoulQuestionTypeNoul, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s NoulQuestionType) MarshalText() ([]byte, error) { + switch s { + case NoulQuestionTypeNoul: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *NoulQuestionType) UnmarshalText(data []byte) error { + switch NoulQuestionType(data) { + case NoulQuestionTypeNoul: + *s = NoulQuestionTypeNoul + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// Evaluation instructions or an outcome description. Accepts a string, JSON object, array or null. +// Omitted or null values use the model's defaults; nested JSON is retained. +// Ref: #/components/schemas/NullableInstructions +// NullableInstructions represents sum type. +type NullableInstructions struct { + Type NullableInstructionsType // switch on this field + String string + JSONObject JSONObject + AnyArray []jx.Raw + Null struct{} +} + +// NullableInstructionsType is oneOf type of NullableInstructions. +type NullableInstructionsType string + +// Possible values for NullableInstructionsType. +const ( + StringNullableInstructions NullableInstructionsType = "string" + JSONObjectNullableInstructions NullableInstructionsType = "JSONObject" + AnyArrayNullableInstructions NullableInstructionsType = "[]jx.Raw" + NullNullableInstructions NullableInstructionsType = "struct{}" +) + +// IsString reports whether NullableInstructions is string. +func (s NullableInstructions) IsString() bool { return s.Type == StringNullableInstructions } + +// IsJSONObject reports whether NullableInstructions is JSONObject. +func (s NullableInstructions) IsJSONObject() bool { return s.Type == JSONObjectNullableInstructions } + +// IsAnyArray reports whether NullableInstructions is []jx.Raw. +func (s NullableInstructions) IsAnyArray() bool { return s.Type == AnyArrayNullableInstructions } + +// IsNull reports whether NullableInstructions is struct{}. +func (s NullableInstructions) IsNull() bool { return s.Type == NullNullableInstructions } + +// SetString sets NullableInstructions to string. +func (s *NullableInstructions) SetString(v string) { + s.Type = StringNullableInstructions + s.String = v +} + +// GetString returns string and true boolean if NullableInstructions is string. +func (s NullableInstructions) GetString() (v string, ok bool) { + if !s.IsString() { + return v, false + } + return s.String, true +} + +// NewStringNullableInstructions returns new NullableInstructions from string. +func NewStringNullableInstructions(v string) NullableInstructions { + var s NullableInstructions + s.SetString(v) + return s +} + +// SetJSONObject sets NullableInstructions to JSONObject. +func (s *NullableInstructions) SetJSONObject(v JSONObject) { + s.Type = JSONObjectNullableInstructions + s.JSONObject = v +} + +// GetJSONObject returns JSONObject and true boolean if NullableInstructions is JSONObject. +func (s NullableInstructions) GetJSONObject() (v JSONObject, ok bool) { + if !s.IsJSONObject() { + return v, false + } + return s.JSONObject, true +} + +// NewJSONObjectNullableInstructions returns new NullableInstructions from JSONObject. +func NewJSONObjectNullableInstructions(v JSONObject) NullableInstructions { + var s NullableInstructions + s.SetJSONObject(v) + return s +} + +// SetAnyArray sets NullableInstructions to []jx.Raw. +func (s *NullableInstructions) SetAnyArray(v []jx.Raw) { + s.Type = AnyArrayNullableInstructions + s.AnyArray = v +} + +// GetAnyArray returns []jx.Raw and true boolean if NullableInstructions is []jx.Raw. +func (s NullableInstructions) GetAnyArray() (v []jx.Raw, ok bool) { + if !s.IsAnyArray() { + return v, false + } + return s.AnyArray, true +} + +// NewAnyArrayNullableInstructions returns new NullableInstructions from []jx.Raw. +func NewAnyArrayNullableInstructions(v []jx.Raw) NullableInstructions { + var s NullableInstructions + s.SetAnyArray(v) + return s +} + +// SetNull sets NullableInstructions to struct{}. +func (s *NullableInstructions) SetNull(v struct{}) { + s.Type = NullNullableInstructions + s.Null = v +} + +// GetNull returns struct{} and true boolean if NullableInstructions is struct{}. +func (s NullableInstructions) GetNull() (v struct{}, ok bool) { + if !s.IsNull() { + return v, false + } + return s.Null, true +} + +// NewNullNullableInstructions returns new NullableInstructions from struct{}. +func NewNullNullableInstructions(v struct{}) NullableInstructions { + var s NullableInstructions + s.SetNull(v) + return s +} + +// NewOptErrorDetail returns new OptErrorDetail with value set to v. +func NewOptErrorDetail(v ErrorDetail) OptErrorDetail { + return OptErrorDetail{ + Value: v, + Set: true, + } +} + +// OptErrorDetail is optional ErrorDetail. +type OptErrorDetail struct { + Value ErrorDetail + Set bool +} + +// IsSet returns true if OptErrorDetail was set. +func (o OptErrorDetail) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptErrorDetail) Reset() { + var v ErrorDetail + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptErrorDetail) SetTo(v ErrorDetail) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptErrorDetail) Get() (v ErrorDetail, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptErrorDetail) Or(d ErrorDetail) ErrorDetail { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptInt32 returns new OptInt32 with value set to v. +func NewOptInt32(v int32) OptInt32 { + return OptInt32{ + Value: v, + Set: true, + } +} + +// OptInt32 is optional int32. +type OptInt32 struct { + Value int32 + Set bool +} + +// IsSet returns true if OptInt32 was set. +func (o OptInt32) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptInt32) Reset() { + var v int32 + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptInt32) SetTo(v int32) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptInt32) Get() (v int32, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptInt32) Or(d int32) int32 { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptNoulCriteria returns new OptNoulCriteria with value set to v. +func NewOptNoulCriteria(v NoulCriteria) OptNoulCriteria { + return OptNoulCriteria{ + Value: v, + Set: true, + } +} + +// OptNoulCriteria is optional NoulCriteria. +type OptNoulCriteria struct { + Value NoulCriteria + Set bool +} + +// IsSet returns true if OptNoulCriteria was set. +func (o OptNoulCriteria) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptNoulCriteria) Reset() { + var v NoulCriteria + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptNoulCriteria) SetTo(v NoulCriteria) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptNoulCriteria) Get() (v NoulCriteria, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptNoulCriteria) Or(d NoulCriteria) NoulCriteria { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptNullableInstructions returns new OptNullableInstructions with value set to v. +func NewOptNullableInstructions(v NullableInstructions) OptNullableInstructions { + return OptNullableInstructions{ + Value: v, + Set: true, + } +} + +// OptNullableInstructions is optional NullableInstructions. +type OptNullableInstructions struct { + Value NullableInstructions + Set bool +} + +// IsSet returns true if OptNullableInstructions was set. +func (o OptNullableInstructions) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptNullableInstructions) Reset() { + var v NullableInstructions + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptNullableInstructions) SetTo(v NullableInstructions) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptNullableInstructions) Get() (v NullableInstructions, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptNullableInstructions) Or(d NullableInstructions) NullableInstructions { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptString returns new OptString with value set to v. +func NewOptString(v string) OptString { + return OptString{ + Value: v, + Set: true, + } +} + +// OptString is optional string. +type OptString struct { + Value string + Set bool +} + +// IsSet returns true if OptString was set. +func (o OptString) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptString) Reset() { + var v string + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptString) SetTo(v string) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptString) Get() (v string, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptString) Or(d string) string { + if v, ok := o.Get(); ok { + return v + } + return d +} + +type Probability float64 + +// Each question has exactly one of the three supported types. +// Ref: #/components/schemas/Question +type Question struct { + OneOf QuestionSum +} + +// GetOneOf returns the value of OneOf. +func (s *Question) GetOneOf() QuestionSum { + return s.OneOf +} + +// SetOneOf sets the value of OneOf. +func (s *Question) SetOneOf(val QuestionSum) { + s.OneOf = val +} + +// QuestionSum represents sum type. +type QuestionSum struct { + Type QuestionSumType // switch on this field + NoulQuestion NoulQuestion + ChoiceQuestion ChoiceQuestion + ScoreQuestion ScoreQuestion +} + +// QuestionSumType is oneOf type of QuestionSum. +type QuestionSumType string + +// Possible values for QuestionSumType. +const ( + NoulQuestionQuestionSum QuestionSumType = "noul" + ChoiceQuestionQuestionSum QuestionSumType = "choice" + ScoreQuestionQuestionSum QuestionSumType = "score" +) + +// IsNoulQuestion reports whether QuestionSum is NoulQuestion. +func (s QuestionSum) IsNoulQuestion() bool { return s.Type == NoulQuestionQuestionSum } + +// IsChoiceQuestion reports whether QuestionSum is ChoiceQuestion. +func (s QuestionSum) IsChoiceQuestion() bool { return s.Type == ChoiceQuestionQuestionSum } + +// IsScoreQuestion reports whether QuestionSum is ScoreQuestion. +func (s QuestionSum) IsScoreQuestion() bool { return s.Type == ScoreQuestionQuestionSum } + +// SetNoulQuestion sets QuestionSum to NoulQuestion. +func (s *QuestionSum) SetNoulQuestion(v NoulQuestion) { + s.Type = NoulQuestionQuestionSum + s.NoulQuestion = v +} + +// GetNoulQuestion returns NoulQuestion and true boolean if QuestionSum is NoulQuestion. +func (s QuestionSum) GetNoulQuestion() (v NoulQuestion, ok bool) { + if !s.IsNoulQuestion() { + return v, false + } + return s.NoulQuestion, true +} + +// NewNoulQuestionQuestionSum returns new QuestionSum from NoulQuestion. +func NewNoulQuestionQuestionSum(v NoulQuestion) QuestionSum { + var s QuestionSum + s.SetNoulQuestion(v) + return s +} + +// SetChoiceQuestion sets QuestionSum to ChoiceQuestion. +func (s *QuestionSum) SetChoiceQuestion(v ChoiceQuestion) { + s.Type = ChoiceQuestionQuestionSum + s.ChoiceQuestion = v +} + +// GetChoiceQuestion returns ChoiceQuestion and true boolean if QuestionSum is ChoiceQuestion. +func (s QuestionSum) GetChoiceQuestion() (v ChoiceQuestion, ok bool) { + if !s.IsChoiceQuestion() { + return v, false + } + return s.ChoiceQuestion, true +} + +// NewChoiceQuestionQuestionSum returns new QuestionSum from ChoiceQuestion. +func NewChoiceQuestionQuestionSum(v ChoiceQuestion) QuestionSum { + var s QuestionSum + s.SetChoiceQuestion(v) + return s +} + +// SetScoreQuestion sets QuestionSum to ScoreQuestion. +func (s *QuestionSum) SetScoreQuestion(v ScoreQuestion) { + s.Type = ScoreQuestionQuestionSum + s.ScoreQuestion = v +} + +// GetScoreQuestion returns ScoreQuestion and true boolean if QuestionSum is ScoreQuestion. +func (s QuestionSum) GetScoreQuestion() (v ScoreQuestion, ok bool) { + if !s.IsScoreQuestion() { + return v, false + } + return s.ScoreQuestion, true +} + +// NewScoreQuestionQuestionSum returns new QuestionSum from ScoreQuestion. +func NewScoreQuestionQuestionSum(v ScoreQuestion) QuestionSum { + var s QuestionSum + s.SetScoreQuestion(v) + return s +} + +// Questions keyed by caller-chosen IDs. Empty, whitespace and long IDs are accepted without an +// identifier-length limit, and are preserved exactly in answers. IDs associate answers with +// questions and are not evaluated as input text. All questions evaluate the same state independently; +// +// they do not form a conversation. Object key order is not an answer-order guarantee: look up +// +// answers by ID. At least one question is required. +// Ref: #/components/schemas/Questions +type Questions map[string]Question + +func (s *Questions) init() Questions { + m := *s + if m == nil { + m = map[string]Question{} + *s = m + } + return m +} + +// Probability-weighted score over the supplied ordered levels. +// Ref: #/components/schemas/ScoreAnswer +type ScoreAnswer struct { + // Answer type; matches the question type. + Type ScoreAnswerType `json:"type"` + // Sum(i * p_i), bounded by [0, N-1]; may be fractional and is not normalized. + Score ScoreValue `json:"score"` + // Keys "0" through "N-1" map to the original level descriptions, retaining string/object/array + // shapes. + Legend ScoreAnswerLegend `json:"legend"` + // Keys "0" through "N-1", including zero probabilities; values sum to 1. + Probabilities ScoreAnswerProbabilities `json:"probabilities"` + // Confidence in the score, from 0 to 1 inclusive. Its calculation depends on the model. + Confidence Probability `json:"confidence"` +} + +// GetType returns the value of Type. +func (s *ScoreAnswer) GetType() ScoreAnswerType { + return s.Type +} + +// GetScore returns the value of Score. +func (s *ScoreAnswer) GetScore() ScoreValue { + return s.Score +} + +// GetLegend returns the value of Legend. +func (s *ScoreAnswer) GetLegend() ScoreAnswerLegend { + return s.Legend +} + +// GetProbabilities returns the value of Probabilities. +func (s *ScoreAnswer) GetProbabilities() ScoreAnswerProbabilities { + return s.Probabilities +} + +// GetConfidence returns the value of Confidence. +func (s *ScoreAnswer) GetConfidence() Probability { + return s.Confidence +} + +// SetType sets the value of Type. +func (s *ScoreAnswer) SetType(val ScoreAnswerType) { + s.Type = val +} + +// SetScore sets the value of Score. +func (s *ScoreAnswer) SetScore(val ScoreValue) { + s.Score = val +} + +// SetLegend sets the value of Legend. +func (s *ScoreAnswer) SetLegend(val ScoreAnswerLegend) { + s.Legend = val +} + +// SetProbabilities sets the value of Probabilities. +func (s *ScoreAnswer) SetProbabilities(val ScoreAnswerProbabilities) { + s.Probabilities = val +} + +// SetConfidence sets the value of Confidence. +func (s *ScoreAnswer) SetConfidence(val Probability) { + s.Confidence = val +} + +// Keys "0" through "N-1" map to the original level descriptions, retaining string/object/array +// shapes. +type ScoreAnswerLegend map[string]Instructions + +func (s *ScoreAnswerLegend) init() ScoreAnswerLegend { + m := *s + if m == nil { + m = map[string]Instructions{} + *s = m + } + return m +} + +// Keys "0" through "N-1", including zero probabilities; values sum to 1. +type ScoreAnswerProbabilities map[string]Probability + +func (s *ScoreAnswerProbabilities) init() ScoreAnswerProbabilities { + m := *s + if m == nil { + m = map[string]Probability{} + *s = m + } + return m +} + +// Answer type; matches the question type. +type ScoreAnswerType string + +const ( + ScoreAnswerTypeScore ScoreAnswerType = "score" +) + +// AllValues returns all ScoreAnswerType values. +func (ScoreAnswerType) AllValues() []ScoreAnswerType { + return []ScoreAnswerType{ + ScoreAnswerTypeScore, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s ScoreAnswerType) MarshalText() ([]byte, error) { + switch s { + case ScoreAnswerTypeScore: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *ScoreAnswerType) UnmarshalText(data []byte) error { + switch ScoreAnswerType(data) { + case ScoreAnswerTypeScore: + *s = ScoreAnswerTypeScore + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +type ScoreCriteria []Instructions + +// A scoring question over an ordered list of levels. +// Ref: #/components/schemas/ScoreQuestion +type ScoreQuestion struct { + // Question type. Use score for a probability-weighted level index. + Type ScoreQuestionType `json:"type"` + // Optional evaluation instructions. Omitted or null uses the model's defaults. Use instructions to + // define what increasing levels mean. + Instructions OptNullableInstructions `json:"instructions"` + // Ordered score levels. Required; 1-10 levels per question, inclusive. The first level has index 0. + Criteria ScoreCriteria `json:"criteria"` +} + +// GetType returns the value of Type. +func (s *ScoreQuestion) GetType() ScoreQuestionType { + return s.Type +} + +// GetInstructions returns the value of Instructions. +func (s *ScoreQuestion) GetInstructions() OptNullableInstructions { + return s.Instructions +} + +// GetCriteria returns the value of Criteria. +func (s *ScoreQuestion) GetCriteria() ScoreCriteria { + return s.Criteria +} + +// SetType sets the value of Type. +func (s *ScoreQuestion) SetType(val ScoreQuestionType) { + s.Type = val +} + +// SetInstructions sets the value of Instructions. +func (s *ScoreQuestion) SetInstructions(val OptNullableInstructions) { + s.Instructions = val +} + +// SetCriteria sets the value of Criteria. +func (s *ScoreQuestion) SetCriteria(val ScoreCriteria) { + s.Criteria = val +} + +// Question type. Use score for a probability-weighted level index. +type ScoreQuestionType string + +const ( + ScoreQuestionTypeScore ScoreQuestionType = "score" +) + +// AllValues returns all ScoreQuestionType values. +func (ScoreQuestionType) AllValues() []ScoreQuestionType { + return []ScoreQuestionType{ + ScoreQuestionTypeScore, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s ScoreQuestionType) MarshalText() ([]byte, error) { + switch s { + case ScoreQuestionTypeScore: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *ScoreQuestionType) UnmarshalText(data []byte) error { + switch ScoreQuestionType(data) { + case ScoreQuestionTypeScore: + *s = ScoreQuestionTypeScore + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +type ScoreValue float64 + +// Shared evaluation context: string, JSON object, string array, business-object array or multimedia +// array. Top-level null and arrays containing numbers, booleans, null, nested arrays, or mixed +// strings/objects are not accepted. An empty array is valid and is treated as empty text. If any +// object in the top-level array explicitly declares type=text/image/video/audio, every item must be +// a valid multimedia element; source field names alone do not select multimedia validation. Nested +// JSON within business objects is preserved; wrap arbitrary business arrays in a top-level object to +// evaluate them as structured text. +// Ref: #/components/schemas/State +// State represents sum type. +type State struct { + Type StateType // switch on this field + String string + JSONObject JSONObject + StateArray StateArray +} + +// StateType is oneOf type of State. +type StateType string + +// Possible values for StateType. +const ( + StringState StateType = "string" + JSONObjectState StateType = "JSONObject" + StateArrayState StateType = "StateArray" +) + +// IsString reports whether State is string. +func (s State) IsString() bool { return s.Type == StringState } + +// IsJSONObject reports whether State is JSONObject. +func (s State) IsJSONObject() bool { return s.Type == JSONObjectState } + +// IsStateArray reports whether State is StateArray. +func (s State) IsStateArray() bool { return s.Type == StateArrayState } + +// SetString sets State to string. +func (s *State) SetString(v string) { + s.Type = StringState + s.String = v +} + +// GetString returns string and true boolean if State is string. +func (s State) GetString() (v string, ok bool) { + if !s.IsString() { + return v, false + } + return s.String, true +} + +// NewStringState returns new State from string. +func NewStringState(v string) State { + var s State + s.SetString(v) + return s +} + +// SetJSONObject sets State to JSONObject. +func (s *State) SetJSONObject(v JSONObject) { + s.Type = JSONObjectState + s.JSONObject = v +} + +// GetJSONObject returns JSONObject and true boolean if State is JSONObject. +func (s State) GetJSONObject() (v JSONObject, ok bool) { + if !s.IsJSONObject() { + return v, false + } + return s.JSONObject, true +} + +// NewJSONObjectState returns new State from JSONObject. +func NewJSONObjectState(v JSONObject) State { + var s State + s.SetJSONObject(v) + return s +} + +// SetStateArray sets State to StateArray. +func (s *State) SetStateArray(v StateArray) { + s.Type = StateArrayState + s.StateArray = v +} + +// GetStateArray returns StateArray and true boolean if State is StateArray. +func (s State) GetStateArray() (v StateArray, ok bool) { + if !s.IsStateArray() { + return v, false + } + return s.StateArray, true +} + +// NewStateArrayState returns new State from StateArray. +func NewStateArrayState(v StateArray) State { + var s State + s.SetStateArray(v) + return s +} + +type StateArray []StateArrayItem + +// Ref: #/components/schemas/StateArrayItem +// StateArrayItem represents sum type. +type StateArrayItem struct { + Type StateArrayItemType // switch on this field + String string + JSONObject JSONObject +} + +// StateArrayItemType is oneOf type of StateArrayItem. +type StateArrayItemType string + +// Possible values for StateArrayItemType. +const ( + StringStateArrayItem StateArrayItemType = "string" + JSONObjectStateArrayItem StateArrayItemType = "JSONObject" +) + +// IsString reports whether StateArrayItem is string. +func (s StateArrayItem) IsString() bool { return s.Type == StringStateArrayItem } + +// IsJSONObject reports whether StateArrayItem is JSONObject. +func (s StateArrayItem) IsJSONObject() bool { return s.Type == JSONObjectStateArrayItem } + +// SetString sets StateArrayItem to string. +func (s *StateArrayItem) SetString(v string) { + s.Type = StringStateArrayItem + s.String = v +} + +// GetString returns string and true boolean if StateArrayItem is string. +func (s StateArrayItem) GetString() (v string, ok bool) { + if !s.IsString() { + return v, false + } + return s.String, true +} + +// NewStringStateArrayItem returns new StateArrayItem from string. +func NewStringStateArrayItem(v string) StateArrayItem { + var s StateArrayItem + s.SetString(v) + return s +} + +// SetJSONObject sets StateArrayItem to JSONObject. +func (s *StateArrayItem) SetJSONObject(v JSONObject) { + s.Type = JSONObjectStateArrayItem + s.JSONObject = v +} + +// GetJSONObject returns JSONObject and true boolean if StateArrayItem is JSONObject. +func (s StateArrayItem) GetJSONObject() (v JSONObject, ok bool) { + if !s.IsJSONObject() { + return v, false + } + return s.JSONObject, true +} + +// NewJSONObjectStateArrayItem returns new StateArrayItem from JSONObject. +func NewJSONObjectStateArrayItem(v JSONObject) StateArrayItem { + var s StateArrayItem + s.SetJSONObject(v) + return s +} + +type SystemOneEvaluateArkBetaSystemoneAPI string + +const ( + SystemOneEvaluateArkBetaSystemoneAPITrue SystemOneEvaluateArkBetaSystemoneAPI = "true" +) + +// AllValues returns all SystemOneEvaluateArkBetaSystemoneAPI values. +func (SystemOneEvaluateArkBetaSystemoneAPI) AllValues() []SystemOneEvaluateArkBetaSystemoneAPI { + return []SystemOneEvaluateArkBetaSystemoneAPI{ + SystemOneEvaluateArkBetaSystemoneAPITrue, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s SystemOneEvaluateArkBetaSystemoneAPI) MarshalText() ([]byte, error) { + switch s { + case SystemOneEvaluateArkBetaSystemoneAPITrue: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *SystemOneEvaluateArkBetaSystemoneAPI) UnmarshalText(data []byte) error { + switch SystemOneEvaluateArkBetaSystemoneAPI(data) { + case SystemOneEvaluateArkBetaSystemoneAPITrue: + *s = SystemOneEvaluateArkBetaSystemoneAPITrue + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +type SystemOneEvaluateBadRequest ErrorResponseHeaders + +func (*SystemOneEvaluateBadRequest) systemOneEvaluateRes() {} + +type SystemOneEvaluateCode499 ErrorResponseHeaders + +func (*SystemOneEvaluateCode499) systemOneEvaluateRes() {} + +type SystemOneEvaluateInternalServerError ErrorResponseHeaders + +func (*SystemOneEvaluateInternalServerError) systemOneEvaluateRes() {} + +type SystemOneEvaluateNotFound ErrorResponseHeaders + +func (*SystemOneEvaluateNotFound) systemOneEvaluateRes() {} + +type SystemOneEvaluateRequestTimeout ErrorResponseHeaders + +func (*SystemOneEvaluateRequestTimeout) systemOneEvaluateRes() {} + +type SystemOneEvaluateServiceUnavailable ErrorResponseHeaders + +func (*SystemOneEvaluateServiceUnavailable) systemOneEvaluateRes() {} + +type SystemOneEvaluateTooManyRequests ErrorResponseHeaders + +func (*SystemOneEvaluateTooManyRequests) systemOneEvaluateRes() {} + +type SystemOneEvaluateUnauthorized ErrorResponseHeaders + +func (*SystemOneEvaluateUnauthorized) systemOneEvaluateRes() {} + +// Evaluate several questions against one shared state. Model-specific text, request-size and context +// limits apply. When an aggregate text-byte limit applies, it counts decoded UTF-8 strings and +// compact JSON objects/arrays across state text, all instructions and criteria. Shared state is +// counted once; media references, Base64, model and question IDs are excluded from that text total. +// Request-size limits include encoded media in the JSON body and are separate from decoded media +// limits and model token budgets. Send a UTF-8 encoded JSON object. Invalid JSON syntax returns 400 +// / InvalidParameter with param="body format". A failed request returns one error instead of partial +// answers. +// Ref: #/components/schemas/SystemOneRequest +type SystemOneRequest struct { + // Model ID or Endpoint ID with System One capability. Use an ID available to your account in the + // selected region; third-party aliases are not automatically mapped. A model without this capability + // returns 400 / InvalidParameter with param=model. Missing or inaccessible models can return 404; + // access denied at the API entry can return 403. Merely supporting Chat or Responses does not imply + // System One support. + Model ModelID `json:"model"` + // Shared text, structured data or multimedia to evaluate. Required; an empty string, array or object + // is accepted, while null is not. Top-level arrays must contain only strings or only objects. In + // object arrays, an explicit type=text/image/video/audio selects multimedia validation for the whole + // array. Source keys such as file_id or image_url alone remain business data. + State State `json:"state"` + // Named questions to evaluate against state. Required and nonempty. + Questions Questions `json:"questions"` +} + +// GetModel returns the value of Model. +func (s *SystemOneRequest) GetModel() ModelID { + return s.Model +} + +// GetState returns the value of State. +func (s *SystemOneRequest) GetState() State { + return s.State +} + +// GetQuestions returns the value of Questions. +func (s *SystemOneRequest) GetQuestions() Questions { + return s.Questions +} + +// SetModel sets the value of Model. +func (s *SystemOneRequest) SetModel(val ModelID) { + s.Model = val +} + +// SetState sets the value of State. +func (s *SystemOneRequest) SetState(val State) { + s.State = val +} + +// SetQuestions sets the value of Questions. +func (s *SystemOneRequest) SetQuestions(val Questions) { + s.Questions = val +} + +// Complete synchronous evaluation result. No partial-success answer envelope is returned. +// Ref: #/components/schemas/SystemOneResponse +type SystemOneResponse struct { + // Public identifier of the model that performed the evaluation, including its version. This can + // differ from the requested model alias or Endpoint ID; it is not an echo of an ep- identifier. + Model ModelID `json:"model"` + // Exactly the request question IDs, each with its matching answer type. + Answers SystemOneResponseAnswers `json:"answers"` + // Token usage for this evaluation. + Usage Usage `json:"usage"` +} + +// GetModel returns the value of Model. +func (s *SystemOneResponse) GetModel() ModelID { + return s.Model +} + +// GetAnswers returns the value of Answers. +func (s *SystemOneResponse) GetAnswers() SystemOneResponseAnswers { + return s.Answers +} + +// GetUsage returns the value of Usage. +func (s *SystemOneResponse) GetUsage() Usage { + return s.Usage +} + +// SetModel sets the value of Model. +func (s *SystemOneResponse) SetModel(val ModelID) { + s.Model = val +} + +// SetAnswers sets the value of Answers. +func (s *SystemOneResponse) SetAnswers(val SystemOneResponseAnswers) { + s.Answers = val +} + +// SetUsage sets the value of Usage. +func (s *SystemOneResponse) SetUsage(val Usage) { + s.Usage = val +} + +// Exactly the request question IDs, each with its matching answer type. +type SystemOneResponseAnswers map[string]Answer + +func (s *SystemOneResponseAnswers) init() SystemOneResponseAnswers { + m := *s + if m == nil { + m = map[string]Answer{} + *s = m + } + return m +} + +// SystemOneResponseHeaders wraps SystemOneResponse with response headers. +type SystemOneResponseHeaders struct { + XRequestID string + Response SystemOneResponse +} + +// GetXRequestID returns the value of XRequestID. +func (s *SystemOneResponseHeaders) GetXRequestID() string { + return s.XRequestID +} + +// GetResponse returns the value of Response. +func (s *SystemOneResponseHeaders) GetResponse() SystemOneResponse { + return s.Response +} + +// SetXRequestID sets the value of XRequestID. +func (s *SystemOneResponseHeaders) SetXRequestID(val string) { + s.XRequestID = val +} + +// SetResponse sets the value of Response. +func (s *SystemOneResponseHeaders) SetResponse(val SystemOneResponse) { + s.Response = val +} + +func (*SystemOneResponseHeaders) systemOneEvaluateRes() {} + +type TokenCount int64 + +// Token usage for the complete evaluation. Clients must tolerate additional usage fields added in +// future versions. Zero can also mean the model did not supply a count for that field; it does not +// establish that the evaluation is free. These counts alone do not specify prices or discounts; +// consult the selected model pricing. +// Ref: #/components/schemas/Usage +type Usage struct { + // Total input tokens reported for this evaluation, including cached input tokens when measured. This + // is not a character count; shared context may contribute to multiple question evaluations. + InputTokens TokenCount `json:"input_tokens"` + // Output tokens reported for the complete evaluation. Not the number of bytes in the JSON response. + OutputTokens TokenCount `json:"output_tokens"` +} + +// GetInputTokens returns the value of InputTokens. +func (s *Usage) GetInputTokens() TokenCount { + return s.InputTokens +} + +// GetOutputTokens returns the value of OutputTokens. +func (s *Usage) GetOutputTokens() TokenCount { + return s.OutputTokens +} + +// SetInputTokens sets the value of InputTokens. +func (s *Usage) SetInputTokens(val TokenCount) { + s.InputTokens = val +} + +// SetOutputTokens sets the value of OutputTokens. +func (s *Usage) SetOutputTokens(val TokenCount) { + s.OutputTokens = val +} diff --git a/arkruntime/model/systemone/oas_validators_gen.go b/arkruntime/model/systemone/oas_validators_gen.go new file mode 100644 index 0000000..42c72f0 --- /dev/null +++ b/arkruntime/model/systemone/oas_validators_gen.go @@ -0,0 +1,988 @@ +// Copyright (c) 2026 ByteDance Ltd. and/or its affiliates. +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by ogen, DO NOT EDIT. + +package systemone + +import ( + "fmt" + + "github.com/go-faster/errors" + "github.com/volcengine/ark-runtime-go/arkruntime/internal/validate" +) + +func (s *Answer) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.OneOf.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "OneOf", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s AnswerSum) Validate() error { + switch s.Type { + case NoulAnswerAnswerSum: + if err := s.NoulAnswer.Validate(); err != nil { + return err + } + return nil + case ChoiceAnswerAnswerSum: + if err := s.ChoiceAnswer.Validate(); err != nil { + return err + } + return nil + case ScoreAnswerAnswerSum: + if err := s.ScoreAnswer.Validate(); err != nil { + return err + } + return nil + default: + return errors.Errorf("invalid type %q", s.Type) + } +} + +func (s *ChoiceAnswer) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if err := func() error { + if err := s.Probabilities.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "probabilities", + Error: err, + }) + } + if err := func() error { + if err := s.Confidence.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "confidence", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ChoiceAnswerProbabilities) Validate() error { + var failures []validate.FieldError + for key, elem := range s { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: key, + Error: err, + }) + } + } + + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ChoiceAnswerType) Validate() error { + switch s { + case "choice": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s ChoiceCriteria) Validate() error { + var failures []validate.FieldError + for key, elem := range s { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: key, + Error: err, + }) + } + } + + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ChoiceDescription) Validate() error { + switch s.Type { + case StringChoiceDescription: + return nil // no validation needed + case JSONObjectChoiceDescription: + return nil // no validation needed + case AnyArrayChoiceDescription: + if s.AnyArray == nil { + return errors.New("nil is invalid value") + } + return nil + case NullChoiceDescription: + return nil // no validation needed + default: + return errors.Errorf("invalid type %q", s.Type) + } +} + +func (s *ChoiceQuestion) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Instructions.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "instructions", + Error: err, + }) + } + if err := func() error { + if err := s.Criteria.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "criteria", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ChoiceQuestionType) Validate() error { + switch s { + case "choice": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s Instructions) Validate() error { + switch s.Type { + case StringInstructions: + return nil // no validation needed + case JSONObjectInstructions: + return nil // no validation needed + case AnyArrayInstructions: + if s.AnyArray == nil { + return errors.New("nil is invalid value") + } + return nil + default: + return errors.Errorf("invalid type %q", s.Type) + } +} + +func (s ModelID) Validate() error { + alias := (string)(s) + if err := (validate.String{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 0, + MaxLengthSet: false, + Email: false, + Hostname: false, + Regex: regexMap["\\S"], + MinNumeric: 0, + MinNumericSet: false, + MaxNumeric: 0, + MaxNumericSet: false, + }).Validate(string(alias)); err != nil { + return errors.Wrap(err, "string") + } + return nil +} + +func (s *NoulAnswer) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if err := func() error { + if err := s.Noul.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "noul", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s NoulAnswerType) Validate() error { + switch s { + case "noul": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *NoulCriteria) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if value, ok := s.True.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "true", + Error: err, + }) + } + if err := func() error { + if value, ok := s.False.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "false", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *NoulQuestion) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Instructions.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "instructions", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Criteria.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "criteria", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s NoulQuestionType) Validate() error { + switch s { + case "noul": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s NullableInstructions) Validate() error { + switch s.Type { + case StringNullableInstructions: + return nil // no validation needed + case JSONObjectNullableInstructions: + return nil // no validation needed + case AnyArrayNullableInstructions: + if s.AnyArray == nil { + return errors.New("nil is invalid value") + } + return nil + case NullNullableInstructions: + return nil // no validation needed + default: + return errors.Errorf("invalid type %q", s.Type) + } +} + +func (s Probability) Validate() error { + alias := (float64)(s) + if err := (validate.Float{ + MinSet: true, + Min: 0, + MaxSet: true, + Max: 1, + MinExclusive: false, + MaxExclusive: false, + MultipleOfSet: false, + MultipleOf: nil, + Pattern: nil, + }).Validate(float64(alias)); err != nil { + return errors.Wrap(err, "float") + } + return nil +} + +func (s *Question) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.OneOf.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "OneOf", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s QuestionSum) Validate() error { + switch s.Type { + case NoulQuestionQuestionSum: + if err := s.NoulQuestion.Validate(); err != nil { + return err + } + return nil + case ChoiceQuestionQuestionSum: + if err := s.ChoiceQuestion.Validate(); err != nil { + return err + } + return nil + case ScoreQuestionQuestionSum: + if err := s.ScoreQuestion.Validate(); err != nil { + return err + } + return nil + default: + return errors.Errorf("invalid type %q", s.Type) + } +} + +func (s Questions) Validate() error { + var failures []validate.FieldError + for key, elem := range s { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: key, + Error: err, + }) + } + } + + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *ScoreAnswer) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if err := func() error { + if err := s.Score.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "score", + Error: err, + }) + } + if err := func() error { + if err := s.Legend.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "legend", + Error: err, + }) + } + if err := func() error { + if err := s.Probabilities.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "probabilities", + Error: err, + }) + } + if err := func() error { + if err := s.Confidence.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "confidence", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ScoreAnswerLegend) Validate() error { + var failures []validate.FieldError + for key, elem := range s { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: key, + Error: err, + }) + } + } + + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ScoreAnswerProbabilities) Validate() error { + var failures []validate.FieldError + for key, elem := range s { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: key, + Error: err, + }) + } + } + + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ScoreAnswerType) Validate() error { + switch s { + case "score": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s ScoreCriteria) Validate() error { + alias := ([]Instructions)(s) + if alias == nil { + return errors.New("nil is invalid value") + } + if err := (validate.Array{ + MinLength: 1, + MinLengthSet: true, + MaxLength: 10, + MaxLengthSet: true, + }).ValidateLength(len(alias)); err != nil { + return errors.Wrap(err, "array") + } + var failures []validate.FieldError + for i, elem := range alias { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *ScoreQuestion) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Instructions.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "instructions", + Error: err, + }) + } + if err := func() error { + if err := s.Criteria.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "criteria", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ScoreQuestionType) Validate() error { + switch s { + case "score": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s ScoreValue) Validate() error { + alias := (float64)(s) + if err := (validate.Float{ + MinSet: true, + Min: 0, + MaxSet: false, + Max: 0, + MinExclusive: false, + MaxExclusive: false, + MultipleOfSet: false, + MultipleOf: nil, + Pattern: nil, + }).Validate(float64(alias)); err != nil { + return errors.Wrap(err, "float") + } + return nil +} + +func (s State) Validate() error { + switch s.Type { + case StringState: + return nil // no validation needed + case JSONObjectState: + return nil // no validation needed + case StateArrayState: + if err := s.StateArray.Validate(); err != nil { + return err + } + return nil + default: + return errors.Errorf("invalid type %q", s.Type) + } +} + +func (s StateArray) Validate() error { + if err := s.validateHomogeneity(); err != nil { + return err + } + alias := ([]StateArrayItem)(s) + if alias == nil { + return errors.New("nil is invalid value") + } + return nil +} + +func (s SystemOneEvaluateArkBetaSystemoneAPI) Validate() error { + switch s { + case "true": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *SystemOneRequest) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Model.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "model", + Error: err, + }) + } + if err := func() error { + if err := s.State.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "state", + Error: err, + }) + } + if err := func() error { + if err := s.Questions.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "questions", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *SystemOneResponse) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Model.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "model", + Error: err, + }) + } + if err := func() error { + if err := s.Answers.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "answers", + Error: err, + }) + } + if err := func() error { + if err := s.Usage.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "usage", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s SystemOneResponseAnswers) Validate() error { + var failures []validate.FieldError + for key, elem := range s { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: key, + Error: err, + }) + } + } + + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s *SystemOneResponseHeaders) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Response.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "Response", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s TokenCount) Validate() error { + alias := (int64)(s) + if err := (validate.Int{ + MinSet: true, + Min: 0, + MaxSet: false, + Max: 0, + MinExclusive: false, + MaxExclusive: false, + MultipleOfSet: false, + MultipleOf: 0, + Pattern: nil, + }).Validate(int64(alias)); err != nil { + return errors.Wrap(err, "int") + } + return nil +} + +func (s *Usage) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.InputTokens.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "input_tokens", + Error: err, + }) + } + if err := func() error { + if err := s.OutputTokens.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "output_tokens", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} diff --git a/arkruntime/model/systemone/systemone_state_gen.go b/arkruntime/model/systemone/systemone_state_gen.go new file mode 100644 index 0000000..4c8e699 --- /dev/null +++ b/arkruntime/model/systemone/systemone_state_gen.go @@ -0,0 +1,17 @@ +// Copyright (c) 2026 ByteDance Ltd. and/or its affiliates. +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by gen/go/systemone.py. DO NOT EDIT. +package systemone + +import "fmt" + +// The public State schema permits string[] or JSONObject[], never a mixture. +func (s StateArray) validateHomogeneity() error { + for i, item := range s { + if i > 0 && item.Type != s[0].Type { + return fmt.Errorf("state[%d]: cannot mix text strings and objects", i) + } + } + return nil +}