Skip to content

Commit 11f5716

Browse files
feat(api): manual updates
1 parent 183aaf7 commit 11f5716

15 files changed

+529
-616
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 87
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-161ca7f1cfd7b33c1fc07d0ce25dfe4be5a7271c394f4cb526b7fb21b0729900.yml
33
openapi_spec_hash: 602e14add4bee018c6774e320ce309b8
4-
config_hash: 7da27f7260075e8813ddcea542fba1bf
4+
config_hash: bdacc55eb995c15255ec82130eb8c3bb

aliases.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,70 @@ type CompoundFilterParam = shared.CompoundFilterParam
256256
// This is an alias to an internal type.
257257
type ErrorObject = shared.ErrorObject
258258

259+
// A message input to the model with a role indicating instruction following
260+
// hierarchy. Instructions given with the `developer` or `system` role take
261+
// precedence over instructions given with the `user` role. Messages with the
262+
// `assistant` role are presumed to have been generated by the model in previous
263+
// interactions.
264+
//
265+
// This is an alias to an internal type.
266+
type EvalItem = shared.EvalItem
267+
268+
// Text inputs to the model - can contain template strings.
269+
//
270+
// This is an alias to an internal type.
271+
type EvalItemContentUnion = shared.EvalItemContentUnion
272+
273+
// A text output from the model.
274+
//
275+
// This is an alias to an internal type.
276+
type EvalItemContentOutputText = shared.EvalItemContentOutputText
277+
278+
// The role of the message input. One of `user`, `assistant`, `system`, or
279+
// `developer`.
280+
//
281+
// This is an alias to an internal type.
282+
type EvalItemRole = shared.EvalItemRole
283+
284+
// Equals "user"
285+
const EvalItemRoleUser = shared.EvalItemRoleUser
286+
287+
// Equals "assistant"
288+
const EvalItemRoleAssistant = shared.EvalItemRoleAssistant
289+
290+
// Equals "system"
291+
const EvalItemRoleSystem = shared.EvalItemRoleSystem
292+
293+
// Equals "developer"
294+
const EvalItemRoleDeveloper = shared.EvalItemRoleDeveloper
295+
296+
// The type of the message input. Always `message`.
297+
//
298+
// This is an alias to an internal type.
299+
type EvalItemType = shared.EvalItemType
300+
301+
// Equals "message"
302+
const EvalItemTypeMessage = shared.EvalItemTypeMessage
303+
304+
// A message input to the model with a role indicating instruction following
305+
// hierarchy. Instructions given with the `developer` or `system` role take
306+
// precedence over instructions given with the `user` role. Messages with the
307+
// `assistant` role are presumed to have been generated by the model in previous
308+
// interactions.
309+
//
310+
// This is an alias to an internal type.
311+
type EvalItemParam = shared.EvalItemParam
312+
313+
// Text inputs to the model - can contain template strings.
314+
//
315+
// This is an alias to an internal type.
316+
type EvalItemContentUnionParam = shared.EvalItemContentUnionParam
317+
318+
// A text output from the model.
319+
//
320+
// This is an alias to an internal type.
321+
type EvalItemContentOutputTextParam = shared.EvalItemContentOutputTextParam
322+
259323
// This is an alias to an internal type.
260324
type FunctionDefinition = shared.FunctionDefinition
261325

api.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#ChatModel">ChatModel</a>
44
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#ComparisonFilterParam">ComparisonFilterParam</a>
55
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#CompoundFilterParam">CompoundFilterParam</a>
6+
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#EvalItemParam">EvalItemParam</a>
67
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#FunctionDefinitionParam">FunctionDefinitionParam</a>
78
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#FunctionParameters">FunctionParameters</a>
89
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#Metadata">Metadata</a>
@@ -19,6 +20,7 @@
1920
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#ComparisonFilter">ComparisonFilter</a>
2021
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#CompoundFilter">CompoundFilter</a>
2122
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#ErrorObject">ErrorObject</a>
23+
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#EvalItem">EvalItem</a>
2224
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#FunctionDefinition">FunctionDefinition</a>
2325
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#FunctionParameters">FunctionParameters</a>
2426
- <a href="https://pkg.go.dev/github.com/openai/openai-go/shared">shared</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/shared#Metadata">Metadata</a>
@@ -330,6 +332,7 @@ Params Types:
330332
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#FileChunkingStrategyParamUnion">FileChunkingStrategyParamUnion</a>
331333
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#StaticFileChunkingStrategyParam">StaticFileChunkingStrategyParam</a>
332334
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#StaticFileChunkingStrategyObjectParam">StaticFileChunkingStrategyObjectParam</a>
335+
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#VectorStoreExpirationAfterParam">VectorStoreExpirationAfterParam</a>
333336

