Skip to content

Commit 47ca619

Browse files
feat(api): Updating Assistants and Evals API schemas
1 parent 11f5716 commit 47ca619

15 files changed

+627
-533
lines changed

.stats.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 87
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-161ca7f1cfd7b33c1fc07d0ce25dfe4be5a7271c394f4cb526b7fb21b0729900.yml
3-
openapi_spec_hash: 602e14add4bee018c6774e320ce309b8
4-
config_hash: bdacc55eb995c15255ec82130eb8c3bb
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-5fa16b9a02985ae06e41be14946a9c325dc672fb014b3c19abca65880c6990e6.yml
3+
openapi_spec_hash: da3e669f65130043b1170048c0727890
4+
config_hash: d8d5fda350f6db77c784f35429741a2e

aliases.go

+3-64
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ const ChatModelGPT4oMiniSearchPreview2025_03_11 = shared.ChatModelGPT4oMiniSearc
115115
// Equals "chatgpt-4o-latest"
116116
const ChatModelChatgpt4oLatest = shared.ChatModelChatgpt4oLatest
117117

118+
// Equals "codex-mini-latest"
119+
const ChatModelCodexMiniLatest = shared.ChatModelCodexMiniLatest
120+
118121
// Equals "gpt-4o-mini"
119122
const ChatModelGPT4oMini = shared.ChatModelGPT4oMini
120123

@@ -256,70 +259,6 @@ type CompoundFilterParam = shared.CompoundFilterParam
256259
// This is an alias to an internal type.
257260
type ErrorObject = shared.ErrorObject
258261

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-
323262
// This is an alias to an internal type.
324263
type FunctionDefinition = shared.FunctionDefinition
325264

api.md

-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
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>
76
- <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>
87
- <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>
98
- <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>
@@ -20,7 +19,6 @@
2019
- <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>
2120
- <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>
2221
- <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>
2422
- <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>
2523
- <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>
2624
- <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>
@@ -332,7 +330,6 @@ Params Types:
332330
- <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>
333331
- <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>
334332
- <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>
336333

337334
Response Types:
338335

@@ -342,7 +339,6 @@ Response Types:
342339
- <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>
343340
- <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>
344341
- <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>
346342
- <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>
347343

348344
Methods:
@@ -421,7 +417,6 @@ Params Types:
421417
- <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>
422418
- <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>
423419
- <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>
425420

426421
Response Types:
427422

@@ -431,7 +426,6 @@ Response Types:
431426
- <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>
432427
- <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>
433428
- <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>
435429

436430
Methods:
437431

betaassistant.go

+1-1
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 TruncationObject `json:"truncation_strategy"`
630+
TruncationStrategy RunTruncationStrategy `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

+35-77
Original file line numberDiff line numberDiff line change
@@ -560,80 +560,6 @@ 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-
637563
type BetaThreadNewParams struct {
638564
// Set of 16 key-value pairs that can be attached to an object. This can be useful
639565
// for storing additional information about the object in a structured format, and
@@ -1131,6 +1057,9 @@ type BetaThreadNewAndRunParams struct {
11311057
// Override the tools the assistant can use for this run. This is useful for
11321058
// modifying the behavior on a per-run basis.
11331059
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"`
11341063
// Specifies the format that the model must output. Compatible with
11351064
// [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
11361065
// [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
@@ -1163,9 +1092,6 @@ type BetaThreadNewAndRunParams struct {
11631092
// `{"type": "function", "function": {"name": "my_function"}}` forces the model to
11641093
// call that tool.
11651094
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"`
11691095
paramObj
11701096
}
11711097

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

+2-2
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.TruncationObjectParam{
237-
Type: openai.TruncationObjectTypeAuto,
236+
TruncationStrategy: openai.BetaThreadNewAndRunParamsTruncationStrategy{
237+
Type: "auto",
238238
LastMessages: openai.Int(1),
239239
},
240240
})

0 commit comments

Comments
 (0)