Skip to content

Commit cd990a7

Browse files
release: 0.3.0 (#109)
* feat(files): add support for string alternative to file upload type * release: 0.3.0 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
1 parent fc89be0 commit cd990a7

File tree

8 files changed

+73
-9
lines changed

8 files changed

+73
-9
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.2.0"
2+
".": "0.3.0"
33
}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 0.3.0 (2025-12-16)
4+
5+
Full Changelog: [v0.2.0...v0.3.0](https://github.com/togethercomputer/together-go/compare/v0.2.0...v0.3.0)
6+
7+
### Features
8+
9+
* **files:** add support for string alternative to file upload type ([07c6a44](https://github.com/togethercomputer/together-go/commit/07c6a44da0e74c3331698b517cc5e26aec5461e4))
10+
311
## 0.2.0 (2025-12-15)
412

513
Full Changelog: [v0.1.0...v0.2.0](https://github.com/togethercomputer/together-go/compare/v0.1.0...v0.2.0)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Or to pin the version:
2828
<!-- x-release-please-start-version -->
2929

3030
```sh
31-
go get -u 'github.com/togethercomputer/together-go@v0.2.0'
31+
go get -u 'github.com/togethercomputer/together-go@v0.3.0'
3232
```
3333

3434
<!-- x-release-please-end -->

audiotranscription.go

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,9 @@ func (r *AudioTranscriptionNewResponseAudioTranscriptionVerboseJsonResponseWord)
277277
}
278278

279279
type AudioTranscriptionNewParams struct {
280-
// Audio file to transcribe
281-
File io.Reader `json:"file,omitzero,required" format:"binary"`
280+
// Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a,
281+
// .webm, .flac.
282+
File AudioTranscriptionNewParamsFileUnion `json:"file,omitzero,required" format:"binary"`
282283
// Whether to enable speaker diarization. When enabled, you will get the speaker id
283284
// for each word in the transcription. In the response, in the words array, you
284285
// will get the speaker id for each word. In addition, we also return the
@@ -336,6 +337,31 @@ func (r AudioTranscriptionNewParams) MarshalMultipart() (data []byte, contentTyp
336337
return buf.Bytes(), writer.FormDataContentType(), nil
337338
}
338339

340+
// Only one field can be non-zero.
341+
//
342+
// Use [param.IsOmitted] to confirm if a field is set.
343+
type AudioTranscriptionNewParamsFileUnion struct {
344+
OfFile io.Reader `json:",omitzero,inline"`
345+
OfString param.Opt[string] `json:",omitzero,inline"`
346+
paramUnion
347+
}
348+
349+
func (u AudioTranscriptionNewParamsFileUnion) MarshalJSON() ([]byte, error) {
350+
return param.MarshalUnion(u, u.OfFile, u.OfString)
351+
}
352+
func (u *AudioTranscriptionNewParamsFileUnion) UnmarshalJSON(data []byte) error {
353+
return apijson.UnmarshalRoot(data, u)
354+
}
355+
356+
func (u *AudioTranscriptionNewParamsFileUnion) asAny() any {
357+
if !param.IsOmitted(u.OfFile) {
358+
return &u.OfFile
359+
} else if !param.IsOmitted(u.OfString) {
360+
return &u.OfString.Value
361+
}
362+
return nil
363+
}
364+
339365
// Model to use for transcription
340366
type AudioTranscriptionNewParamsModel string
341367

audiotranscription_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ func TestAudioTranscriptionNewWithOptionalParams(t *testing.T) {
2828
option.WithAPIKey("My API Key"),
2929
)
3030
_, err := client.Audio.Transcriptions.New(context.TODO(), together.AudioTranscriptionNewParams{
31-
File: io.Reader(bytes.NewBuffer([]byte("some file contents"))),
31+
File: together.AudioTranscriptionNewParamsFileUnion{
32+
OfFile: io.Reader(bytes.NewBuffer([]byte("some file contents"))),
33+
},
3234
Diarize: together.Bool(true),
3335
Language: together.String("en"),
3436
MaxSpeakers: together.Int(0),

audiotranslation.go

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,9 @@ func (r *AudioTranslationNewResponseAudioTranslationVerboseJsonResponseWord) Unm
206206
}
207207

208208
type AudioTranslationNewParams struct {
209-
// Audio file to translate
210-
File io.Reader `json:"file,omitzero,required" format:"binary"`
209+
// Audio file upload or public HTTP/HTTPS URL. Supported formats .wav, .mp3, .m4a,
210+
// .webm, .flac.
211+
File AudioTranslationNewParamsFileUnion `json:"file,omitzero,required" format:"binary"`
211212
// Target output language. Optional ISO 639-1 language code. If omitted, language
212213
// is set to English.
213214
Language param.Opt[string] `json:"language,omitzero"`
@@ -248,6 +249,31 @@ func (r AudioTranslationNewParams) MarshalMultipart() (data []byte, contentType
248249
return buf.Bytes(), writer.FormDataContentType(), nil
249250
}
250251

252+
// Only one field can be non-zero.
253+
//
254+
// Use [param.IsOmitted] to confirm if a field is set.
255+
type AudioTranslationNewParamsFileUnion struct {
256+
OfFile io.Reader `json:",omitzero,inline"`
257+
OfString param.Opt[string] `json:",omitzero,inline"`
258+
paramUnion
259+
}
260+
261+
func (u AudioTranslationNewParamsFileUnion) MarshalJSON() ([]byte, error) {
262+
return param.MarshalUnion(u, u.OfFile, u.OfString)
263+
}
264+
func (u *AudioTranslationNewParamsFileUnion) UnmarshalJSON(data []byte) error {
265+
return apijson.UnmarshalRoot(data, u)
266+
}
267+
268+
func (u *AudioTranslationNewParamsFileUnion) asAny() any {
269+
if !param.IsOmitted(u.OfFile) {
270+
return &u.OfFile
271+
} else if !param.IsOmitted(u.OfString) {
272+
return &u.OfString.Value
273+
}
274+
return nil
275+
}
276+
251277
// Model to use for translation
252278
type AudioTranslationNewParamsModel string
253279

audiotranslation_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ func TestAudioTranslationNewWithOptionalParams(t *testing.T) {
2828
option.WithAPIKey("My API Key"),
2929
)
3030
_, err := client.Audio.Translations.New(context.TODO(), together.AudioTranslationNewParams{
31-
File: io.Reader(bytes.NewBuffer([]byte("some file contents"))),
31+
File: together.AudioTranslationNewParamsFileUnion{
32+
OfFile: io.Reader(bytes.NewBuffer([]byte("some file contents"))),
33+
},
3234
Language: together.String("en"),
3335
Model: together.AudioTranslationNewParamsModelOpenAIWhisperLargeV3,
3436
Prompt: together.String("prompt"),

internal/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
package internal
44

5-
const PackageVersion = "0.2.0" // x-release-please-version
5+
const PackageVersion = "0.3.0" // x-release-please-version

0 commit comments

Comments
 (0)