@@ -560,80 +560,6 @@ func (r *ThreadDeleted) UnmarshalJSON(data []byte) error {
560
560
return apijson .UnmarshalRoot (data , r )
561
561
}
562
562
563
- // Controls for how a thread will be truncated prior to the run. Use this to
564
- // control the intial context window of the run.
565
- type TruncationObject struct {
566
- // The truncation strategy to use for the thread. The default is `auto`. If set to
567
- // `last_messages`, the thread will be truncated to the n most recent messages in
568
- // the thread. When set to `auto`, messages in the middle of the thread will be
569
- // dropped to fit the context length of the model, `max_prompt_tokens`.
570
- //
571
- // Any of "auto", "last_messages".
572
- Type TruncationObjectType `json:"type,required"`
573
- // The number of most recent messages from the thread when constructing the context
574
- // for the run.
575
- LastMessages int64 `json:"last_messages,nullable"`
576
- // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
577
- JSON struct {
578
- Type respjson.Field
579
- LastMessages respjson.Field
580
- ExtraFields map [string ]respjson.Field
581
- raw string
582
- } `json:"-"`
583
- }
584
-
585
- // Returns the unmodified JSON received from the API
586
- func (r TruncationObject ) RawJSON () string { return r .JSON .raw }
587
- func (r * TruncationObject ) UnmarshalJSON (data []byte ) error {
588
- return apijson .UnmarshalRoot (data , r )
589
- }
590
-
591
- // ToParam converts this TruncationObject to a TruncationObjectParam.
592
- //
593
- // Warning: the fields of the param type will not be present. ToParam should only
594
- // be used at the last possible moment before sending a request. Test for this with
595
- // TruncationObjectParam.Overrides()
596
- func (r TruncationObject ) ToParam () TruncationObjectParam {
597
- return param.Override [TruncationObjectParam ](r .RawJSON ())
598
- }
599
-
600
- // The truncation strategy to use for the thread. The default is `auto`. If set to
601
- // `last_messages`, the thread will be truncated to the n most recent messages in
602
- // the thread. When set to `auto`, messages in the middle of the thread will be
603
- // dropped to fit the context length of the model, `max_prompt_tokens`.
604
- type TruncationObjectType string
605
-
606
- const (
607
- TruncationObjectTypeAuto TruncationObjectType = "auto"
608
- TruncationObjectTypeLastMessages TruncationObjectType = "last_messages"
609
- )
610
-
611
- // Controls for how a thread will be truncated prior to the run. Use this to
612
- // control the intial context window of the run.
613
- //
614
- // The property Type is required.
615
- type TruncationObjectParam struct {
616
- // The truncation strategy to use for the thread. The default is `auto`. If set to
617
- // `last_messages`, the thread will be truncated to the n most recent messages in
618
- // the thread. When set to `auto`, messages in the middle of the thread will be
619
- // dropped to fit the context length of the model, `max_prompt_tokens`.
620
- //
621
- // Any of "auto", "last_messages".
622
- Type TruncationObjectType `json:"type,omitzero,required"`
623
- // The number of most recent messages from the thread when constructing the context
624
- // for the run.
625
- LastMessages param.Opt [int64 ] `json:"last_messages,omitzero"`
626
- paramObj
627
- }
628
-
629
- func (r TruncationObjectParam ) MarshalJSON () (data []byte , err error ) {
630
- type shadow TruncationObjectParam
631
- return param .MarshalObject (r , (* shadow )(& r ))
632
- }
633
- func (r * TruncationObjectParam ) UnmarshalJSON (data []byte ) error {
634
- return apijson .UnmarshalRoot (data , r )
635
- }
636
-
637
563
type BetaThreadNewParams struct {
638
564
// Set of 16 key-value pairs that can be attached to an object. This can be useful
639
565
// for storing additional information about the object in a structured format, and
@@ -1131,6 +1057,9 @@ type BetaThreadNewAndRunParams struct {
1131
1057
// Override the tools the assistant can use for this run. This is useful for
1132
1058
// modifying the behavior on a per-run basis.
1133
1059
Tools []AssistantToolUnionParam `json:"tools,omitzero"`
1060
+ // Controls for how a thread will be truncated prior to the run. Use this to
1061
+ // control the intial context window of the run.
1062
+ TruncationStrategy BetaThreadNewAndRunParamsTruncationStrategy `json:"truncation_strategy,omitzero"`
1134
1063
// Specifies the format that the model must output. Compatible with
1135
1064
// [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
1136
1065
// [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
@@ -1163,9 +1092,6 @@ type BetaThreadNewAndRunParams struct {
1163
1092
// `{"type": "function", "function": {"name": "my_function"}}` forces the model to
1164
1093
// call that tool.
1165
1094
ToolChoice AssistantToolChoiceOptionUnionParam `json:"tool_choice,omitzero"`
1166
- // Controls for how a thread will be truncated prior to the run. Use this to
1167
- // control the intial context window of the run.
1168
- TruncationStrategy TruncationObjectParam `json:"truncation_strategy,omitzero"`
1169
1095
paramObj
1170
1096
}
1171
1097
@@ -1597,3 +1523,35 @@ func (r BetaThreadNewAndRunParamsToolResourcesFileSearch) MarshalJSON() (data []
1597
1523
func (r * BetaThreadNewAndRunParamsToolResourcesFileSearch ) UnmarshalJSON (data []byte ) error {
1598
1524
return apijson .UnmarshalRoot (data , r )
1599
1525
}
1526
+
1527
+ // Controls for how a thread will be truncated prior to the run. Use this to
1528
+ // control the intial context window of the run.
1529
+ //
1530
+ // The property Type is required.
1531
+ type BetaThreadNewAndRunParamsTruncationStrategy struct {
1532
+ // The truncation strategy to use for the thread. The default is `auto`. If set to
1533
+ // `last_messages`, the thread will be truncated to the n most recent messages in
1534
+ // the thread. When set to `auto`, messages in the middle of the thread will be
1535
+ // dropped to fit the context length of the model, `max_prompt_tokens`.
1536
+ //
1537
+ // Any of "auto", "last_messages".
1538
+ Type string `json:"type,omitzero,required"`
1539
+ // The number of most recent messages from the thread when constructing the context
1540
+ // for the run.
1541
+ LastMessages param.Opt [int64 ] `json:"last_messages,omitzero"`
1542
+ paramObj
1543
+ }
1544
+
1545
+ func (r BetaThreadNewAndRunParamsTruncationStrategy ) MarshalJSON () (data []byte , err error ) {
1546
+ type shadow BetaThreadNewAndRunParamsTruncationStrategy
1547
+ return param .MarshalObject (r , (* shadow )(& r ))
1548
+ }
1549
+ func (r * BetaThreadNewAndRunParamsTruncationStrategy ) UnmarshalJSON (data []byte ) error {
1550
+ return apijson .UnmarshalRoot (data , r )
1551
+ }
1552
+
1553
+ func init () {
1554
+ apijson .RegisterFieldValidator [BetaThreadNewAndRunParamsTruncationStrategy ](
1555
+ "type" , "auto" , "last_messages" ,
1556
+ )
1557
+ }
0 commit comments