334337
Response Types:
335338

@@ -339,6 +342,7 @@ Response Types:
339342
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#StaticFileChunkingStrategyObject">StaticFileChunkingStrategyObject</a>
340343
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#VectorStore">VectorStore</a>
341344
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#VectorStoreDeleted">VectorStoreDeleted</a>
345+
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#VectorStoreExpirationAfter">VectorStoreExpirationAfter</a>
342346
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#VectorStoreSearchResponse">VectorStoreSearchResponse</a>
343347

344348
Methods:
@@ -417,6 +421,7 @@ Params Types:
417421
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#AssistantToolChoiceParam">AssistantToolChoiceParam</a>
418422
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#AssistantToolChoiceFunctionParam">AssistantToolChoiceFunctionParam</a>
419423
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#AssistantToolChoiceOptionUnionParam">AssistantToolChoiceOptionUnionParam</a>
424+
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#TruncationObjectParam">TruncationObjectParam</a>
420425

421426
Response Types:
422427

@@ -426,6 +431,7 @@ Response Types:
426431
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#AssistantToolChoiceOptionUnion">AssistantToolChoiceOptionUnion</a>
427432
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#Thread">Thread</a>
428433
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#ThreadDeleted">ThreadDeleted</a>
434+
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#TruncationObject">TruncationObject</a>
429435

430436
Methods:
431437

betaassistant.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ type AssistantStreamEventUnionData struct {
627627
// This field is from variant [Run].
628628
Tools []AssistantToolUnion `json:"tools"`
629629
// This field is from variant [Run].
630-
TruncationStrategy RunTruncationStrategy `json:"truncation_strategy"`
630+
TruncationStrategy TruncationObject `json:"truncation_strategy"`
631631
// This field is a union of [RunUsage], [RunStepUsage]
632632
Usage AssistantStreamEventUnionDataUsage `json:"usage"`
633633
// This field is from variant [Run].

betathread.go

Lines changed: 77 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,80 @@ func (r *ThreadDeleted) UnmarshalJSON(data []byte) error {
560560
return apijson.UnmarshalRoot(data, r)
561561
}
562562

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+
563637
type BetaThreadNewParams struct {
564638
// Set of 16 key-value pairs that can be attached to an object. This can be useful
565639
// for storing additional information about the object in a structured format, and
@@ -1057,9 +1131,6 @@ type BetaThreadNewAndRunParams struct {
10571131
// Override the tools the assistant can use for this run. This is useful for
10581132
// modifying the behavior on a per-run basis.
10591133
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"`
10631134
// Specifies the format that the model must output. Compatible with
10641135
// [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
10651136
// [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
@@ -1092,6 +1163,9 @@ type BetaThreadNewAndRunParams struct {
10921163
// `{"type": "function", "function": {"name": "my_function"}}` forces the model to
10931164
// call that tool.
10941165
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"`
10951169
paramObj
10961170
}
10971171

@@ -1523,35 +1597,3 @@ func (r BetaThreadNewAndRunParamsToolResourcesFileSearch) MarshalJSON() (data []
15231597
func (r *BetaThreadNewAndRunParamsToolResourcesFileSearch) UnmarshalJSON(data []byte) error {
15241598
return apijson.UnmarshalRoot(data, r)
15251599
}
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-
}

betathread_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ func TestBetaThreadNewAndRunWithOptionalParams(t *testing.T) {
233233
OfCodeInterpreter: &openai.CodeInterpreterToolParam{},
234234
}},
235235
TopP: openai.Float(1),
236-
TruncationStrategy: openai.BetaThreadNewAndRunParamsTruncationStrategy{
237-
Type: "auto",
236+
TruncationStrategy: openai.TruncationObjectParam{
237+
Type: openai.TruncationObjectTypeAuto,
238238
LastMessages: openai.Int(1),
239239
},
240240
})

0 commit comments

Comments
 (0)