Skip to content

release: 0.1.0-beta.7 #351

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

Merged
merged 3 commits into from
Apr 7, 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-beta.6"
".": "0.1.0-beta.7"
}
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 0.1.0-beta.7 (2025-04-07)

Full Changelog: [v0.1.0-beta.6...v0.1.0-beta.7](https://github.com/openai/openai-go/compare/v0.1.0-beta.6...v0.1.0-beta.7)

### Features

* **client:** make response union's AsAny method type safe ([#352](https://github.com/openai/openai-go/issues/352)) ([1252f56](https://github.com/openai/openai-go/commit/1252f56c917e57d6d2b031501b2ff5f89f87cf87))


### Chores

* **docs:** doc improvements ([#350](https://github.com/openai/openai-go/issues/350)) ([80debc8](https://github.com/openai/openai-go/commit/80debc824eaacb4b07c8f3e8b1d0488d860d5be5))

## 0.1.0-beta.6 (2025-04-04)

Full Changelog: [v0.1.0-beta.5...v0.1.0-beta.6](https://github.com/openai/openai-go/compare/v0.1.0-beta.5...v0.1.0-beta.6)
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ To set up the repository, run:

```sh
$ ./scripts/bootstrap
$ ./scripts/build
$ ./scripts/lint
```

This will install all the required dependencies and build the SDK.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Or to pin the version:
<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/openai/[email protected].6'
go get -u 'github.com/openai/[email protected].7'
```

<!-- x-release-please-end -->
Expand Down
14 changes: 13 additions & 1 deletion audiotranscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ type TranscriptionStreamEventUnion struct {
} `json:"-"`
}

// anyTranscriptionStreamEvent is implemented by each variant of
// [TranscriptionStreamEventUnion] to add type safety for the return type of
// [TranscriptionStreamEventUnion.AsAny]
type anyTranscriptionStreamEvent interface {
implTranscriptionStreamEventUnion()
}

func (TranscriptionTextDeltaEvent) implTranscriptionStreamEventUnion() {}
func (TranscriptionTextDoneEvent) implTranscriptionStreamEventUnion() {}

// Use the following switch statement to find the correct variant
//
// switch variant := TranscriptionStreamEventUnion.AsAny().(type) {
Expand All @@ -148,7 +158,7 @@ type TranscriptionStreamEventUnion struct {
// default:
// fmt.Errorf("no variant present")
// }
func (u TranscriptionStreamEventUnion) AsAny() any {
func (u TranscriptionStreamEventUnion) AsAny() anyTranscriptionStreamEvent {
switch u.Type {
case "transcript.text.delta":
return u.AsTranscriptTextDelta()
Expand Down Expand Up @@ -352,6 +362,8 @@ type AudioTranscriptionNewParams struct {
// Either or both of these options are supported: `word`, or `segment`. Note: There
// is no additional latency for segment timestamps, but generating word timestamps
// incurs additional latency.
//
// Any of "word", "segment".
TimestampGranularities []string `json:"timestamp_granularities,omitzero"`
paramObj
}
Expand Down
46 changes: 44 additions & 2 deletions betaassistant.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,38 @@ type AssistantStreamEventUnion struct {
} `json:"-"`
}

// anyAssistantStreamEvent is implemented by each variant of
// [AssistantStreamEventUnion] to add type safety for the return type of
// [AssistantStreamEventUnion.AsAny]
type anyAssistantStreamEvent interface {
implAssistantStreamEventUnion()
}

func (AssistantStreamEventThreadCreated) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadRunCreated) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadRunQueued) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadRunInProgress) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadRunRequiresAction) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadRunCompleted) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadRunIncomplete) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadRunFailed) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadRunCancelling) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadRunCancelled) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadRunExpired) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadRunStepCreated) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadRunStepInProgress) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadRunStepDelta) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadRunStepCompleted) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadRunStepFailed) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadRunStepCancelled) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadRunStepExpired) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadMessageCreated) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadMessageInProgress) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadMessageDelta) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadMessageCompleted) implAssistantStreamEventUnion() {}
func (AssistantStreamEventThreadMessageIncomplete) implAssistantStreamEventUnion() {}
func (AssistantStreamEventErrorEvent) implAssistantStreamEventUnion() {}

// Use the following switch statement to find the correct variant
//
// switch variant := AssistantStreamEventUnion.AsAny().(type) {
Expand Down Expand Up @@ -374,7 +406,7 @@ type AssistantStreamEventUnion struct {
// default:
// fmt.Errorf("no variant present")
// }
func (u AssistantStreamEventUnion) AsAny() any {
func (u AssistantStreamEventUnion) AsAny() anyAssistantStreamEvent {
switch u.Event {
case "thread.created":
return u.AsThreadCreated()
Expand Down Expand Up @@ -1347,6 +1379,16 @@ type AssistantToolUnion struct {
} `json:"-"`
}

// anyAssistantTool is implemented by each variant of [AssistantToolUnion] to add
// type safety for the return type of [AssistantToolUnion.AsAny]
type anyAssistantTool interface {
implAssistantToolUnion()
}

func (CodeInterpreterTool) implAssistantToolUnion() {}
func (FileSearchTool) implAssistantToolUnion() {}
func (FunctionTool) implAssistantToolUnion() {}

// Use the following switch statement to find the correct variant
//
// switch variant := AssistantToolUnion.AsAny().(type) {
Expand All @@ -1356,7 +1398,7 @@ type AssistantToolUnion struct {
// default:
// fmt.Errorf("no variant present")
// }
func (u AssistantToolUnion) AsAny() any {
func (u AssistantToolUnion) AsAny() anyAssistantTool {
switch u.Type {
case "code_interpreter":
return u.AsCodeInterpreter()
Expand Down
49 changes: 45 additions & 4 deletions betathreadmessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@ type AnnotationUnion struct {
} `json:"-"`
}

// anyAnnotation is implemented by each variant of [AnnotationUnion] to add type
// safety for the return type of [AnnotationUnion.AsAny]
type anyAnnotation interface {
implAnnotationUnion()
}

func (FileCitationAnnotation) implAnnotationUnion() {}
func (FilePathAnnotation) implAnnotationUnion() {}

// Use the following switch statement to find the correct variant
//
// switch variant := AnnotationUnion.AsAny().(type) {
Expand All @@ -168,7 +177,7 @@ type AnnotationUnion struct {
// default:
// fmt.Errorf("no variant present")
// }
func (u AnnotationUnion) AsAny() any {
func (u AnnotationUnion) AsAny() anyAnnotation {
switch u.Type {
case "file_citation":
return u.AsFileCitation()
Expand Down Expand Up @@ -224,6 +233,15 @@ type AnnotationDeltaUnion struct {
} `json:"-"`
}

// anyAnnotationDelta is implemented by each variant of [AnnotationDeltaUnion] to
// add type safety for the return type of [AnnotationDeltaUnion.AsAny]
type anyAnnotationDelta interface {
implAnnotationDeltaUnion()
}

func (FileCitationDeltaAnnotation) implAnnotationDeltaUnion() {}
func (FilePathDeltaAnnotation) implAnnotationDeltaUnion() {}

// Use the following switch statement to find the correct variant
//
// switch variant := AnnotationDeltaUnion.AsAny().(type) {
Expand All @@ -232,7 +250,7 @@ type AnnotationDeltaUnion struct {
// default:
// fmt.Errorf("no variant present")
// }
func (u AnnotationDeltaUnion) AsAny() any {
func (u AnnotationDeltaUnion) AsAny() anyAnnotationDelta {
switch u.Type {
case "file_citation":
return u.AsFileCitation()
Expand Down Expand Up @@ -1022,6 +1040,17 @@ type MessageContentUnion struct {
} `json:"-"`
}

// anyMessageContent is implemented by each variant of [MessageContentUnion] to add
// type safety for the return type of [MessageContentUnion.AsAny]
type anyMessageContent interface {
implMessageContentUnion()
}

func (ImageFileContentBlock) implMessageContentUnion() {}
func (ImageURLContentBlock) implMessageContentUnion() {}
func (TextContentBlock) implMessageContentUnion() {}
func (RefusalContentBlock) implMessageContentUnion() {}

// Use the following switch statement to find the correct variant
//
// switch variant := MessageContentUnion.AsAny().(type) {
Expand All @@ -1032,7 +1061,7 @@ type MessageContentUnion struct {
// default:
// fmt.Errorf("no variant present")
// }
func (u MessageContentUnion) AsAny() any {
func (u MessageContentUnion) AsAny() anyMessageContent {
switch u.Type {
case "image_file":
return u.AsImageFile()
Expand Down Expand Up @@ -1103,6 +1132,18 @@ type MessageContentDeltaUnion struct {
} `json:"-"`
}

// anyMessageContentDelta is implemented by each variant of
// [MessageContentDeltaUnion] to add type safety for the return type of
// [MessageContentDeltaUnion.AsAny]
type anyMessageContentDelta interface {
implMessageContentDeltaUnion()
}

func (ImageFileDeltaBlock) implMessageContentDeltaUnion() {}
func (TextDeltaBlock) implMessageContentDeltaUnion() {}
func (RefusalDeltaBlock) implMessageContentDeltaUnion() {}
func (ImageURLDeltaBlock) implMessageContentDeltaUnion() {}

// Use the following switch statement to find the correct variant
//
// switch variant := MessageContentDeltaUnion.AsAny().(type) {
Expand All @@ -1113,7 +1154,7 @@ type MessageContentDeltaUnion struct {
// default:
// fmt.Errorf("no variant present")
// }
func (u MessageContentDeltaUnion) AsAny() any {
func (u MessageContentDeltaUnion) AsAny() anyMessageContentDelta {
switch u.Type {
case "image_file":
return u.AsImageFile()
Expand Down
Loading