Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 0.1.0-alpha.49 #179

Merged
merged 4 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.48"
".": "0.1.0-alpha.49"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 68
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-b5b0e2c794b012919701c3fd43286af10fa25d33ceb8a881bec2636028f446e0.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-3904ef6b29a89c98f93a9b7da19879695f3c440564be6384db7af1b734611ede.yml
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 0.1.0-alpha.49 (2025-01-22)

Full Changelog: [v0.1.0-alpha.48...v0.1.0-alpha.49](https://github.com/openai/openai-go/compare/v0.1.0-alpha.48...v0.1.0-alpha.49)

### Features

* **api:** update enum values, comments, and examples ([#181](https://github.com/openai/openai-go/issues/181)) ([a074981](https://github.com/openai/openai-go/commit/a07498136304d74bd706684341fb9dcce6e8075c))
* Minor text change: Update readme to say beta instead of alpha ([2b766ab](https://github.com/openai/openai-go/commit/2b766ab7054cb649d40db0e7ac50c370e070043f))
* support deprecated markers ([#178](https://github.com/openai/openai-go/issues/178)) ([3d6f52f](https://github.com/openai/openai-go/commit/3d6f52f0f5b30f1f064cfbba8f61d28c1094bb0a))

## 0.1.0-alpha.48 (2025-01-21)

Full Changelog: [v0.1.0-alpha.47...v0.1.0-alpha.48](https://github.com/openai/openai-go/compare/v0.1.0-alpha.47...v0.1.0-alpha.48)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<a href="https://pkg.go.dev/github.com/openai/openai-go"><img src="https://pkg.go.dev/badge/github.com/openai/openai-go.svg" alt="Go Reference"></a>

> [!WARNING]
> **This release is currently in alpha**. Minor breaking changes may occur.
> **This release is currently in beta**. Minor breaking changes may occur.

The OpenAI Go library provides convenient access to [the OpenAI REST
API](https://platform.openai.com/docs) from applications written in Go. The full API of this library can be found in [api.md](api.md).
Expand All @@ -25,7 +25,7 @@ Or to pin the version:
<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/openai/openai-go@v0.1.0-alpha.48'
go get -u 'github.com/openai/openai-go@v0.1.0-alpha.49'
```

<!-- x-release-please-end -->
Expand Down
17 changes: 10 additions & 7 deletions audiospeech.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ type AudioSpeechNewParams struct {
// One of the available [TTS models](https://platform.openai.com/docs/models#tts):
// `tts-1` or `tts-1-hd`
Model param.Field[SpeechModel] `json:"model,required"`
// The voice to use when generating the audio. Supported voices are `alloy`,
// `echo`, `fable`, `onyx`, `nova`, and `shimmer`. Previews of the voices are
// available in the
// The voice to use when generating the audio. Supported voices are `alloy`, `ash`,
// `coral`, `echo`, `fable`, `onyx`, `nova`, `sage` and `shimmer`. Previews of the
// voices are available in the
// [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
Voice param.Field[AudioSpeechNewParamsVoice] `json:"voice,required"`
// The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`,
Expand All @@ -70,24 +70,27 @@ func (r AudioSpeechNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

// The voice to use when generating the audio. Supported voices are `alloy`,
// `echo`, `fable`, `onyx`, `nova`, and `shimmer`. Previews of the voices are
// available in the
// The voice to use when generating the audio. Supported voices are `alloy`, `ash`,
// `coral`, `echo`, `fable`, `onyx`, `nova`, `sage` and `shimmer`. Previews of the
// voices are available in the
// [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
type AudioSpeechNewParamsVoice string

const (
AudioSpeechNewParamsVoiceAlloy AudioSpeechNewParamsVoice = "alloy"
AudioSpeechNewParamsVoiceAsh AudioSpeechNewParamsVoice = "ash"
AudioSpeechNewParamsVoiceCoral AudioSpeechNewParamsVoice = "coral"
AudioSpeechNewParamsVoiceEcho AudioSpeechNewParamsVoice = "echo"
AudioSpeechNewParamsVoiceFable AudioSpeechNewParamsVoice = "fable"
AudioSpeechNewParamsVoiceOnyx AudioSpeechNewParamsVoice = "onyx"
AudioSpeechNewParamsVoiceNova AudioSpeechNewParamsVoice = "nova"
AudioSpeechNewParamsVoiceSage AudioSpeechNewParamsVoice = "sage"
AudioSpeechNewParamsVoiceShimmer AudioSpeechNewParamsVoice = "shimmer"
)

func (r AudioSpeechNewParamsVoice) IsKnown() bool {
switch r {
case AudioSpeechNewParamsVoiceAlloy, AudioSpeechNewParamsVoiceEcho, AudioSpeechNewParamsVoiceFable, AudioSpeechNewParamsVoiceOnyx, AudioSpeechNewParamsVoiceNova, AudioSpeechNewParamsVoiceShimmer:
case AudioSpeechNewParamsVoiceAlloy, AudioSpeechNewParamsVoiceAsh, AudioSpeechNewParamsVoiceCoral, AudioSpeechNewParamsVoiceEcho, AudioSpeechNewParamsVoiceFable, AudioSpeechNewParamsVoiceOnyx, AudioSpeechNewParamsVoiceNova, AudioSpeechNewParamsVoiceSage, AudioSpeechNewParamsVoiceShimmer:
return true
}
return false
Expand Down
22 changes: 11 additions & 11 deletions betathread.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (r AssistantToolChoiceFunctionParam) MarshalJSON() (data []byte, err error)
// `{"type": "function", "function": {"name": "my_function"}}` forces the model to
// call that tool.
//
// Union satisfied by [AssistantToolChoiceOptionBehavior] or [AssistantToolChoice].
// Union satisfied by [AssistantToolChoiceOptionAuto] or [AssistantToolChoice].
type AssistantToolChoiceOptionUnion interface {
implementsAssistantToolChoiceOptionUnion()
}
Expand All @@ -229,7 +229,7 @@ func init() {
"",
apijson.UnionVariant{
TypeFilter: gjson.String,
Type: reflect.TypeOf(AssistantToolChoiceOptionBehavior("")),
Type: reflect.TypeOf(AssistantToolChoiceOptionAuto("")),
},
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Expand All @@ -242,25 +242,25 @@ func init() {
// `auto` means the model can pick between generating a message or calling one or
// more tools. `required` means the model must call one or more tools before
// responding to the user.
type AssistantToolChoiceOptionBehavior string
type AssistantToolChoiceOptionAuto string

const (
AssistantToolChoiceOptionBehaviorNone AssistantToolChoiceOptionBehavior = "none"
AssistantToolChoiceOptionBehaviorAuto AssistantToolChoiceOptionBehavior = "auto"
AssistantToolChoiceOptionBehaviorRequired AssistantToolChoiceOptionBehavior = "required"
AssistantToolChoiceOptionAutoNone AssistantToolChoiceOptionAuto = "none"
AssistantToolChoiceOptionAutoAuto AssistantToolChoiceOptionAuto = "auto"
AssistantToolChoiceOptionAutoRequired AssistantToolChoiceOptionAuto = "required"
)

func (r AssistantToolChoiceOptionBehavior) IsKnown() bool {
func (r AssistantToolChoiceOptionAuto) IsKnown() bool {
switch r {
case AssistantToolChoiceOptionBehaviorNone, AssistantToolChoiceOptionBehaviorAuto, AssistantToolChoiceOptionBehaviorRequired:
case AssistantToolChoiceOptionAutoNone, AssistantToolChoiceOptionAutoAuto, AssistantToolChoiceOptionAutoRequired:
return true
}
return false
}

func (r AssistantToolChoiceOptionBehavior) implementsAssistantToolChoiceOptionUnion() {}
func (r AssistantToolChoiceOptionAuto) implementsAssistantToolChoiceOptionUnion() {}

func (r AssistantToolChoiceOptionBehavior) implementsAssistantToolChoiceOptionUnionParam() {}
func (r AssistantToolChoiceOptionAuto) implementsAssistantToolChoiceOptionUnionParam() {}

// Controls which (if any) tool is called by the model. `none` means the model will
// not call any tools and instead generates a message. `auto` is the default value
Expand All @@ -270,7 +270,7 @@ func (r AssistantToolChoiceOptionBehavior) implementsAssistantToolChoiceOptionUn
// `{"type": "function", "function": {"name": "my_function"}}` forces the model to
// call that tool.
//
// Satisfied by [AssistantToolChoiceOptionBehavior], [AssistantToolChoiceParam].
// Satisfied by [AssistantToolChoiceOptionAuto], [AssistantToolChoiceParam].
type AssistantToolChoiceOptionUnionParam interface {
implementsAssistantToolChoiceOptionUnionParam()
}
Expand Down
2 changes: 1 addition & 1 deletion betathread_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func TestBetaThreadNewAndRunWithOptionalParams(t *testing.T) {
}),
}),
}),
ToolChoice: openai.F[openai.AssistantToolChoiceOptionUnionParam](openai.AssistantToolChoiceOptionBehavior(openai.AssistantToolChoiceOptionBehaviorNone)),
ToolChoice: openai.F[openai.AssistantToolChoiceOptionUnionParam](openai.AssistantToolChoiceOptionAuto(openai.AssistantToolChoiceOptionAutoNone)),
ToolResources: openai.F(openai.BetaThreadNewAndRunParamsToolResources{
CodeInterpreter: openai.F(openai.BetaThreadNewAndRunParamsToolResourcesCodeInterpreter{
FileIDs: openai.F([]string{"string"}),
Expand Down
2 changes: 1 addition & 1 deletion betathreadrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestBetaThreadRunNewWithOptionalParams(t *testing.T) {
Model: openai.F(openai.ChatModelGPT4o),
ParallelToolCalls: openai.F(true),
Temperature: openai.F(1.000000),
ToolChoice: openai.F[openai.AssistantToolChoiceOptionUnionParam](openai.AssistantToolChoiceOptionBehavior(openai.AssistantToolChoiceOptionBehaviorNone)),
ToolChoice: openai.F[openai.AssistantToolChoiceOptionUnionParam](openai.AssistantToolChoiceOptionAuto(openai.AssistantToolChoiceOptionAutoNone)),
Tools: openai.F([]openai.AssistantToolUnionParam{openai.CodeInterpreterToolParam{
Type: openai.F(openai.CodeInterpreterToolTypeCodeInterpreter),
}}),
Expand Down
65 changes: 35 additions & 30 deletions chatcompletion.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ type ChatCompletion struct {
Model string `json:"model,required"`
// The object type, which is always `chat.completion`.
Object ChatCompletionObject `json:"object,required"`
// The service tier used for processing the request. This field is only included if
// the `service_tier` parameter is specified in the request.
// The service tier used for processing the request.
ServiceTier ChatCompletionServiceTier `json:"service_tier,nullable"`
// This fingerprint represents the backend configuration that the model runs with.
//
Expand Down Expand Up @@ -293,8 +292,7 @@ func (r ChatCompletionObject) IsKnown() bool {
return false
}

// The service tier used for processing the request. This field is only included if
// the `service_tier` parameter is specified in the request.
// The service tier used for processing the request.
type ChatCompletionServiceTier string

const (
Expand Down Expand Up @@ -322,6 +320,8 @@ type ChatCompletionAssistantMessageParam struct {
Content param.Field[[]ChatCompletionAssistantMessageParamContentUnion] `json:"content"`
// Deprecated and replaced by `tool_calls`. The name and arguments of a function
// that should be called, as generated by the model.
//
// Deprecated: deprecated
FunctionCall param.Field[ChatCompletionAssistantMessageParamFunctionCall] `json:"function_call"`
// An optional name for the participant. Provides the model information to
// differentiate between participants of the same role.
Expand Down Expand Up @@ -410,6 +410,8 @@ func (r ChatCompletionAssistantMessageParamContentType) IsKnown() bool {

// Deprecated and replaced by `tool_calls`. The name and arguments of a function
// that should be called, as generated by the model.
//
// Deprecated: deprecated
type ChatCompletionAssistantMessageParamFunctionCall struct {
// The arguments to call the function with, as generated by the model in JSON
// format. Note that the model does not always generate valid JSON, and may
Expand Down Expand Up @@ -537,8 +539,7 @@ type ChatCompletionChunk struct {
Model string `json:"model,required"`
// The object type, which is always `chat.completion.chunk`.
Object ChatCompletionChunkObject `json:"object,required"`
// The service tier used for processing the request. This field is only included if
// the `service_tier` parameter is specified in the request.
// The service tier used for processing the request.
ServiceTier ChatCompletionChunkServiceTier `json:"service_tier,nullable"`
// This fingerprint represents the backend configuration that the model runs with.
// Can be used in conjunction with the `seed` request parameter to understand when
Expand Down Expand Up @@ -617,6 +618,8 @@ type ChatCompletionChunkChoicesDelta struct {
Content string `json:"content,nullable"`
// Deprecated and replaced by `tool_calls`. The name and arguments of a function
// that should be called, as generated by the model.
//
// Deprecated: deprecated
FunctionCall ChatCompletionChunkChoicesDeltaFunctionCall `json:"function_call"`
// The refusal message generated by the model.
Refusal string `json:"refusal,nullable"`
Expand Down Expand Up @@ -648,6 +651,8 @@ func (r chatCompletionChunkChoicesDeltaJSON) RawJSON() string {

// Deprecated and replaced by `tool_calls`. The name and arguments of a function
// that should be called, as generated by the model.
//
// Deprecated: deprecated
type ChatCompletionChunkChoicesDeltaFunctionCall struct {
// The arguments to call the function with, as generated by the model in JSON
// format. Note that the model does not always generate valid JSON, and may
Expand Down Expand Up @@ -831,8 +836,7 @@ func (r ChatCompletionChunkObject) IsKnown() bool {
return false
}

// The service tier used for processing the request. This field is only included if
// the `service_tier` parameter is specified in the request.
// The service tier used for processing the request.
type ChatCompletionChunkServiceTier string

const (
Expand Down Expand Up @@ -1114,6 +1118,7 @@ func (r ChatCompletionFunctionCallOptionParam) MarshalJSON() (data []byte, err e

func (r ChatCompletionFunctionCallOptionParam) implementsChatCompletionNewParamsFunctionCallUnion() {}

// Deprecated: deprecated
type ChatCompletionFunctionMessageParam struct {
// The contents of the function message.
Content param.Field[string] `json:"content,required"`
Expand Down Expand Up @@ -1158,6 +1163,8 @@ type ChatCompletionMessage struct {
Audio ChatCompletionAudio `json:"audio,nullable"`
// Deprecated and replaced by `tool_calls`. The name and arguments of a function
// that should be called, as generated by the model.
//
// Deprecated: deprecated
FunctionCall ChatCompletionMessageFunctionCall `json:"function_call"`
// The tool calls generated by the model, such as function calls.
ToolCalls []ChatCompletionMessageToolCall `json:"tool_calls"`
Expand Down Expand Up @@ -1227,6 +1234,8 @@ func (r ChatCompletionMessageRole) IsKnown() bool {

// Deprecated and replaced by `tool_calls`. The name and arguments of a function
// that should be called, as generated by the model.
//
// Deprecated: deprecated
type ChatCompletionMessageFunctionCall struct {
// The arguments to call the function with, as generated by the model in JSON
// format. Note that the model does not always generate valid JSON, and may
Expand Down Expand Up @@ -1674,7 +1683,7 @@ func (r ChatCompletionToolType) IsKnown() bool {
// `none` is the default when no tools are present. `auto` is the default if tools
// are present.
//
// Satisfied by [ChatCompletionToolChoiceOptionBehavior],
// Satisfied by [ChatCompletionToolChoiceOptionAuto],
// [ChatCompletionNamedToolChoiceParam].
type ChatCompletionToolChoiceOptionUnionParam interface {
implementsChatCompletionToolChoiceOptionUnionParam()
Expand All @@ -1683,24 +1692,23 @@ type ChatCompletionToolChoiceOptionUnionParam interface {
// `none` means the model will not call any tool and instead generates a message.
// `auto` means the model can pick between generating a message or calling one or
// more tools. `required` means the model must call one or more tools.
type ChatCompletionToolChoiceOptionBehavior string
type ChatCompletionToolChoiceOptionAuto string

const (
ChatCompletionToolChoiceOptionBehaviorNone ChatCompletionToolChoiceOptionBehavior = "none"
ChatCompletionToolChoiceOptionBehaviorAuto ChatCompletionToolChoiceOptionBehavior = "auto"
ChatCompletionToolChoiceOptionBehaviorRequired ChatCompletionToolChoiceOptionBehavior = "required"
ChatCompletionToolChoiceOptionAutoNone ChatCompletionToolChoiceOptionAuto = "none"
ChatCompletionToolChoiceOptionAutoAuto ChatCompletionToolChoiceOptionAuto = "auto"
ChatCompletionToolChoiceOptionAutoRequired ChatCompletionToolChoiceOptionAuto = "required"
)

func (r ChatCompletionToolChoiceOptionBehavior) IsKnown() bool {
func (r ChatCompletionToolChoiceOptionAuto) IsKnown() bool {
switch r {
case ChatCompletionToolChoiceOptionBehaviorNone, ChatCompletionToolChoiceOptionBehaviorAuto, ChatCompletionToolChoiceOptionBehaviorRequired:
case ChatCompletionToolChoiceOptionAutoNone, ChatCompletionToolChoiceOptionAutoAuto, ChatCompletionToolChoiceOptionAutoRequired:
return true
}
return false
}

func (r ChatCompletionToolChoiceOptionBehavior) implementsChatCompletionToolChoiceOptionUnionParam() {
}
func (r ChatCompletionToolChoiceOptionAuto) implementsChatCompletionToolChoiceOptionUnionParam() {}

type ChatCompletionToolMessageParam struct {
// The contents of the tool message.
Expand Down Expand Up @@ -1900,9 +1908,6 @@ type ChatCompletionNewParams struct {
// - If set to 'default', the request will be processed using the default service
// tier with a lower uptime SLA and no latency guarentee.
// - When not set, the default behavior is 'auto'.
//
// When this parameter is set, the response body will include the `service_tier`
// utilized.
ServiceTier param.Field[ChatCompletionNewParamsServiceTier] `json:"service_tier"`
// Up to 4 sequences where the API will stop generating further tokens.
Stop param.Field[ChatCompletionNewParamsStopUnion] `json:"stop"`
Expand Down Expand Up @@ -1966,33 +1971,36 @@ func (r ChatCompletionNewParams) MarshalJSON() (data []byte, err error) {
// `none` is the default when no functions are present. `auto` is the default if
// functions are present.
//
// Satisfied by [ChatCompletionNewParamsFunctionCallBehavior],
// Satisfied by [ChatCompletionNewParamsFunctionCallAuto],
// [ChatCompletionFunctionCallOptionParam].
//
// Deprecated: deprecated
type ChatCompletionNewParamsFunctionCallUnion interface {
implementsChatCompletionNewParamsFunctionCallUnion()
}

// `none` means the model will not call a function and instead generates a message.
// `auto` means the model can pick between generating a message or calling a
// function.
type ChatCompletionNewParamsFunctionCallBehavior string
type ChatCompletionNewParamsFunctionCallAuto string

const (
ChatCompletionNewParamsFunctionCallBehaviorNone ChatCompletionNewParamsFunctionCallBehavior = "none"
ChatCompletionNewParamsFunctionCallBehaviorAuto ChatCompletionNewParamsFunctionCallBehavior = "auto"
ChatCompletionNewParamsFunctionCallAutoNone ChatCompletionNewParamsFunctionCallAuto = "none"
ChatCompletionNewParamsFunctionCallAutoAuto ChatCompletionNewParamsFunctionCallAuto = "auto"
)

func (r ChatCompletionNewParamsFunctionCallBehavior) IsKnown() bool {
func (r ChatCompletionNewParamsFunctionCallAuto) IsKnown() bool {
switch r {
case ChatCompletionNewParamsFunctionCallBehaviorNone, ChatCompletionNewParamsFunctionCallBehaviorAuto:
case ChatCompletionNewParamsFunctionCallAutoNone, ChatCompletionNewParamsFunctionCallAutoAuto:
return true
}
return false
}

func (r ChatCompletionNewParamsFunctionCallBehavior) implementsChatCompletionNewParamsFunctionCallUnion() {
func (r ChatCompletionNewParamsFunctionCallAuto) implementsChatCompletionNewParamsFunctionCallUnion() {
}

// Deprecated: deprecated
type ChatCompletionNewParamsFunction struct {
// The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
// underscores and dashes, with a maximum length of 64.
Expand Down Expand Up @@ -2097,9 +2105,6 @@ func (r ChatCompletionNewParamsResponseFormatType) IsKnown() bool {
// - If set to 'default', the request will be processed using the default service
// tier with a lower uptime SLA and no latency guarentee.
// - When not set, the default behavior is 'auto'.
//
// When this parameter is set, the response body will include the `service_tier`
// utilized.
type ChatCompletionNewParamsServiceTier string

const (
Expand Down
Loading
Loading