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
together/_streaming.py
CHANGED
|
@@ -55,30 +55,31 @@ class Stream(Generic[_T]):
|
|
|
55
55
|
process_data = self._client._process_response_data
|
|
56
56
|
iterator = self._iter_events()
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
58
|
+
try:
|
|
59
|
+
for sse in iterator:
|
|
60
|
+
if sse.data.startswith("[DONE]"):
|
|
61
|
+
break
|
|
62
|
+
|
|
63
|
+
if sse.event is None:
|
|
64
|
+
data = sse.json()
|
|
65
|
+
if is_mapping(data) and data.get("error"):
|
|
66
|
+
message = None
|
|
67
|
+
error = data.get("error")
|
|
68
|
+
if is_mapping(error):
|
|
69
|
+
message = error.get("message")
|
|
70
|
+
if not message or not isinstance(message, str):
|
|
71
|
+
message = "An error occurred during streaming"
|
|
72
|
+
|
|
73
|
+
raise APIError(
|
|
74
|
+
message=message,
|
|
75
|
+
request=self.response.request,
|
|
76
|
+
body=data["error"],
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
yield process_data(data=data, cast_to=cast_to, response=response)
|
|
80
|
+
finally:
|
|
81
|
+
# Ensure the response is closed even if the consumer doesn't read all data
|
|
82
|
+
response.close()
|
|
82
83
|
|
|
83
84
|
def __enter__(self) -> Self:
|
|
84
85
|
return self
|
|
@@ -137,30 +138,31 @@ class AsyncStream(Generic[_T]):
|
|
|
137
138
|
process_data = self._client._process_response_data
|
|
138
139
|
iterator = self._iter_events()
|
|
139
140
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
141
|
+
try:
|
|
142
|
+
async for sse in iterator:
|
|
143
|
+
if sse.data.startswith("[DONE]"):
|
|
144
|
+
break
|
|
145
|
+
|
|
146
|
+
if sse.event is None:
|
|
147
|
+
data = sse.json()
|
|
148
|
+
if is_mapping(data) and data.get("error"):
|
|
149
|
+
message = None
|
|
150
|
+
error = data.get("error")
|
|
151
|
+
if is_mapping(error):
|
|
152
|
+
message = error.get("message")
|
|
153
|
+
if not message or not isinstance(message, str):
|
|
154
|
+
message = "An error occurred during streaming"
|
|
155
|
+
|
|
156
|
+
raise APIError(
|
|
157
|
+
message=message,
|
|
158
|
+
request=self.response.request,
|
|
159
|
+
body=data["error"],
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
yield process_data(data=data, cast_to=cast_to, response=response)
|
|
163
|
+
finally:
|
|
164
|
+
# Ensure the response is closed even if the consumer doesn't read all data
|
|
165
|
+
await response.aclose()
|
|
164
166
|
|
|
165
167
|
async def __aenter__(self) -> Self:
|
|
166
168
|
return self
|
together/_types.py
CHANGED
|
@@ -243,6 +243,9 @@ _T_co = TypeVar("_T_co", covariant=True)
|
|
|
243
243
|
if TYPE_CHECKING:
|
|
244
244
|
# This works because str.__contains__ does not accept object (either in typeshed or at runtime)
|
|
245
245
|
# https://github.com/hauntsaninja/useful_types/blob/5e9710f3875107d068e7679fd7fec9cfab0eff3b/useful_types/__init__.py#L285
|
|
246
|
+
#
|
|
247
|
+
# Note: index() and count() methods are intentionally omitted to allow pyright to properly
|
|
248
|
+
# infer TypedDict types when dict literals are used in lists assigned to SequenceNotStr.
|
|
246
249
|
class SequenceNotStr(Protocol[_T_co]):
|
|
247
250
|
@overload
|
|
248
251
|
def __getitem__(self, index: SupportsIndex, /) -> _T_co: ...
|
|
@@ -251,8 +254,6 @@ if TYPE_CHECKING:
|
|
|
251
254
|
def __contains__(self, value: object, /) -> bool: ...
|
|
252
255
|
def __len__(self) -> int: ...
|
|
253
256
|
def __iter__(self) -> Iterator[_T_co]: ...
|
|
254
|
-
def index(self, value: Any, start: int = 0, stop: int = ..., /) -> int: ...
|
|
255
|
-
def count(self, value: Any, /) -> int: ...
|
|
256
257
|
def __reversed__(self) -> Iterator[_T_co]: ...
|
|
257
258
|
else:
|
|
258
259
|
# just point this to a normal `Sequence` at runtime to avoid having to special case
|
together/_utils/_utils.py
CHANGED
|
@@ -373,7 +373,7 @@ def get_required_header(headers: HeadersLike, header: str) -> str:
|
|
|
373
373
|
lower_header = header.lower()
|
|
374
374
|
if is_mapping_t(headers):
|
|
375
375
|
# mypy doesn't understand the type narrowing here
|
|
376
|
-
for k, v in headers.items(): # type: ignore[misc, has-type]
|
|
376
|
+
for k, v in headers.items(): # type: ignore[misc, has-type, attr-defined]
|
|
377
377
|
if k.lower() == lower_header and isinstance(v, str): # type: ignore[has-type]
|
|
378
378
|
return v # type: ignore[has-type]
|
|
379
379
|
|
together/_version.py
CHANGED
|
@@ -13,6 +13,7 @@ from tabulate import tabulate
|
|
|
13
13
|
from click.core import ParameterSource # type: ignore[attr-defined]
|
|
14
14
|
|
|
15
15
|
from together import Together
|
|
16
|
+
from together.types import fine_tuning_estimate_price_params as pe_params
|
|
16
17
|
from together._types import NOT_GIVEN, NotGiven
|
|
17
18
|
from together.lib.utils import log_warn
|
|
18
19
|
from together.lib.utils.tools import format_timestamp, finetune_price_to_dollars
|
|
@@ -24,13 +25,21 @@ from together.lib.resources.fine_tuning import get_model_limits
|
|
|
24
25
|
|
|
25
26
|
_CONFIRMATION_MESSAGE = (
|
|
26
27
|
"You are about to create a fine-tuning job. "
|
|
27
|
-
"The
|
|
28
|
+
"The estimated price of this job is {price}. "
|
|
29
|
+
"The actual cost of your job will be determined by the model size, the number of tokens "
|
|
28
30
|
"in the training file, the number of tokens in the validation file, the number of epochs, and "
|
|
29
|
-
"the number of evaluations. Visit https://www.together.ai/pricing to
|
|
31
|
+
"the number of evaluations. Visit https://www.together.ai/pricing to learn more about pricing.\n"
|
|
32
|
+
"{warning}"
|
|
30
33
|
"You can pass `-y` or `--confirm` to your command to skip this message.\n\n"
|
|
31
34
|
"Do you want to proceed?"
|
|
32
35
|
)
|
|
33
36
|
|
|
37
|
+
_WARNING_MESSAGE_INSUFFICIENT_FUNDS = (
|
|
38
|
+
"The estimated price of this job is significantly greater than your current credit limit and balance combined. "
|
|
39
|
+
"It will likely get cancelled due to insufficient funds. "
|
|
40
|
+
"Consider increasing your credit limit at https://api.together.xyz/settings/profile\n"
|
|
41
|
+
)
|
|
42
|
+
|
|
34
43
|
_FT_JOB_WITH_STEP_REGEX = r"^ft-[\dabcdef-]+:\d+$"
|
|
35
44
|
|
|
36
45
|
|
|
@@ -323,7 +332,60 @@ def create(
|
|
|
323
332
|
elif n_evals > 0 and not validation_file:
|
|
324
333
|
raise click.BadParameter("You have specified a number of evaluation loops but no validation file.")
|
|
325
334
|
|
|
326
|
-
|
|
335
|
+
training_type_cls: pe_params.TrainingType
|
|
336
|
+
if lora:
|
|
337
|
+
training_type_cls = pe_params.TrainingTypeLoRaTrainingType(
|
|
338
|
+
lora_alpha=int(lora_alpha or 0),
|
|
339
|
+
lora_r=lora_r or 0,
|
|
340
|
+
lora_dropout=lora_dropout or 0,
|
|
341
|
+
lora_trainable_modules=lora_trainable_modules or "all-linear",
|
|
342
|
+
type="Lora",
|
|
343
|
+
)
|
|
344
|
+
else:
|
|
345
|
+
training_type_cls = pe_params.TrainingTypeFullTrainingType(
|
|
346
|
+
type="Full",
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
training_method_cls: pe_params.TrainingMethod
|
|
350
|
+
if training_method == "sft":
|
|
351
|
+
training_method_cls = pe_params.TrainingMethodTrainingMethodSft(
|
|
352
|
+
method="sft",
|
|
353
|
+
train_on_inputs=train_on_inputs or "auto",
|
|
354
|
+
)
|
|
355
|
+
else:
|
|
356
|
+
training_method_cls = pe_params.TrainingMethodTrainingMethodDpo(
|
|
357
|
+
method="dpo",
|
|
358
|
+
dpo_beta=dpo_beta or 0,
|
|
359
|
+
dpo_normalize_logratios_by_length=dpo_normalize_logratios_by_length or False,
|
|
360
|
+
dpo_reference_free=False,
|
|
361
|
+
rpo_alpha=rpo_alpha or 0,
|
|
362
|
+
simpo_gamma=simpo_gamma or 0,
|
|
363
|
+
)
|
|
364
|
+
|
|
365
|
+
finetune_price_estimation_result = client.fine_tuning.estimate_price(
|
|
366
|
+
training_file=training_file,
|
|
367
|
+
validation_file=validation_file,
|
|
368
|
+
model=model or "",
|
|
369
|
+
n_epochs=n_epochs,
|
|
370
|
+
n_evals=n_evals,
|
|
371
|
+
training_type=training_type_cls,
|
|
372
|
+
training_method=training_method_cls,
|
|
373
|
+
)
|
|
374
|
+
price = click.style(
|
|
375
|
+
f"${finetune_price_estimation_result.estimated_total_price:.2f}",
|
|
376
|
+
bold=True,
|
|
377
|
+
)
|
|
378
|
+
if not finetune_price_estimation_result.allowed_to_proceed:
|
|
379
|
+
warning = click.style(_WARNING_MESSAGE_INSUFFICIENT_FUNDS, fg="red", bold=True)
|
|
380
|
+
else:
|
|
381
|
+
warning = ""
|
|
382
|
+
|
|
383
|
+
confirmation_message = _CONFIRMATION_MESSAGE.format(
|
|
384
|
+
price=price,
|
|
385
|
+
warning=warning,
|
|
386
|
+
)
|
|
387
|
+
|
|
388
|
+
if confirm or click.confirm(confirmation_message, default=True, show_default=True):
|
|
327
389
|
response = client.fine_tuning.create(
|
|
328
390
|
**training_args,
|
|
329
391
|
verbose=True,
|
together/lib/cli/api/models.py
CHANGED
|
@@ -7,7 +7,6 @@ from tabulate import tabulate
|
|
|
7
7
|
from together import Together, omit
|
|
8
8
|
from together._models import BaseModel
|
|
9
9
|
from together._response import APIResponse as APIResponse
|
|
10
|
-
from together.lib.resources.models import filter_by_dedicated_models
|
|
11
10
|
from together.types.model_upload_response import ModelUploadResponse
|
|
12
11
|
|
|
13
12
|
|
|
@@ -34,11 +33,7 @@ def list(ctx: click.Context, type: Optional[str], json: bool) -> None:
|
|
|
34
33
|
"""List models"""
|
|
35
34
|
client: Together = ctx.obj
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
models_list = response
|
|
39
|
-
|
|
40
|
-
if type == "dedicated":
|
|
41
|
-
models_list = filter_by_dedicated_models(client, models_list)
|
|
36
|
+
models_list = client.models.list(dedicated=type == "dedicated" if type else omit)
|
|
42
37
|
|
|
43
38
|
display_list: List[Dict[str, Any]] = []
|
|
44
39
|
model: BaseModel
|
|
@@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Literal
|
|
|
4
4
|
|
|
5
5
|
from rich import print as rprint
|
|
6
6
|
|
|
7
|
+
from together.types import fine_tuning_estimate_price_params as pe_params
|
|
7
8
|
from together.lib.utils import log_warn_once
|
|
8
9
|
|
|
9
10
|
if TYPE_CHECKING:
|
|
@@ -66,7 +67,7 @@ def create_finetune_request(
|
|
|
66
67
|
hf_model_revision: str | None = None,
|
|
67
68
|
hf_api_token: str | None = None,
|
|
68
69
|
hf_output_repo_name: str | None = None,
|
|
69
|
-
) -> FinetuneRequest:
|
|
70
|
+
) -> tuple[FinetuneRequest, pe_params.TrainingType, pe_params.TrainingMethod]:
|
|
70
71
|
if model is not None and from_checkpoint is not None:
|
|
71
72
|
raise ValueError("You must specify either a model or a checkpoint to start a job from, not both")
|
|
72
73
|
|
|
@@ -233,8 +234,46 @@ def create_finetune_request(
|
|
|
233
234
|
hf_output_repo_name=hf_output_repo_name,
|
|
234
235
|
)
|
|
235
236
|
|
|
236
|
-
|
|
237
|
+
training_type_pe, training_method_pe = create_price_estimation_params(finetune_request)
|
|
237
238
|
|
|
239
|
+
return finetune_request, training_type_pe, training_method_pe
|
|
240
|
+
|
|
241
|
+
def create_price_estimation_params(finetune_request: FinetuneRequest) -> tuple[pe_params.TrainingType, pe_params.TrainingMethod]:
|
|
242
|
+
training_type_cls: pe_params.TrainingType
|
|
243
|
+
if isinstance(finetune_request.training_type, FullTrainingType):
|
|
244
|
+
training_type_cls = pe_params.TrainingTypeFullTrainingType(
|
|
245
|
+
type="Full",
|
|
246
|
+
)
|
|
247
|
+
elif isinstance(finetune_request.training_type, LoRATrainingType):
|
|
248
|
+
training_type_cls = pe_params.TrainingTypeLoRaTrainingType(
|
|
249
|
+
lora_alpha=finetune_request.training_type.lora_alpha,
|
|
250
|
+
lora_r=finetune_request.training_type.lora_r,
|
|
251
|
+
lora_dropout=finetune_request.training_type.lora_dropout,
|
|
252
|
+
lora_trainable_modules=finetune_request.training_type.lora_trainable_modules,
|
|
253
|
+
type="Lora",
|
|
254
|
+
)
|
|
255
|
+
else:
|
|
256
|
+
raise ValueError(f"Unknown training type: {finetune_request.training_type}")
|
|
257
|
+
|
|
258
|
+
training_method_cls: pe_params.TrainingMethod
|
|
259
|
+
if isinstance(finetune_request.training_method, TrainingMethodSFT):
|
|
260
|
+
training_method_cls = pe_params.TrainingMethodTrainingMethodSft(
|
|
261
|
+
method="sft",
|
|
262
|
+
train_on_inputs=finetune_request.training_method.train_on_inputs,
|
|
263
|
+
)
|
|
264
|
+
elif isinstance(finetune_request.training_method, TrainingMethodDPO):
|
|
265
|
+
training_method_cls = pe_params.TrainingMethodTrainingMethodDpo(
|
|
266
|
+
method="dpo",
|
|
267
|
+
dpo_beta=finetune_request.training_method.dpo_beta or 0,
|
|
268
|
+
dpo_normalize_logratios_by_length=finetune_request.training_method.dpo_normalize_logratios_by_length,
|
|
269
|
+
dpo_reference_free=finetune_request.training_method.dpo_reference_free,
|
|
270
|
+
rpo_alpha=finetune_request.training_method.rpo_alpha or 0,
|
|
271
|
+
simpo_gamma=finetune_request.training_method.simpo_gamma or 0,
|
|
272
|
+
)
|
|
273
|
+
else:
|
|
274
|
+
raise ValueError(f"Unknown training method: {finetune_request.training_method}")
|
|
275
|
+
|
|
276
|
+
return training_type_cls, training_method_cls
|
|
238
277
|
|
|
239
278
|
def get_model_limits(client: Together, model: str) -> FinetuneTrainingLimits:
|
|
240
279
|
"""
|
|
@@ -50,6 +50,8 @@ class TranscriptionsResource(SyncAPIResource):
|
|
|
50
50
|
file: FileTypes,
|
|
51
51
|
diarize: bool | Omit = omit,
|
|
52
52
|
language: str | Omit = omit,
|
|
53
|
+
max_speakers: int | Omit = omit,
|
|
54
|
+
min_speakers: int | Omit = omit,
|
|
53
55
|
model: Literal["openai/whisper-large-v3"] | Omit = omit,
|
|
54
56
|
prompt: str | Omit = omit,
|
|
55
57
|
response_format: Literal["json", "verbose_json"] | Omit = omit,
|
|
@@ -82,6 +84,12 @@ class TranscriptionsResource(SyncAPIResource):
|
|
|
82
84
|
language: Optional ISO 639-1 language code. If `auto` is provided, language is
|
|
83
85
|
auto-detected.
|
|
84
86
|
|
|
87
|
+
max_speakers: Maximum number of speakers expected in the audio. Used to improve diarization
|
|
88
|
+
accuracy when the approximate number of speakers is known.
|
|
89
|
+
|
|
90
|
+
min_speakers: Minimum number of speakers expected in the audio. Used to improve diarization
|
|
91
|
+
accuracy when the approximate number of speakers is known.
|
|
92
|
+
|
|
85
93
|
model: Model to use for transcription
|
|
86
94
|
|
|
87
95
|
prompt: Optional text to bias decoding.
|
|
@@ -107,6 +115,8 @@ class TranscriptionsResource(SyncAPIResource):
|
|
|
107
115
|
"file": file,
|
|
108
116
|
"diarize": diarize,
|
|
109
117
|
"language": language,
|
|
118
|
+
"max_speakers": max_speakers,
|
|
119
|
+
"min_speakers": min_speakers,
|
|
110
120
|
"model": model,
|
|
111
121
|
"prompt": prompt,
|
|
112
122
|
"response_format": response_format,
|
|
@@ -161,6 +171,8 @@ class AsyncTranscriptionsResource(AsyncAPIResource):
|
|
|
161
171
|
file: FileTypes,
|
|
162
172
|
diarize: bool | Omit = omit,
|
|
163
173
|
language: str | Omit = omit,
|
|
174
|
+
max_speakers: int | Omit = omit,
|
|
175
|
+
min_speakers: int | Omit = omit,
|
|
164
176
|
model: Literal["openai/whisper-large-v3"] | Omit = omit,
|
|
165
177
|
prompt: str | Omit = omit,
|
|
166
178
|
response_format: Literal["json", "verbose_json"] | Omit = omit,
|
|
@@ -193,6 +205,12 @@ class AsyncTranscriptionsResource(AsyncAPIResource):
|
|
|
193
205
|
language: Optional ISO 639-1 language code. If `auto` is provided, language is
|
|
194
206
|
auto-detected.
|
|
195
207
|
|
|
208
|
+
max_speakers: Maximum number of speakers expected in the audio. Used to improve diarization
|
|
209
|
+
accuracy when the approximate number of speakers is known.
|
|
210
|
+
|
|
211
|
+
min_speakers: Minimum number of speakers expected in the audio. Used to improve diarization
|
|
212
|
+
accuracy when the approximate number of speakers is known.
|
|
213
|
+
|
|
196
214
|
model: Model to use for transcription
|
|
197
215
|
|
|
198
216
|
prompt: Optional text to bias decoding.
|
|
@@ -218,6 +236,8 @@ class AsyncTranscriptionsResource(AsyncAPIResource):
|
|
|
218
236
|
"file": file,
|
|
219
237
|
"diarize": diarize,
|
|
220
238
|
"language": language,
|
|
239
|
+
"max_speakers": max_speakers,
|
|
240
|
+
"min_speakers": min_speakers,
|
|
221
241
|
"model": model,
|
|
222
242
|
"prompt": prompt,
|
|
223
243
|
"response_format": response_format,
|
|
@@ -136,6 +136,14 @@ class CompletionsResource(SyncAPIResource):
|
|
|
136
136
|
|
|
137
137
|
response_format: An object specifying the format that the model must output.
|
|
138
138
|
|
|
139
|
+
Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
|
|
140
|
+
Outputs which ensures the model will match your supplied JSON schema. Learn more
|
|
141
|
+
in the [Structured Outputs guide](https://docs.together.ai/docs/json-mode).
|
|
142
|
+
|
|
143
|
+
Setting to `{ "type": "json_object" }` enables the older JSON mode, which
|
|
144
|
+
ensures the message the model generates is valid JSON. Using `json_schema` is
|
|
145
|
+
preferred for models that support it.
|
|
146
|
+
|
|
139
147
|
safety_model: The name of the moderation model used to validate tokens. Choose from the
|
|
140
148
|
available moderation models found
|
|
141
149
|
[here](https://docs.together.ai/docs/inference-models#moderation-models).
|
|
@@ -277,6 +285,14 @@ class CompletionsResource(SyncAPIResource):
|
|
|
277
285
|
|
|
278
286
|
response_format: An object specifying the format that the model must output.
|
|
279
287
|
|
|
288
|
+
Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
|
|
289
|
+
Outputs which ensures the model will match your supplied JSON schema. Learn more
|
|
290
|
+
in the [Structured Outputs guide](https://docs.together.ai/docs/json-mode).
|
|
291
|
+
|
|
292
|
+
Setting to `{ "type": "json_object" }` enables the older JSON mode, which
|
|
293
|
+
ensures the message the model generates is valid JSON. Using `json_schema` is
|
|
294
|
+
preferred for models that support it.
|
|
295
|
+
|
|
280
296
|
safety_model: The name of the moderation model used to validate tokens. Choose from the
|
|
281
297
|
available moderation models found
|
|
282
298
|
[here](https://docs.together.ai/docs/inference-models#moderation-models).
|
|
@@ -414,6 +430,14 @@ class CompletionsResource(SyncAPIResource):
|
|
|
414
430
|
|
|
415
431
|
response_format: An object specifying the format that the model must output.
|
|
416
432
|
|
|
433
|
+
Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
|
|
434
|
+
Outputs which ensures the model will match your supplied JSON schema. Learn more
|
|
435
|
+
in the [Structured Outputs guide](https://docs.together.ai/docs/json-mode).
|
|
436
|
+
|
|
437
|
+
Setting to `{ "type": "json_object" }` enables the older JSON mode, which
|
|
438
|
+
ensures the message the model generates is valid JSON. Using `json_schema` is
|
|
439
|
+
preferred for models that support it.
|
|
440
|
+
|
|
417
441
|
safety_model: The name of the moderation model used to validate tokens. Choose from the
|
|
418
442
|
available moderation models found
|
|
419
443
|
[here](https://docs.together.ai/docs/inference-models#moderation-models).
|
|
@@ -653,6 +677,14 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
653
677
|
|
|
654
678
|
response_format: An object specifying the format that the model must output.
|
|
655
679
|
|
|
680
|
+
Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
|
|
681
|
+
Outputs which ensures the model will match your supplied JSON schema. Learn more
|
|
682
|
+
in the [Structured Outputs guide](https://docs.together.ai/docs/json-mode).
|
|
683
|
+
|
|
684
|
+
Setting to `{ "type": "json_object" }` enables the older JSON mode, which
|
|
685
|
+
ensures the message the model generates is valid JSON. Using `json_schema` is
|
|
686
|
+
preferred for models that support it.
|
|
687
|
+
|
|
656
688
|
safety_model: The name of the moderation model used to validate tokens. Choose from the
|
|
657
689
|
available moderation models found
|
|
658
690
|
[here](https://docs.together.ai/docs/inference-models#moderation-models).
|
|
@@ -794,6 +826,14 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
794
826
|
|
|
795
827
|
response_format: An object specifying the format that the model must output.
|
|
796
828
|
|
|
829
|
+
Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
|
|
830
|
+
Outputs which ensures the model will match your supplied JSON schema. Learn more
|
|
831
|
+
in the [Structured Outputs guide](https://docs.together.ai/docs/json-mode).
|
|
832
|
+
|
|
833
|
+
Setting to `{ "type": "json_object" }` enables the older JSON mode, which
|
|
834
|
+
ensures the message the model generates is valid JSON. Using `json_schema` is
|
|
835
|
+
preferred for models that support it.
|
|
836
|
+
|
|
797
837
|
safety_model: The name of the moderation model used to validate tokens. Choose from the
|
|
798
838
|
available moderation models found
|
|
799
839
|
[here](https://docs.together.ai/docs/inference-models#moderation-models).
|
|
@@ -931,6 +971,14 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
931
971
|
|
|
932
972
|
response_format: An object specifying the format that the model must output.
|
|
933
973
|
|
|
974
|
+
Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
|
|
975
|
+
Outputs which ensures the model will match your supplied JSON schema. Learn more
|
|
976
|
+
in the [Structured Outputs guide](https://docs.together.ai/docs/json-mode).
|
|
977
|
+
|
|
978
|
+
Setting to `{ "type": "json_object" }` enables the older JSON mode, which
|
|
979
|
+
ensures the message the model generates is valid JSON. Using `json_schema` is
|
|
980
|
+
preferred for models that support it.
|
|
981
|
+
|
|
934
982
|
safety_model: The name of the moderation model used to validate tokens. Choose from the
|
|
935
983
|
available moderation models found
|
|
936
984
|
[here](https://docs.together.ai/docs/inference-models#moderation-models).
|