|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +package together |
| 4 | + |
| 5 | +import ( |
| 6 | + "context" |
| 7 | + "net/http" |
| 8 | + "slices" |
| 9 | + |
| 10 | + "github.com/togethercomputer/together-go/internal/apijson" |
| 11 | + "github.com/togethercomputer/together-go/internal/requestconfig" |
| 12 | + "github.com/togethercomputer/together-go/option" |
| 13 | + "github.com/togethercomputer/together-go/packages/respjson" |
| 14 | +) |
| 15 | + |
| 16 | +// AudioVoiceService contains methods and other services that help with interacting |
| 17 | +// with the together API. |
| 18 | +// |
| 19 | +// Note, unlike clients, this service does not read variables from the environment |
| 20 | +// automatically. You should not instantiate this service directly, and instead use |
| 21 | +// the [NewAudioVoiceService] method instead. |
| 22 | +type AudioVoiceService struct { |
| 23 | + Options []option.RequestOption |
| 24 | +} |
| 25 | + |
| 26 | +// NewAudioVoiceService generates a new service that applies the given options to |
| 27 | +// each request. These options are applied after the parent client's options (if |
| 28 | +// there is one), and before any request-specific options. |
| 29 | +func NewAudioVoiceService(opts ...option.RequestOption) (r AudioVoiceService) { |
| 30 | + r = AudioVoiceService{} |
| 31 | + r.Options = opts |
| 32 | + return |
| 33 | +} |
| 34 | + |
| 35 | +// Fetch available voices for each model |
| 36 | +func (r *AudioVoiceService) List(ctx context.Context, opts ...option.RequestOption) (res *AudioVoiceListResponse, err error) { |
| 37 | + opts = slices.Concat(r.Options, opts) |
| 38 | + path := "voices" |
| 39 | + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) |
| 40 | + return |
| 41 | +} |
| 42 | + |
| 43 | +// Response containing a list of models and their available voices. |
| 44 | +type AudioVoiceListResponse struct { |
| 45 | + Data []AudioVoiceListResponseData `json:"data,required"` |
| 46 | + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. |
| 47 | + JSON struct { |
| 48 | + Data respjson.Field |
| 49 | + ExtraFields map[string]respjson.Field |
| 50 | + raw string |
| 51 | + } `json:"-"` |
| 52 | +} |
| 53 | + |
| 54 | +// Returns the unmodified JSON received from the API |
| 55 | +func (r AudioVoiceListResponse) RawJSON() string { return r.JSON.raw } |
| 56 | +func (r *AudioVoiceListResponse) UnmarshalJSON(data []byte) error { |
| 57 | + return apijson.UnmarshalRoot(data, r) |
| 58 | +} |
| 59 | + |
| 60 | +// Represents a model with its available voices. |
| 61 | +type AudioVoiceListResponseData struct { |
| 62 | + Model string `json:"model,required"` |
| 63 | + Voices []AudioVoiceListResponseDataVoice `json:"voices,required"` |
| 64 | + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. |
| 65 | + JSON struct { |
| 66 | + Model respjson.Field |
| 67 | + Voices respjson.Field |
| 68 | + ExtraFields map[string]respjson.Field |
| 69 | + raw string |
| 70 | + } `json:"-"` |
| 71 | +} |
| 72 | + |
| 73 | +// Returns the unmodified JSON received from the API |
| 74 | +func (r AudioVoiceListResponseData) RawJSON() string { return r.JSON.raw } |
| 75 | +func (r *AudioVoiceListResponseData) UnmarshalJSON(data []byte) error { |
| 76 | + return apijson.UnmarshalRoot(data, r) |
| 77 | +} |
| 78 | + |
| 79 | +type AudioVoiceListResponseDataVoice struct { |
| 80 | + ID string `json:"id,required"` |
| 81 | + Name string `json:"name,required"` |
| 82 | + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. |
| 83 | + JSON struct { |
| 84 | + ID respjson.Field |
| 85 | + Name respjson.Field |
| 86 | + ExtraFields map[string]respjson.Field |
| 87 | + raw string |
| 88 | + } `json:"-"` |
| 89 | +} |
| 90 | + |
| 91 | +// Returns the unmodified JSON received from the API |
| 92 | +func (r AudioVoiceListResponseDataVoice) RawJSON() string { return r.JSON.raw } |
| 93 | +func (r *AudioVoiceListResponseDataVoice) UnmarshalJSON(data []byte) error { |
| 94 | + return apijson.UnmarshalRoot(data, r) |
| 95 | +} |
0 commit comments