together 2.0.0a9__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.
Files changed (30) hide show
  1. together/_types.py +3 -2
  2. together/_version.py +1 -1
  3. together/lib/cli/api/fine_tuning.py +65 -3
  4. together/lib/cli/api/models.py +1 -6
  5. together/lib/resources/fine_tuning.py +41 -2
  6. together/resources/chat/completions.py +48 -0
  7. together/resources/fine_tuning.py +213 -5
  8. together/resources/models.py +41 -5
  9. together/types/__init__.py +3 -0
  10. together/types/audio/voice_list_response.py +4 -0
  11. together/types/autoscaling.py +2 -0
  12. together/types/autoscaling_param.py +2 -0
  13. together/types/chat/completion_create_params.py +78 -5
  14. together/types/dedicated_endpoint.py +2 -0
  15. together/types/endpoint_list_avzones_response.py +2 -0
  16. together/types/endpoint_list_response.py +2 -0
  17. together/types/execute_response.py +7 -0
  18. together/types/fine_tuning_cancel_response.py +6 -0
  19. together/types/fine_tuning_estimate_price_params.py +98 -0
  20. together/types/fine_tuning_estimate_price_response.py +24 -0
  21. together/types/fine_tuning_list_response.py +6 -0
  22. together/types/hardware_list_response.py +8 -0
  23. together/types/model_list_params.py +12 -0
  24. together/types/video_job.py +8 -0
  25. {together-2.0.0a9.dist-info → together-2.0.0a10.dist-info}/METADATA +9 -11
  26. {together-2.0.0a9.dist-info → together-2.0.0a10.dist-info}/RECORD +29 -27
  27. together/lib/resources/models.py +0 -35
  28. {together-2.0.0a9.dist-info → together-2.0.0a10.dist-info}/WHEEL +0 -0
  29. {together-2.0.0a9.dist-info → together-2.0.0a10.dist-info}/entry_points.txt +0 -0
  30. {together-2.0.0a9.dist-info → together-2.0.0a10.dist-info}/licenses/LICENSE +0 -0
@@ -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
- """Lists all of Together's open-source models"""
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, extra_query=extra_query, extra_body=extra_body, timeout=timeout
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
- """Lists all of Together's open-source models"""
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, extra_query=extra_query, extra_body=extra_body, timeout=timeout
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
  )
@@ -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
  )
@@ -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]
@@ -6,6 +6,8 @@ __all__ = ["Autoscaling"]
6
6
 
7
7
 
8
8
  class Autoscaling(BaseModel):
9
+ """Configuration for automatic scaling of replicas based on demand."""
10
+
9
11
  max_replicas: int
10
12
  """The maximum number of replicas to scale up to under load"""
11
13
 
@@ -8,6 +8,8 @@ __all__ = ["AutoscalingParam"]
8
8
 
9
9
 
10
10
  class AutoscalingParam(TypedDict, total=False):
11
+ """Configuration for automatic scaling of replicas based on demand."""
12
+
11
13
  max_replicas: Required[int]
12
14
  """The maximum number of replicas to scale up to under load"""
13
15
 
@@ -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 ResponseFormat(TypedDict, total=False):
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
- """The schema of the response format."""
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
 
@@ -10,6 +10,8 @@ __all__ = ["DedicatedEndpoint"]
10
10
 
11
11
 
12
12
  class DedicatedEndpoint(BaseModel):
13
+ """Details about a dedicated endpoint deployment"""
14
+
13
15
  id: str
14
16
  """Unique identifier for the endpoint"""
15
17
 
@@ -8,4 +8,6 @@ __all__ = ["EndpointListAvzonesResponse"]
8
8
 
9
9
 
10
10
  class EndpointListAvzonesResponse(BaseModel):
11
+ """List of unique availability zones"""
12
+
11
13
  avzones: List[str]
@@ -10,6 +10,8 @@ __all__ = ["EndpointListResponse", "Data"]
10
10
 
11
11
 
12
12
  class Data(BaseModel):
13
+ """Details about an endpoint when listed via the list endpoint"""
14
+
13
15
  id: str
14
16
  """Unique identifier for the endpoint"""
15
17
 
