together 2.0.0a8__py3-none-any.whl → 2.0.0a10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- together/_streaming.py +50 -48
- together/_types.py +3 -2
- together/_utils/_utils.py +1 -1
- together/_version.py +1 -1
- together/lib/cli/api/fine_tuning.py +65 -3
- together/lib/cli/api/models.py +1 -6
- together/lib/resources/fine_tuning.py +41 -2
- together/resources/audio/transcriptions.py +20 -0
- together/resources/chat/completions.py +48 -0
- together/resources/fine_tuning.py +213 -5
- together/resources/images.py +13 -1
- together/resources/models.py +41 -5
- together/types/__init__.py +3 -0
- together/types/audio/transcription_create_params.py +14 -0
- together/types/audio/voice_list_response.py +4 -0
- together/types/autoscaling.py +2 -0
- together/types/autoscaling_param.py +2 -0
- together/types/chat/completion_create_params.py +78 -5
- together/types/dedicated_endpoint.py +2 -0
- together/types/endpoint_list_avzones_response.py +2 -0
- together/types/endpoint_list_response.py +2 -0
- together/types/execute_response.py +7 -0
- together/types/fine_tuning_cancel_response.py +6 -0
- together/types/fine_tuning_estimate_price_params.py +98 -0
- together/types/fine_tuning_estimate_price_response.py +24 -0
- together/types/fine_tuning_list_response.py +6 -0
- together/types/hardware_list_response.py +8 -0
- together/types/image_generate_params.py +9 -0
- together/types/model_list_params.py +12 -0
- together/types/video_job.py +8 -0
- {together-2.0.0a8.dist-info → together-2.0.0a10.dist-info}/METADATA +11 -12
- {together-2.0.0a8.dist-info → together-2.0.0a10.dist-info}/RECORD +35 -33
- together/lib/resources/models.py +0 -35
- {together-2.0.0a8.dist-info → together-2.0.0a10.dist-info}/WHEEL +0 -0
- {together-2.0.0a8.dist-info → together-2.0.0a10.dist-info}/entry_points.txt +0 -0
- {together-2.0.0a8.dist-info → together-2.0.0a10.dist-info}/licenses/LICENSE +0 -0
|
@@ -7,7 +7,7 @@ from typing_extensions import Literal
|
|
|
7
7
|
import httpx
|
|
8
8
|
from rich import print as rprint
|
|
9
9
|
|
|
10
|
-
from ..types import fine_tuning_delete_params, fine_tuning_content_params
|
|
10
|
+
from ..types import fine_tuning_delete_params, fine_tuning_content_params, fine_tuning_estimate_price_params
|
|
11
11
|
from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
|
|
12
12
|
from .._utils import maybe_transform, async_maybe_transform
|
|
13
13
|
from .._compat import cached_property
|
|
@@ -27,17 +27,31 @@ from .._response import (
|
|
|
27
27
|
async_to_custom_streamed_response_wrapper,
|
|
28
28
|
)
|
|
29
29
|
from .._base_client import make_request_options
|
|
30
|
-
from ..lib.types.fine_tuning import
|
|
30
|
+
from ..lib.types.fine_tuning import (
|
|
31
|
+
FinetuneResponse as FinetuneResponseLib,
|
|
32
|
+
FinetuneTrainingLimits,
|
|
33
|
+
)
|
|
31
34
|
from ..types.finetune_response import FinetuneResponse
|
|
32
|
-
from ..lib.resources.fine_tuning import
|
|
35
|
+
from ..lib.resources.fine_tuning import (
|
|
36
|
+
get_model_limits,
|
|
37
|
+
async_get_model_limits,
|
|
38
|
+
create_finetune_request,
|
|
39
|
+
)
|
|
33
40
|
from ..types.fine_tuning_list_response import FineTuningListResponse
|
|
34
41
|
from ..types.fine_tuning_cancel_response import FineTuningCancelResponse
|
|
35
42
|
from ..types.fine_tuning_delete_response import FineTuningDeleteResponse
|
|
36
43
|
from ..types.fine_tuning_list_events_response import FineTuningListEventsResponse
|
|
44
|
+
from ..types.fine_tuning_estimate_price_response import FineTuningEstimatePriceResponse
|
|
37
45
|
from ..types.fine_tuning_list_checkpoints_response import FineTuningListCheckpointsResponse
|
|
38
46
|
|
|
39
47
|
__all__ = ["FineTuningResource", "AsyncFineTuningResource"]
|
|
40
48
|
|
|
49
|
+
_WARNING_MESSAGE_INSUFFICIENT_FUNDS = (
|
|
50
|
+
"The estimated price of the fine-tuning job is {} which is significantly "
|
|
51
|
+
"greater than your current credit limit and balance combined. "
|
|
52
|
+
"It will likely get cancelled due to insufficient funds. "
|
|
53
|
+
"Proceed at your own risk."
|
|
54
|
+
)
|
|
41
55
|
|
|
42
56
|
class FineTuningResource(SyncAPIResource):
|
|
43
57
|
@cached_property
|
|
@@ -179,7 +193,7 @@ class FineTuningResource(SyncAPIResource):
|
|
|
179
193
|
pass
|
|
180
194
|
model_limits = get_model_limits(self._client, str(model_name))
|
|
181
195
|
|
|
182
|
-
finetune_request = create_finetune_request(
|
|
196
|
+
finetune_request, training_type_cls, training_method_cls = create_finetune_request(
|
|
183
197
|
model_limits=model_limits,
|
|
184
198
|
training_file=training_file,
|
|
185
199
|
model=model,
|
|
@@ -218,11 +232,32 @@ class FineTuningResource(SyncAPIResource):
|
|
|
218
232
|
hf_output_repo_name=hf_output_repo_name,
|
|
219
233
|
)
|
|
220
234
|
|
|
235
|
+
|
|
236
|
+
price_estimation_result = self.estimate_price(
|
|
237
|
+
training_file=training_file,
|
|
238
|
+
from_checkpoint=from_checkpoint or Omit(),
|
|
239
|
+
validation_file=validation_file or Omit(),
|
|
240
|
+
model=model or "",
|
|
241
|
+
n_epochs=finetune_request.n_epochs,
|
|
242
|
+
n_evals=finetune_request.n_evals or 0,
|
|
243
|
+
training_type=training_type_cls,
|
|
244
|
+
training_method=training_method_cls,
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
|
|
221
248
|
if verbose:
|
|
222
249
|
rprint(
|
|
223
250
|
"Submitting a fine-tuning job with the following parameters:",
|
|
224
251
|
finetune_request,
|
|
225
252
|
)
|
|
253
|
+
if not price_estimation_result.allowed_to_proceed:
|
|
254
|
+
rprint(
|
|
255
|
+
"[red]"
|
|
256
|
+
+ _WARNING_MESSAGE_INSUFFICIENT_FUNDS.format(
|
|
257
|
+
price_estimation_result.estimated_total_price # pyright: ignore[reportPossiblyUnboundVariable]
|
|
258
|
+
)
|
|
259
|
+
+ "[/red]",
|
|
260
|
+
)
|
|
226
261
|
parameter_payload = finetune_request.model_dump(exclude_none=True)
|
|
227
262
|
|
|
228
263
|
return self._client.post(
|
|
@@ -413,6 +448,76 @@ class FineTuningResource(SyncAPIResource):
|
|
|
413
448
|
cast_to=BinaryAPIResponse,
|
|
414
449
|
)
|
|
415
450
|
|
|
451
|
+
def estimate_price(
|
|
452
|
+
self,
|
|
453
|
+
*,
|
|
454
|
+
training_file: str,
|
|
455
|
+
from_checkpoint: str | Omit = omit,
|
|
456
|
+
model: str | Omit = omit,
|
|
457
|
+
n_epochs: int | Omit = omit,
|
|
458
|
+
n_evals: int | Omit = omit,
|
|
459
|
+
training_method: fine_tuning_estimate_price_params.TrainingMethod | Omit = omit,
|
|
460
|
+
training_type: fine_tuning_estimate_price_params.TrainingType | Omit = omit,
|
|
461
|
+
validation_file: str | Omit = omit,
|
|
462
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
463
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
464
|
+
extra_headers: Headers | None = None,
|
|
465
|
+
extra_query: Query | None = None,
|
|
466
|
+
extra_body: Body | None = None,
|
|
467
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
468
|
+
) -> FineTuningEstimatePriceResponse:
|
|
469
|
+
"""
|
|
470
|
+
Estimate the price of a fine-tuning job.
|
|
471
|
+
|
|
472
|
+
Args:
|
|
473
|
+
training_file: File-ID of a training file uploaded to the Together API
|
|
474
|
+
|
|
475
|
+
from_checkpoint: The checkpoint identifier to continue training from a previous fine-tuning job.
|
|
476
|
+
Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or
|
|
477
|
+
`{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, the
|
|
478
|
+
final checkpoint will be used.
|
|
479
|
+
|
|
480
|
+
model: Name of the base model to run fine-tune job on
|
|
481
|
+
|
|
482
|
+
n_epochs: Number of complete passes through the training dataset (higher values may
|
|
483
|
+
improve results but increase cost and risk of overfitting)
|
|
484
|
+
|
|
485
|
+
n_evals: Number of evaluations to be run on a given validation set during training
|
|
486
|
+
|
|
487
|
+
training_method: The training method to use. 'sft' for Supervised Fine-Tuning or 'dpo' for Direct
|
|
488
|
+
Preference Optimization.
|
|
489
|
+
|
|
490
|
+
validation_file: File-ID of a validation file uploaded to the Together API
|
|
491
|
+
|
|
492
|
+
extra_headers: Send extra headers
|
|
493
|
+
|
|
494
|
+
extra_query: Add additional query parameters to the request
|
|
495
|
+
|
|
496
|
+
extra_body: Add additional JSON properties to the request
|
|
497
|
+
|
|
498
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
499
|
+
"""
|
|
500
|
+
return self._post(
|
|
501
|
+
"/fine-tunes/estimate-price",
|
|
502
|
+
body=maybe_transform(
|
|
503
|
+
{
|
|
504
|
+
"training_file": training_file,
|
|
505
|
+
"from_checkpoint": from_checkpoint,
|
|
506
|
+
"model": model,
|
|
507
|
+
"n_epochs": n_epochs,
|
|
508
|
+
"n_evals": n_evals,
|
|
509
|
+
"training_method": training_method,
|
|
510
|
+
"training_type": training_type,
|
|
511
|
+
"validation_file": validation_file,
|
|
512
|
+
},
|
|
513
|
+
fine_tuning_estimate_price_params.FineTuningEstimatePriceParams,
|
|
514
|
+
),
|
|
515
|
+
options=make_request_options(
|
|
516
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
517
|
+
),
|
|
518
|
+
cast_to=FineTuningEstimatePriceResponse,
|
|
519
|
+
)
|
|
520
|
+
|
|
416
521
|
def list_checkpoints(
|
|
417
522
|
self,
|
|
418
523
|
id: str,
|
|
@@ -620,7 +725,7 @@ class AsyncFineTuningResource(AsyncAPIResource):
|
|
|
620
725
|
pass
|
|
621
726
|
model_limits = await async_get_model_limits(self._client, str(model_name))
|
|
622
727
|
|
|
623
|
-
finetune_request = create_finetune_request(
|
|
728
|
+
finetune_request, training_type_cls, training_method_cls = create_finetune_request(
|
|
624
729
|
model_limits=model_limits,
|
|
625
730
|
training_file=training_file,
|
|
626
731
|
model=model,
|
|
@@ -659,11 +764,32 @@ class AsyncFineTuningResource(AsyncAPIResource):
|
|
|
659
764
|
hf_output_repo_name=hf_output_repo_name,
|
|
660
765
|
)
|
|
661
766
|
|
|
767
|
+
|
|
768
|
+
price_estimation_result = await self.estimate_price(
|
|
769
|
+
training_file=training_file,
|
|
770
|
+
from_checkpoint=from_checkpoint or Omit(),
|
|
771
|
+
validation_file=validation_file or Omit(),
|
|
772
|
+
model=model or "",
|
|
773
|
+
n_epochs=finetune_request.n_epochs,
|
|
774
|
+
n_evals=finetune_request.n_evals or 0,
|
|
775
|
+
training_type=training_type_cls,
|
|
776
|
+
training_method=training_method_cls,
|
|
777
|
+
)
|
|
778
|
+
|
|
779
|
+
|
|
662
780
|
if verbose:
|
|
663
781
|
rprint(
|
|
664
782
|
"Submitting a fine-tuning job with the following parameters:",
|
|
665
783
|
finetune_request,
|
|
666
784
|
)
|
|
785
|
+
if not price_estimation_result.allowed_to_proceed:
|
|
786
|
+
rprint(
|
|
787
|
+
"[red]"
|
|
788
|
+
+ _WARNING_MESSAGE_INSUFFICIENT_FUNDS.format(
|
|
789
|
+
price_estimation_result.estimated_total_price # pyright: ignore[reportPossiblyUnboundVariable]
|
|
790
|
+
)
|
|
791
|
+
+ "[/red]",
|
|
792
|
+
)
|
|
667
793
|
parameter_payload = finetune_request.model_dump(exclude_none=True)
|
|
668
794
|
|
|
669
795
|
return await self._client.post(
|
|
@@ -854,6 +980,76 @@ class AsyncFineTuningResource(AsyncAPIResource):
|
|
|
854
980
|
cast_to=AsyncBinaryAPIResponse,
|
|
855
981
|
)
|
|
856
982
|
|
|
983
|
+
async def estimate_price(
|
|
984
|
+
self,
|
|
985
|
+
*,
|
|
986
|
+
training_file: str,
|
|
987
|
+
from_checkpoint: str | Omit = omit,
|
|
988
|
+
model: str | Omit = omit,
|
|
989
|
+
n_epochs: int | Omit = omit,
|
|
990
|
+
n_evals: int | Omit = omit,
|
|
991
|
+
training_method: fine_tuning_estimate_price_params.TrainingMethod | Omit = omit,
|
|
992
|
+
training_type: fine_tuning_estimate_price_params.TrainingType | Omit = omit,
|
|
993
|
+
validation_file: str | Omit = omit,
|
|
994
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
995
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
996
|
+
extra_headers: Headers | None = None,
|
|
997
|
+
extra_query: Query | None = None,
|
|
998
|
+
extra_body: Body | None = None,
|
|
999
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
1000
|
+
) -> FineTuningEstimatePriceResponse:
|
|
1001
|
+
"""
|
|
1002
|
+
Estimate the price of a fine-tuning job.
|
|
1003
|
+
|
|
1004
|
+
Args:
|
|
1005
|
+
training_file: File-ID of a training file uploaded to the Together API
|
|
1006
|
+
|
|
1007
|
+
from_checkpoint: The checkpoint identifier to continue training from a previous fine-tuning job.
|
|
1008
|
+
Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or
|
|
1009
|
+
`{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, the
|
|
1010
|
+
final checkpoint will be used.
|
|
1011
|
+
|
|
1012
|
+
model: Name of the base model to run fine-tune job on
|
|
1013
|
+
|
|
1014
|
+
n_epochs: Number of complete passes through the training dataset (higher values may
|
|
1015
|
+
improve results but increase cost and risk of overfitting)
|
|
1016
|
+
|
|
1017
|
+
n_evals: Number of evaluations to be run on a given validation set during training
|
|
1018
|
+
|
|
1019
|
+
training_method: The training method to use. 'sft' for Supervised Fine-Tuning or 'dpo' for Direct
|
|
1020
|
+
Preference Optimization.
|
|
1021
|
+
|
|
1022
|
+
validation_file: File-ID of a validation file uploaded to the Together API
|
|
1023
|
+
|
|
1024
|
+
extra_headers: Send extra headers
|
|
1025
|
+
|
|
1026
|
+
extra_query: Add additional query parameters to the request
|
|
1027
|
+
|
|
1028
|
+
extra_body: Add additional JSON properties to the request
|
|
1029
|
+
|
|
1030
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
1031
|
+
"""
|
|
1032
|
+
return await self._post(
|
|
1033
|
+
"/fine-tunes/estimate-price",
|
|
1034
|
+
body=await async_maybe_transform(
|
|
1035
|
+
{
|
|
1036
|
+
"training_file": training_file,
|
|
1037
|
+
"from_checkpoint": from_checkpoint,
|
|
1038
|
+
"model": model,
|
|
1039
|
+
"n_epochs": n_epochs,
|
|
1040
|
+
"n_evals": n_evals,
|
|
1041
|
+
"training_method": training_method,
|
|
1042
|
+
"training_type": training_type,
|
|
1043
|
+
"validation_file": validation_file,
|
|
1044
|
+
},
|
|
1045
|
+
fine_tuning_estimate_price_params.FineTuningEstimatePriceParams,
|
|
1046
|
+
),
|
|
1047
|
+
options=make_request_options(
|
|
1048
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
1049
|
+
),
|
|
1050
|
+
cast_to=FineTuningEstimatePriceResponse,
|
|
1051
|
+
)
|
|
1052
|
+
|
|
857
1053
|
async def list_checkpoints(
|
|
858
1054
|
self,
|
|
859
1055
|
id: str,
|
|
@@ -941,6 +1137,9 @@ class FineTuningResourceWithRawResponse:
|
|
|
941
1137
|
fine_tuning.content,
|
|
942
1138
|
BinaryAPIResponse,
|
|
943
1139
|
)
|
|
1140
|
+
self.estimate_price = to_raw_response_wrapper(
|
|
1141
|
+
fine_tuning.estimate_price,
|
|
1142
|
+
)
|
|
944
1143
|
self.list_checkpoints = to_raw_response_wrapper(
|
|
945
1144
|
fine_tuning.list_checkpoints,
|
|
946
1145
|
)
|
|
@@ -969,6 +1168,9 @@ class AsyncFineTuningResourceWithRawResponse:
|
|
|
969
1168
|
fine_tuning.content,
|
|
970
1169
|
AsyncBinaryAPIResponse,
|
|
971
1170
|
)
|
|
1171
|
+
self.estimate_price = async_to_raw_response_wrapper(
|
|
1172
|
+
fine_tuning.estimate_price,
|
|
1173
|
+
)
|
|
972
1174
|
self.list_checkpoints = async_to_raw_response_wrapper(
|
|
973
1175
|
fine_tuning.list_checkpoints,
|
|
974
1176
|
)
|
|
@@ -997,6 +1199,9 @@ class FineTuningResourceWithStreamingResponse:
|
|
|
997
1199
|
fine_tuning.content,
|
|
998
1200
|
StreamedBinaryAPIResponse,
|
|
999
1201
|
)
|
|
1202
|
+
self.estimate_price = to_streamed_response_wrapper(
|
|
1203
|
+
fine_tuning.estimate_price,
|
|
1204
|
+
)
|
|
1000
1205
|
self.list_checkpoints = to_streamed_response_wrapper(
|
|
1001
1206
|
fine_tuning.list_checkpoints,
|
|
1002
1207
|
)
|
|
@@ -1025,6 +1230,9 @@ class AsyncFineTuningResourceWithStreamingResponse:
|
|
|
1025
1230
|
fine_tuning.content,
|
|
1026
1231
|
AsyncStreamedBinaryAPIResponse,
|
|
1027
1232
|
)
|
|
1233
|
+
self.estimate_price = async_to_streamed_response_wrapper(
|
|
1234
|
+
fine_tuning.estimate_price,
|
|
1235
|
+
)
|
|
1028
1236
|
self.list_checkpoints = async_to_streamed_response_wrapper(
|
|
1029
1237
|
fine_tuning.list_checkpoints,
|
|
1030
1238
|
)
|
together/resources/images.py
CHANGED
|
@@ -8,7 +8,7 @@ from typing_extensions import Literal
|
|
|
8
8
|
import httpx
|
|
9
9
|
|
|
10
10
|
from ..types import image_generate_params
|
|
11
|
-
from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
|
|
11
|
+
from .._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
|
|
12
12
|
from .._utils import maybe_transform, async_maybe_transform
|
|
13
13
|
from .._compat import cached_property
|
|
14
14
|
from .._resource import SyncAPIResource, AsyncAPIResource
|
|
@@ -64,6 +64,7 @@ class ImagesResource(SyncAPIResource):
|
|
|
64
64
|
n: int | Omit = omit,
|
|
65
65
|
negative_prompt: str | Omit = omit,
|
|
66
66
|
output_format: Literal["jpeg", "png"] | Omit = omit,
|
|
67
|
+
reference_images: SequenceNotStr[str] | Omit = omit,
|
|
67
68
|
response_format: Literal["base64", "url"] | Omit = omit,
|
|
68
69
|
seed: int | Omit = omit,
|
|
69
70
|
steps: int | Omit = omit,
|
|
@@ -105,6 +106,10 @@ class ImagesResource(SyncAPIResource):
|
|
|
105
106
|
output_format: The format of the image response. Can be either be `jpeg` or `png`. Defaults to
|
|
106
107
|
`jpeg`.
|
|
107
108
|
|
|
109
|
+
reference_images: An array of image URLs that guide the overall appearance and style of the
|
|
110
|
+
generated image. These reference images influence the visual characteristics
|
|
111
|
+
consistently across the generation.
|
|
112
|
+
|
|
108
113
|
response_format: Format of the image response. Can be either a base64 string or a URL.
|
|
109
114
|
|
|
110
115
|
seed: Seed used for generation. Can be used to reproduce image generations.
|
|
@@ -135,6 +140,7 @@ class ImagesResource(SyncAPIResource):
|
|
|
135
140
|
"n": n,
|
|
136
141
|
"negative_prompt": negative_prompt,
|
|
137
142
|
"output_format": output_format,
|
|
143
|
+
"reference_images": reference_images,
|
|
138
144
|
"response_format": response_format,
|
|
139
145
|
"seed": seed,
|
|
140
146
|
"steps": steps,
|
|
@@ -189,6 +195,7 @@ class AsyncImagesResource(AsyncAPIResource):
|
|
|
189
195
|
n: int | Omit = omit,
|
|
190
196
|
negative_prompt: str | Omit = omit,
|
|
191
197
|
output_format: Literal["jpeg", "png"] | Omit = omit,
|
|
198
|
+
reference_images: SequenceNotStr[str] | Omit = omit,
|
|
192
199
|
response_format: Literal["base64", "url"] | Omit = omit,
|
|
193
200
|
seed: int | Omit = omit,
|
|
194
201
|
steps: int | Omit = omit,
|
|
@@ -230,6 +237,10 @@ class AsyncImagesResource(AsyncAPIResource):
|
|
|
230
237
|
output_format: The format of the image response. Can be either be `jpeg` or `png`. Defaults to
|
|
231
238
|
`jpeg`.
|
|
232
239
|
|
|
240
|
+
reference_images: An array of image URLs that guide the overall appearance and style of the
|
|
241
|
+
generated image. These reference images influence the visual characteristics
|
|
242
|
+
consistently across the generation.
|
|
243
|
+
|
|
233
244
|
response_format: Format of the image response. Can be either a base64 string or a URL.
|
|
234
245
|
|
|
235
246
|
seed: Seed used for generation. Can be used to reproduce image generations.
|
|
@@ -260,6 +271,7 @@ class AsyncImagesResource(AsyncAPIResource):
|
|
|
260
271
|
"n": n,
|
|
261
272
|
"negative_prompt": negative_prompt,
|
|
262
273
|
"output_format": output_format,
|
|
274
|
+
"reference_images": reference_images,
|
|
263
275
|
"response_format": response_format,
|
|
264
276
|
"seed": seed,
|
|
265
277
|
"steps": steps,
|
together/resources/models.py
CHANGED
|
@@ -6,7 +6,7 @@ from typing_extensions import Literal
|
|
|
6
6
|
|
|
7
7
|
import httpx
|
|
8
8
|
|
|
9
|
-
from ..types import model_upload_params
|
|
9
|
+
from ..types import model_list_params, model_upload_params
|
|
10
10
|
from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
|
|
11
11
|
from .._utils import maybe_transform, async_maybe_transform
|
|
12
12
|
from .._compat import cached_property
|
|
@@ -47,6 +47,7 @@ class ModelsResource(SyncAPIResource):
|
|
|
47
47
|
def list(
|
|
48
48
|
self,
|
|
49
49
|
*,
|
|
50
|
+
dedicated: bool | Omit = omit,
|
|
50
51
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
51
52
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
52
53
|
extra_headers: Headers | None = None,
|
|
@@ -54,11 +55,28 @@ class ModelsResource(SyncAPIResource):
|
|
|
54
55
|
extra_body: Body | None = None,
|
|
55
56
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
56
57
|
) -> ModelListResponse:
|
|
57
|
-
"""
|
|
58
|
+
"""
|
|
59
|
+
Lists all of Together's open-source models
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
dedicated: Filter models to only return dedicated models
|
|
63
|
+
|
|
64
|
+
extra_headers: Send extra headers
|
|
65
|
+
|
|
66
|
+
extra_query: Add additional query parameters to the request
|
|
67
|
+
|
|
68
|
+
extra_body: Add additional JSON properties to the request
|
|
69
|
+
|
|
70
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
71
|
+
"""
|
|
58
72
|
return self._get(
|
|
59
73
|
"/models",
|
|
60
74
|
options=make_request_options(
|
|
61
|
-
extra_headers=extra_headers,
|
|
75
|
+
extra_headers=extra_headers,
|
|
76
|
+
extra_query=extra_query,
|
|
77
|
+
extra_body=extra_body,
|
|
78
|
+
timeout=timeout,
|
|
79
|
+
query=maybe_transform({"dedicated": dedicated}, model_list_params.ModelListParams),
|
|
62
80
|
),
|
|
63
81
|
cast_to=ModelListResponse,
|
|
64
82
|
)
|
|
@@ -152,6 +170,7 @@ class AsyncModelsResource(AsyncAPIResource):
|
|
|
152
170
|
async def list(
|
|
153
171
|
self,
|
|
154
172
|
*,
|
|
173
|
+
dedicated: bool | Omit = omit,
|
|
155
174
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
156
175
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
157
176
|
extra_headers: Headers | None = None,
|
|
@@ -159,11 +178,28 @@ class AsyncModelsResource(AsyncAPIResource):
|
|
|
159
178
|
extra_body: Body | None = None,
|
|
160
179
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
161
180
|
) -> ModelListResponse:
|
|
162
|
-
"""
|
|
181
|
+
"""
|
|
182
|
+
Lists all of Together's open-source models
|
|
183
|
+
|
|
184
|
+
Args:
|
|
185
|
+
dedicated: Filter models to only return dedicated models
|
|
186
|
+
|
|
187
|
+
extra_headers: Send extra headers
|
|
188
|
+
|
|
189
|
+
extra_query: Add additional query parameters to the request
|
|
190
|
+
|
|
191
|
+
extra_body: Add additional JSON properties to the request
|
|
192
|
+
|
|
193
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
194
|
+
"""
|
|
163
195
|
return await self._get(
|
|
164
196
|
"/models",
|
|
165
197
|
options=make_request_options(
|
|
166
|
-
extra_headers=extra_headers,
|
|
198
|
+
extra_headers=extra_headers,
|
|
199
|
+
extra_query=extra_query,
|
|
200
|
+
extra_body=extra_body,
|
|
201
|
+
timeout=timeout,
|
|
202
|
+
query=await async_maybe_transform({"dedicated": dedicated}, model_list_params.ModelListParams),
|
|
167
203
|
),
|
|
168
204
|
cast_to=ModelListResponse,
|
|
169
205
|
)
|
together/types/__init__.py
CHANGED
|
@@ -26,6 +26,7 @@ from .execute_response import ExecuteResponse as ExecuteResponse
|
|
|
26
26
|
from .autoscaling_param import AutoscalingParam as AutoscalingParam
|
|
27
27
|
from .finetune_response import FinetuneResponse as FinetuneResponse
|
|
28
28
|
from .job_list_response import JobListResponse as JobListResponse
|
|
29
|
+
from .model_list_params import ModelListParams as ModelListParams
|
|
29
30
|
from .tool_choice_param import ToolChoiceParam as ToolChoiceParam
|
|
30
31
|
from .dedicated_endpoint import DedicatedEndpoint as DedicatedEndpoint
|
|
31
32
|
from .eval_create_params import EvalCreateParams as EvalCreateParams
|
|
@@ -62,6 +63,8 @@ from .fine_tuning_delete_response import FineTuningDeleteResponse as FineTuningD
|
|
|
62
63
|
from .endpoint_list_avzones_response import EndpointListAvzonesResponse as EndpointListAvzonesResponse
|
|
63
64
|
from .code_interpreter_execute_params import CodeInterpreterExecuteParams as CodeInterpreterExecuteParams
|
|
64
65
|
from .fine_tuning_list_events_response import FineTuningListEventsResponse as FineTuningListEventsResponse
|
|
66
|
+
from .fine_tuning_estimate_price_params import FineTuningEstimatePriceParams as FineTuningEstimatePriceParams
|
|
67
|
+
from .fine_tuning_estimate_price_response import FineTuningEstimatePriceResponse as FineTuningEstimatePriceResponse
|
|
65
68
|
from .fine_tuning_list_checkpoints_response import (
|
|
66
69
|
FineTuningListCheckpointsResponse as FineTuningListCheckpointsResponse,
|
|
67
70
|
)
|
|
@@ -34,6 +34,20 @@ class TranscriptionCreateParams(TypedDict, total=False):
|
|
|
34
34
|
If `auto` is provided, language is auto-detected.
|
|
35
35
|
"""
|
|
36
36
|
|
|
37
|
+
max_speakers: int
|
|
38
|
+
"""Maximum number of speakers expected in the audio.
|
|
39
|
+
|
|
40
|
+
Used to improve diarization accuracy when the approximate number of speakers is
|
|
41
|
+
known.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
min_speakers: int
|
|
45
|
+
"""Minimum number of speakers expected in the audio.
|
|
46
|
+
|
|
47
|
+
Used to improve diarization accuracy when the approximate number of speakers is
|
|
48
|
+
known.
|
|
49
|
+
"""
|
|
50
|
+
|
|
37
51
|
model: Literal["openai/whisper-large-v3"]
|
|
38
52
|
"""Model to use for transcription"""
|
|
39
53
|
|
|
@@ -14,10 +14,14 @@ class DataVoice(BaseModel):
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class Data(BaseModel):
|
|
17
|
+
"""Represents a model with its available voices."""
|
|
18
|
+
|
|
17
19
|
model: str
|
|
18
20
|
|
|
19
21
|
voices: List[DataVoice]
|
|
20
22
|
|
|
21
23
|
|
|
22
24
|
class VoiceListResponse(BaseModel):
|
|
25
|
+
"""Response containing a list of models and their available voices."""
|
|
26
|
+
|
|
23
27
|
data: List[Data]
|
together/types/autoscaling.py
CHANGED
|
@@ -29,6 +29,10 @@ __all__ = [
|
|
|
29
29
|
"FunctionCall",
|
|
30
30
|
"FunctionCallName",
|
|
31
31
|
"ResponseFormat",
|
|
32
|
+
"ResponseFormatText",
|
|
33
|
+
"ResponseFormatJsonSchema",
|
|
34
|
+
"ResponseFormatJsonSchemaJsonSchema",
|
|
35
|
+
"ResponseFormatJsonObject",
|
|
32
36
|
"ToolChoice",
|
|
33
37
|
"CompletionCreateParamsNonStreaming",
|
|
34
38
|
"CompletionCreateParamsStreaming",
|
|
@@ -117,7 +121,16 @@ class CompletionCreateParamsBase(TypedDict, total=False):
|
|
|
117
121
|
"""
|
|
118
122
|
|
|
119
123
|
response_format: ResponseFormat
|
|
120
|
-
"""An object specifying the format that the model must output.
|
|
124
|
+
"""An object specifying the format that the model must output.
|
|
125
|
+
|
|
126
|
+
Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
|
|
127
|
+
Outputs which ensures the model will match your supplied JSON schema. Learn more
|
|
128
|
+
in the [Structured Outputs guide](https://docs.together.ai/docs/json-mode).
|
|
129
|
+
|
|
130
|
+
Setting to `{ "type": "json_object" }` enables the older JSON mode, which
|
|
131
|
+
ensures the message the model generates is valid JSON. Using `json_schema` is
|
|
132
|
+
preferred for models that support it.
|
|
133
|
+
"""
|
|
121
134
|
|
|
122
135
|
safety_model: str
|
|
123
136
|
"""The name of the moderation model used to validate tokens.
|
|
@@ -297,13 +310,73 @@ class FunctionCallName(TypedDict, total=False):
|
|
|
297
310
|
FunctionCall: TypeAlias = Union[Literal["none", "auto"], FunctionCallName]
|
|
298
311
|
|
|
299
312
|
|
|
300
|
-
class
|
|
313
|
+
class ResponseFormatText(TypedDict, total=False):
|
|
314
|
+
"""Default response format. Used to generate text responses."""
|
|
315
|
+
|
|
316
|
+
type: Required[Literal["text"]]
|
|
317
|
+
"""The type of response format being defined. Always `text`."""
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
class ResponseFormatJsonSchemaJsonSchema(TypedDict, total=False):
|
|
321
|
+
"""Structured Outputs configuration options, including a JSON Schema."""
|
|
322
|
+
|
|
323
|
+
name: Required[str]
|
|
324
|
+
"""The name of the response format.
|
|
325
|
+
|
|
326
|
+
Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length
|
|
327
|
+
of 64.
|
|
328
|
+
"""
|
|
329
|
+
|
|
330
|
+
description: str
|
|
331
|
+
"""
|
|
332
|
+
A description of what the response format is for, used by the model to determine
|
|
333
|
+
how to respond in the format.
|
|
334
|
+
"""
|
|
335
|
+
|
|
301
336
|
schema: Dict[str, object]
|
|
302
|
-
"""
|
|
337
|
+
"""
|
|
338
|
+
The schema for the response format, described as a JSON Schema object. Learn how
|
|
339
|
+
to build JSON schemas [here](https://json-schema.org/).
|
|
340
|
+
"""
|
|
341
|
+
|
|
342
|
+
strict: Optional[bool]
|
|
343
|
+
"""
|
|
344
|
+
Whether to enable strict schema adherence when generating the output. If set to
|
|
345
|
+
true, the model will always follow the exact schema defined in the `schema`
|
|
346
|
+
field. Only a subset of JSON Schema is supported when `strict` is `true`. To
|
|
347
|
+
learn more, read the
|
|
348
|
+
[Structured Outputs guide](https://docs.together.ai/docs/json-mode).
|
|
349
|
+
"""
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
class ResponseFormatJsonSchema(TypedDict, total=False):
|
|
353
|
+
"""JSON Schema response format.
|
|
354
|
+
|
|
355
|
+
Used to generate structured JSON responses.
|
|
356
|
+
Learn more about [Structured Outputs](https://docs.together.ai/docs/json-mode).
|
|
357
|
+
"""
|
|
358
|
+
|
|
359
|
+
json_schema: Required[ResponseFormatJsonSchemaJsonSchema]
|
|
360
|
+
"""Structured Outputs configuration options, including a JSON Schema."""
|
|
361
|
+
|
|
362
|
+
type: Required[Literal["json_schema"]]
|
|
363
|
+
"""The type of response format being defined. Always `json_schema`."""
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
class ResponseFormatJsonObject(TypedDict, total=False):
|
|
367
|
+
"""JSON object response format.
|
|
368
|
+
|
|
369
|
+
An older method of generating JSON responses.
|
|
370
|
+
Using `json_schema` is recommended for models that support it. Note that the
|
|
371
|
+
model will not generate JSON without a system or user message instructing it
|
|
372
|
+
to do so.
|
|
373
|
+
"""
|
|
374
|
+
|
|
375
|
+
type: Required[Literal["json_object"]]
|
|
376
|
+
"""The type of response format being defined. Always `json_object`."""
|
|
303
377
|
|
|
304
|
-
type: str
|
|
305
|
-
"""The type of the response format."""
|
|
306
378
|
|
|
379
|
+
ResponseFormat: TypeAlias = Union[ResponseFormatText, ResponseFormatJsonSchema, ResponseFormatJsonObject]
|
|
307
380
|
|
|
308
381
|
ToolChoice: TypeAlias = Union[str, ToolChoiceParam]
|
|
309
382
|
|