@@ -22,12 +22,19 @@ __all__ = [
22
22
 
23
23
 
24
24
  class SuccessfulExecutionDataOutputStreamOutput(BaseModel):
25
+ """Outputs that were printed to stdout or stderr"""
26
+
25
27
  data: str
26
28
 
27
29
  type: Literal["stdout", "stderr"]
28
30
 
29
31
 
30
32
  class SuccessfulExecutionDataOutputError(BaseModel):
33
+ """Errors and exceptions that occurred.
34
+
35
+ If this output type is present, your code did not execute successfully.
36
+ """
37
+
31
38
  data: str
32
39
 
33
40
  type: Literal["error"]
@@ -43,6 +43,8 @@ LrSchedulerLrSchedulerArgs: TypeAlias = Union[
43
43
 
44
44
 
45
45
  class LrScheduler(BaseModel):
46
+ """Learning rate scheduler configuration"""
47
+
46
48
  lr_scheduler_type: Literal["linear", "cosine"]
47
49
 
48
50
  lr_scheduler_args: Optional[LrSchedulerLrSchedulerArgs] = None
@@ -95,6 +97,10 @@ TrainingType: TypeAlias = Union[TrainingTypeFullTrainingType, TrainingTypeLoRaTr
95
97
 
96
98
 
97
99
  class FineTuningCancelResponse(BaseModel):
100
+ """
101
+ A truncated version of the fine-tune response, used for POST /fine-tunes, GET /fine-tunes and POST /fine-tunes/{id}/cancel endpoints
102
+ """
103
+
98
104
  id: str
99
105
  """Unique identifier for the fine-tune job"""
100
106
 
@@ -0,0 +1,98 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Union
6
+ from typing_extensions import Literal, Required, TypeAlias, TypedDict
7
+
8
+ __all__ = [
9
+ "FineTuningEstimatePriceParams",
10
+ "TrainingMethod",
11
+ "TrainingMethodTrainingMethodSft",
12
+ "TrainingMethodTrainingMethodDpo",
13
+ "TrainingType",
14
+ "TrainingTypeFullTrainingType",
15
+ "TrainingTypeLoRaTrainingType",
16
+ ]
17
+
18
+
19
+ class FineTuningEstimatePriceParams(TypedDict, total=False):
20
+ training_file: Required[str]
21
+ """File-ID of a training file uploaded to the Together API"""
22
+
23
+ from_checkpoint: str
24
+ """The checkpoint identifier to continue training from a previous fine-tuning job.
25
+
26
+ Format is `{$JOB_ID}` or `{$OUTPUT_MODEL_NAME}` or `{$JOB_ID}:{$STEP}` or
27
+ `{$OUTPUT_MODEL_NAME}:{$STEP}`. The step value is optional; without it, the
28
+ final checkpoint will be used.
29
+ """
30
+
31
+ model: str
32
+ """Name of the base model to run fine-tune job on"""
33
+
34
+ n_epochs: int
35
+ """
36
+ Number of complete passes through the training dataset (higher values may
37
+ improve results but increase cost and risk of overfitting)
38
+ """
39
+
40
+ n_evals: int
41
+ """Number of evaluations to be run on a given validation set during training"""
42
+
43
+ training_method: TrainingMethod
44
+ """The training method to use.
45
+
46
+ 'sft' for Supervised Fine-Tuning or 'dpo' for Direct Preference Optimization.
47
+ """
48
+
49
+ training_type: TrainingType
50
+
51
+ validation_file: str
52
+ """File-ID of a validation file uploaded to the Together API"""
53
+
54
+
55
+ class TrainingMethodTrainingMethodSft(TypedDict, total=False):
56
+ method: Required[Literal["sft"]]
57
+
58
+ train_on_inputs: Required[Union[bool, Literal["auto"]]]
59
+ """
60
+ Whether to mask the user messages in conversational data or prompts in
61
+ instruction data.
62
+ """
63
+
64
+
65
+ class TrainingMethodTrainingMethodDpo(TypedDict, total=False):
66
+ method: Required[Literal["dpo"]]
67
+
68
+ dpo_beta: float
69
+
70
+ dpo_normalize_logratios_by_length: bool
71
+
72
+ dpo_reference_free: bool
73
+
74
+ rpo_alpha: float
75
+
76
+ simpo_gamma: float
77
+
78
+
79
+ TrainingMethod: TypeAlias = Union[TrainingMethodTrainingMethodSft, TrainingMethodTrainingMethodDpo]
80
+
81
+
82
+ class TrainingTypeFullTrainingType(TypedDict, total=False):
83
+ type: Required[Literal["Full"]]
84
+
85
+
86
+ class TrainingTypeLoRaTrainingType(TypedDict, total=False):
87
+ lora_alpha: Required[int]
88
+
89
+ lora_r: Required[int]
90
+
91
+ type: Required[Literal["Lora"]]
92
+
93
+ lora_dropout: float
94
+
95
+ lora_trainable_modules: str
96
+
97
+
98
+ TrainingType: TypeAlias = Union[TrainingTypeFullTrainingType, TrainingTypeLoRaTrainingType]
@@ -0,0 +1,24 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import Optional
4
+
5
+ from .._models import BaseModel
6
+
7
+ __all__ = ["FineTuningEstimatePriceResponse"]
8
+
9
+
10
+ class FineTuningEstimatePriceResponse(BaseModel):
11
+ allowed_to_proceed: Optional[bool] = None
12
+ """Whether the user is allowed to proceed with the fine-tuning job"""
13
+
14
+ estimated_eval_token_count: Optional[float] = None
15
+ """The estimated number of tokens for evaluation"""
16
+
17
+ estimated_total_price: Optional[float] = None
18
+ """The price of the fine-tuning job"""
19
+
20
+ estimated_train_token_count: Optional[float] = None
21
+ """The estimated number of tokens to be trained"""
22
+
23
+ user_limit: Optional[float] = None
24
+ """The user's credit limit in dollars"""
@@ -44,6 +44,8 @@ DataLrSchedulerLrSchedulerArgs: TypeAlias = Union[
44
44
 
45
45
 
46
46
  class DataLrScheduler(BaseModel):
47
+ """Learning rate scheduler configuration"""
48
+
47
49
  lr_scheduler_type: Literal["linear", "cosine"]
48
50
 
49
51
  lr_scheduler_args: Optional[DataLrSchedulerLrSchedulerArgs] = None
@@ -96,6 +98,10 @@ DataTrainingType: TypeAlias = Union[DataTrainingTypeFullTrainingType, DataTraini
96
98
 
97
99
 
98
100
  class Data(BaseModel):
101
+ """
102
+ A truncated version of the fine-tune response, used for POST /fine-tunes, GET /fine-tunes and POST /fine-tunes/{id}/cancel endpoints
103
+ """
104
+
99
105
  id: str
100
106
  """Unique identifier for the fine-tune job"""
101
107
 
@@ -10,11 +10,15 @@ __all__ = ["HardwareListResponse", "Data", "DataPricing", "DataSpecs", "DataAvai
10
10
 
11
11
 
12
12
  class DataPricing(BaseModel):
13
+ """Pricing details for using an endpoint"""
14
+
13
15
  cents_per_minute: float
14
16
  """Cost per minute of endpoint uptime in cents"""
15
17
 
16
18
 
17
19
  class DataSpecs(BaseModel):
20
+ """Detailed specifications of a hardware configuration"""
21
+
18
22
  gpu_count: int
19
23
  """Number of GPUs in this configuration"""
20
24
 
@@ -29,11 +33,15 @@ class DataSpecs(BaseModel):
29
33
 
30
34
 
31
35
  class DataAvailability(BaseModel):
36
+ """Indicates the current availability status of a hardware configuration"""
37
+
32
38
  status: Literal["available", "unavailable", "insufficient"]
33
39
  """The availability status of the hardware configuration"""
34
40
 
35
41
 
36
42
  class Data(BaseModel):
43
+ """Hardware configuration details with optional availability status"""
44
+
37
45
  id: str
38
46
  """Unique identifier for the hardware configuration"""
39
47
 
@@ -0,0 +1,12 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing_extensions import TypedDict
6
+
7
+ __all__ = ["ModelListParams"]
8
+
9
+
10
+ class ModelListParams(TypedDict, total=False):
11
+ dedicated: bool
12
+ """Filter models to only return dedicated models"""
@@ -9,12 +9,18 @@ __all__ = ["VideoJob", "Error", "Outputs"]
9
9
 
10
10
 
11
11
  class Error(BaseModel):
12
+ """Error payload that explains why generation failed, if applicable."""
13
+
12
14
  message: str
13
15
 
14
16
  code: Optional[str] = None
15
17
 
16
18
 
17
19
  class Outputs(BaseModel):
20
+ """
21
+ Available upon completion, the outputs provides the cost charged and the hosted url to access the video
22
+ """
23
+
18
24
  cost: int
19
25
  """The cost of generated video charged to the owners account."""
20
26
 
@@ -23,6 +29,8 @@ class Outputs(BaseModel):
23
29
 
24
30
 
25
31
  class VideoJob(BaseModel):
32
+ """Structured information describing a generated video job."""
33
+
26
34
  id: str
27
35
  """Unique identifier for the video job."""
28
36
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: together
3
- Version: 2.0.0a9
3
+ Version: 2.0.0a10
4
4
  Summary: The official Python library for the together API
5
5
  Project-URL: Homepage, https://github.com/togethercomputer/together-py
6
6
  Project-URL: Repository, https://github.com/togethercomputer/together-py
@@ -232,17 +232,15 @@ from together import Together
232
232
 
233
233
  client = Together()
234
234
 
235
- chat_completion = client.chat.completions.create(
236
- messages=[
237
- {
238
- "content": "content",
239
- "role": "system",
240
- }
241
- ],
242
- model="meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo",
243
- response_format={},
235
+ dedicated_endpoint = client.endpoints.create(
236
+ autoscaling={
237
+ "max_replicas": 5,
238
+ "min_replicas": 2,
239
+ },
240
+ hardware="1x_nvidia_a100_80gb_sxm",
241
+ model="meta-llama/Llama-3-8b-chat-hf",
244
242
  )
245
- print(chat_completion.response_format)
243
+ print(dedicated_endpoint.autoscaling)
246
244
  ```
247
245
 
248
246
  The async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.