together 1.5.2__py3-none-any.whl → 1.5.4__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/client.py +5 -0
- together/resources/code_interpreter.py +58 -0
- together/resources/finetune.py +22 -15
- together/types/code_interpreter.py +46 -0
- together/types/finetune.py +1 -1
- {together-1.5.2.dist-info → together-1.5.4.dist-info}/METADATA +1 -1
- {together-1.5.2.dist-info → together-1.5.4.dist-info}/RECORD +10 -8
- {together-1.5.2.dist-info → together-1.5.4.dist-info}/LICENSE +0 -0
- {together-1.5.2.dist-info → together-1.5.4.dist-info}/WHEEL +0 -0
- {together-1.5.2.dist-info → together-1.5.4.dist-info}/entry_points.txt +0 -0
together/client.py
CHANGED
|
@@ -7,6 +7,7 @@ from typing import Dict, TYPE_CHECKING
|
|
|
7
7
|
from together import resources
|
|
8
8
|
from together.constants import BASE_URL, MAX_RETRIES, TIMEOUT_SECS
|
|
9
9
|
from together.error import AuthenticationError
|
|
10
|
+
from together.resources.code_interpreter import CodeInterpreter
|
|
10
11
|
from together.types import TogetherClient
|
|
11
12
|
from together.utils import enforce_trailing_slash
|
|
12
13
|
from together.utils.api_helpers import get_google_colab_secret
|
|
@@ -22,6 +23,7 @@ class Together:
|
|
|
22
23
|
fine_tuning: resources.FineTuning
|
|
23
24
|
rerank: resources.Rerank
|
|
24
25
|
audio: resources.Audio
|
|
26
|
+
code_interpreter: CodeInterpreter
|
|
25
27
|
|
|
26
28
|
# client options
|
|
27
29
|
client: TogetherClient
|
|
@@ -87,6 +89,7 @@ class Together:
|
|
|
87
89
|
self.rerank = resources.Rerank(self.client)
|
|
88
90
|
self.audio = resources.Audio(self.client)
|
|
89
91
|
self.endpoints = resources.Endpoints(self.client)
|
|
92
|
+
self.code_interpreter = CodeInterpreter(self.client)
|
|
90
93
|
|
|
91
94
|
|
|
92
95
|
class AsyncTogether:
|
|
@@ -98,6 +101,7 @@ class AsyncTogether:
|
|
|
98
101
|
models: resources.AsyncModels
|
|
99
102
|
fine_tuning: resources.AsyncFineTuning
|
|
100
103
|
rerank: resources.AsyncRerank
|
|
104
|
+
code_interpreter: CodeInterpreter
|
|
101
105
|
|
|
102
106
|
# client options
|
|
103
107
|
client: TogetherClient
|
|
@@ -161,6 +165,7 @@ class AsyncTogether:
|
|
|
161
165
|
self.models = resources.AsyncModels(self.client)
|
|
162
166
|
self.fine_tuning = resources.AsyncFineTuning(self.client)
|
|
163
167
|
self.rerank = resources.AsyncRerank(self.client)
|
|
168
|
+
self.code_interpreter = CodeInterpreter(self.client)
|
|
164
169
|
|
|
165
170
|
|
|
166
171
|
Client = Together
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Dict, Literal, Optional
|
|
4
|
+
|
|
5
|
+
from together.abstract import api_requestor
|
|
6
|
+
from together.together_response import TogetherResponse
|
|
7
|
+
from together.types import TogetherClient, TogetherRequest
|
|
8
|
+
from together.types.code_interpreter import ExecuteResponse
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class CodeInterpreter:
|
|
12
|
+
"""Code Interpreter resource for executing code snippets."""
|
|
13
|
+
|
|
14
|
+
def __init__(self, client: TogetherClient) -> None:
|
|
15
|
+
self._client = client
|
|
16
|
+
|
|
17
|
+
def run(
|
|
18
|
+
self,
|
|
19
|
+
code: str,
|
|
20
|
+
language: Literal["python"],
|
|
21
|
+
session_id: Optional[str] = None,
|
|
22
|
+
) -> ExecuteResponse:
|
|
23
|
+
"""Execute a code snippet.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
code (str): Code snippet to execute
|
|
27
|
+
language (str): Programming language for the code to execute. Currently only supports Python.
|
|
28
|
+
session_id (str, optional): Identifier of the current session. Used to make follow-up calls.
|
|
29
|
+
|
|
30
|
+
Returns:
|
|
31
|
+
ExecuteResponse: Object containing execution results and outputs
|
|
32
|
+
"""
|
|
33
|
+
requestor = api_requestor.APIRequestor(
|
|
34
|
+
client=self._client,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
data: Dict[str, str] = {
|
|
38
|
+
"code": code,
|
|
39
|
+
"language": language,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if session_id is not None:
|
|
43
|
+
data["session_id"] = session_id
|
|
44
|
+
|
|
45
|
+
# Use absolute URL to bypass the /v1 prefix
|
|
46
|
+
response, _, _ = requestor.request(
|
|
47
|
+
options=TogetherRequest(
|
|
48
|
+
method="POST",
|
|
49
|
+
url="/tci/execute",
|
|
50
|
+
params=data,
|
|
51
|
+
),
|
|
52
|
+
stream=False,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
assert isinstance(response, TogetherResponse)
|
|
56
|
+
|
|
57
|
+
# Return the response data directly since our types match the API structure
|
|
58
|
+
return ExecuteResponse(**response.data)
|
together/resources/finetune.py
CHANGED
|
@@ -87,6 +87,9 @@ def createFinetuneRequest(
|
|
|
87
87
|
"You must specify either a model or a checkpoint to start a job from, not both"
|
|
88
88
|
)
|
|
89
89
|
|
|
90
|
+
if model is None and from_checkpoint is None:
|
|
91
|
+
raise ValueError("You must specify either a model or a checkpoint")
|
|
92
|
+
|
|
90
93
|
if batch_size == "max":
|
|
91
94
|
log_warn_once(
|
|
92
95
|
"Starting from together>=1.3.0, "
|
|
@@ -96,6 +99,8 @@ def createFinetuneRequest(
|
|
|
96
99
|
warmup_ratio = 0.0
|
|
97
100
|
|
|
98
101
|
training_type: TrainingType = FullTrainingType()
|
|
102
|
+
max_batch_size: int = 0
|
|
103
|
+
min_batch_size: int = 0
|
|
99
104
|
if lora:
|
|
100
105
|
if model_limits.lora_training is None:
|
|
101
106
|
raise ValueError("LoRA adapters are not supported for the selected model.")
|
|
@@ -108,18 +113,26 @@ def createFinetuneRequest(
|
|
|
108
113
|
lora_trainable_modules=lora_trainable_modules,
|
|
109
114
|
)
|
|
110
115
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
else model_limits.lora_training.max_batch_size
|
|
115
|
-
)
|
|
116
|
+
max_batch_size = model_limits.lora_training.max_batch_size
|
|
117
|
+
min_batch_size = model_limits.lora_training.min_batch_size
|
|
118
|
+
|
|
116
119
|
else:
|
|
117
120
|
if model_limits.full_training is None:
|
|
118
121
|
raise ValueError("Full training is not supported for the selected model.")
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
|
|
123
|
+
max_batch_size = model_limits.full_training.max_batch_size
|
|
124
|
+
min_batch_size = model_limits.full_training.min_batch_size
|
|
125
|
+
|
|
126
|
+
batch_size = batch_size if batch_size != "max" else max_batch_size
|
|
127
|
+
|
|
128
|
+
if batch_size > max_batch_size:
|
|
129
|
+
raise ValueError(
|
|
130
|
+
"Requested batch size is higher that the maximum allowed value."
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
if batch_size < min_batch_size:
|
|
134
|
+
raise ValueError(
|
|
135
|
+
"Requested batch size is lower that the minimum allowed value."
|
|
123
136
|
)
|
|
124
137
|
|
|
125
138
|
if warmup_ratio > 1 or warmup_ratio < 0:
|
|
@@ -346,9 +359,6 @@ class FineTuning:
|
|
|
346
359
|
FinetuneResponse: Object containing information about fine-tuning job.
|
|
347
360
|
"""
|
|
348
361
|
|
|
349
|
-
if model is None and from_checkpoint is None:
|
|
350
|
-
raise ValueError("You must specify either a model or a checkpoint")
|
|
351
|
-
|
|
352
362
|
requestor = api_requestor.APIRequestor(
|
|
353
363
|
client=self._client,
|
|
354
364
|
)
|
|
@@ -737,9 +747,6 @@ class AsyncFineTuning:
|
|
|
737
747
|
FinetuneResponse: Object containing information about fine-tuning job.
|
|
738
748
|
"""
|
|
739
749
|
|
|
740
|
-
if model is None and from_checkpoint is None:
|
|
741
|
-
raise ValueError("You must specify either a model or a checkpoint")
|
|
742
|
-
|
|
743
750
|
requestor = api_requestor.APIRequestor(
|
|
744
751
|
client=self._client,
|
|
745
752
|
)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict, Literal, Union
|
|
4
|
+
|
|
5
|
+
from pydantic import Field
|
|
6
|
+
|
|
7
|
+
from together.types.endpoints import TogetherJSONModel
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class InterpreterOutput(TogetherJSONModel):
|
|
11
|
+
"""Base class for interpreter output types."""
|
|
12
|
+
|
|
13
|
+
type: Literal["stdout", "stderr", "error", "display_data", "execute_result"] = (
|
|
14
|
+
Field(description="The type of output")
|
|
15
|
+
)
|
|
16
|
+
data: Union[str, Dict[str, Any]] = Field(description="The output data")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ExecuteResponseData(TogetherJSONModel):
|
|
20
|
+
"""Data from code execution response."""
|
|
21
|
+
|
|
22
|
+
outputs: list[InterpreterOutput] = Field(
|
|
23
|
+
description="List of outputs from execution", default_factory=list
|
|
24
|
+
)
|
|
25
|
+
errors: Union[str, None] = Field(
|
|
26
|
+
description="Any errors that occurred during execution", default=None
|
|
27
|
+
)
|
|
28
|
+
session_id: str = Field(
|
|
29
|
+
description="Identifier of the current session. Used to make follow-up calls."
|
|
30
|
+
)
|
|
31
|
+
status: str = Field(description="Status of the execution", default="completed")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class ExecuteResponse(TogetherJSONModel):
|
|
35
|
+
"""Response from code execution."""
|
|
36
|
+
|
|
37
|
+
data: ExecuteResponseData = Field(
|
|
38
|
+
description="The response data containing outputs and session information"
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
__all__ = [
|
|
43
|
+
"InterpreterOutput",
|
|
44
|
+
"ExecuteResponseData",
|
|
45
|
+
"ExecuteResponse",
|
|
46
|
+
]
|
together/types/finetune.py
CHANGED
|
@@ -12,7 +12,7 @@ together/cli/api/images.py,sha256=GADSeaNUHUVMtWovmccGuKc28IJ9E_v4vAEwYHJhu5o,26
|
|
|
12
12
|
together/cli/api/models.py,sha256=CXw8B1hqNkadogi58GIXhLg_dTJnvTBaE7Kq1_xQ-10,1423
|
|
13
13
|
together/cli/api/utils.py,sha256=IuqYWPnLI38_Bqd7lj8V_SnGdYc59pRmMbQmciS4FsM,1326
|
|
14
14
|
together/cli/cli.py,sha256=YCDzbXpC5is0rs2PEkUPrIhYuzdyrihQ8GVR_TlDv5s,2054
|
|
15
|
-
together/client.py,sha256=
|
|
15
|
+
together/client.py,sha256=lN_KfJs2gCdLfQ5GBrVKin-4ZL7L7UQf9wjofWQ7sXg,5682
|
|
16
16
|
together/constants.py,sha256=UDJhEylJFmdm4bedBDpvqYXBj5Or3k7z9GWtkRY_dZQ,1526
|
|
17
17
|
together/error.py,sha256=HU6247CyzCFjaxL9A0XYbXZ6fY_ebRg0FEYjI4Skogs,5515
|
|
18
18
|
together/filemanager.py,sha256=QHhBn73oVFdgUpSYXYLmJzHJ9c5wYEMJC0ur6ZgDeYo,11269
|
|
@@ -29,11 +29,12 @@ together/resources/audio/__init__.py,sha256=e7xp0Lkp_nMAHXcuFHS7dLXP_YqTPMMZIilW
|
|
|
29
29
|
together/resources/audio/speech.py,sha256=81ib_gIo-Rxoaipx2Pi9ZsKnOTjeFPwSlBrcUkyX5xk,5211
|
|
30
30
|
together/resources/chat/__init__.py,sha256=RsTptdP8MeGjcdIjze896-J27cRvCbUoMft0X2BVlQ8,617
|
|
31
31
|
together/resources/chat/completions.py,sha256=jYiNZsWa8RyEacL0VgxWj1egJ857oU4nxIY8uqGHcaU,14459
|
|
32
|
+
together/resources/code_interpreter.py,sha256=gkzBgGZ6XckrUIB_ml0ju3_ACtNT3116cqYFeupyYKM,1788
|
|
32
33
|
together/resources/completions.py,sha256=5Wa-ZjPCxRcam6CDe7KgGYlTA7yJZMmd5TrRgGCL_ug,11726
|
|
33
34
|
together/resources/embeddings.py,sha256=PTvLb82yjG_-iQOyuhsilp77Fr7gZ0o6WD2KeRnKoxs,2675
|
|
34
35
|
together/resources/endpoints.py,sha256=NNjp-wyzOotzlscGGrANhOHxQBjHTN8f5kTQTH_CLvE,17177
|
|
35
36
|
together/resources/files.py,sha256=bnPbaF25e4InBRPvHwXHXT-oSX1Z1sZRsnQW5wq82U4,4990
|
|
36
|
-
together/resources/finetune.py,sha256=
|
|
37
|
+
together/resources/finetune.py,sha256=IUOBHSfeNNpZIiuL2w51SUZrqNvmbmvxs8kr-Ry15_w,36079
|
|
37
38
|
together/resources/images.py,sha256=LQUjKPaFxWTqOAPnyF1Pp7Rz4NLOYhmoKwshpYiprEM,4923
|
|
38
39
|
together/resources/models.py,sha256=qgmAXv61Cq4oLxytenEZBywA8shldDHYxJ_EAu_4JWQ,3864
|
|
39
40
|
together/resources/rerank.py,sha256=3Ju_aRSyZ1s_3zCSNZnSnEJErUVmt2xa3M8z1nvejMA,3931
|
|
@@ -42,13 +43,14 @@ together/types/__init__.py,sha256=PBhPpJklsF5-IiI2aWLK2Srhb36m0v93jR8xv8G7Q_0,27
|
|
|
42
43
|
together/types/abstract.py,sha256=1lFQI_3WjsR_t1128AeKW0aTk6EiM6Gh1J3ZuyLLPao,642
|
|
43
44
|
together/types/audio_speech.py,sha256=jlj8BZf3dkIDARF1P11fuenVLj4try8Yx4RN-EAkhOU,2609
|
|
44
45
|
together/types/chat_completions.py,sha256=ggwt1LlBXTB_hZKbtLsjg8j-gXxO8pUUQfTrxUmRXHU,5078
|
|
46
|
+
together/types/code_interpreter.py,sha256=Ali8Prv9TXqcvCMeYffWbOsTmljs8sgvWIY3-kkcQ7M,1331
|
|
45
47
|
together/types/common.py,sha256=kxZ-N9xtBsGYZBmbIWnZ0rfT3Pn8PFB7sAbp3iv96pw,1525
|
|
46
48
|
together/types/completions.py,sha256=o3FR5ixsTUj-a3pmOUzbSQg-hESVhpqrC9UD__VCqr4,2971
|
|
47
49
|
together/types/embeddings.py,sha256=J7grkYYn7xhqeKaBO2T-8XQRtHhkzYzymovtGdIUK5A,751
|
|
48
50
|
together/types/endpoints.py,sha256=EzNhHOoQ_D9fUdNQtxQPeSWiFzdFLqpNodN0YLmv_h0,4393
|
|
49
51
|
together/types/error.py,sha256=OVlCs3cx_2WhZK4JzHT8SQyRIIqKOP1AZQ4y1PydjAE,370
|
|
50
52
|
together/types/files.py,sha256=-rEUfsV6f2vZB9NrFxT4_933ubsDIUNkPB-3OlOFk4A,1954
|
|
51
|
-
together/types/finetune.py,sha256=
|
|
53
|
+
together/types/finetune.py,sha256=gREerRx3NA1mOXf2hGq6mh_FjpePNK5TiGbVGkRaDZQ,10494
|
|
52
54
|
together/types/images.py,sha256=xnC-FZGdZU30WSFTybfGneWxb-kj0ZGufJsgHtB8j0k,980
|
|
53
55
|
together/types/models.py,sha256=nwQIZGHKZpX9I6mK8z56VW70YC6Ry6JGsVa0s99QVxc,1055
|
|
54
56
|
together/types/rerank.py,sha256=qZfuXOn7MZ6ly8hpJ_MZ7OU_Bi1-cgYNSB20Wja8Qkk,1061
|
|
@@ -58,8 +60,8 @@ together/utils/api_helpers.py,sha256=2K0O6qeEQ2zVFvi5NBN5m2kjZJaS3-JfKFecQ7SmGaw
|
|
|
58
60
|
together/utils/files.py,sha256=rfp10qU0urtWOXXFeasFtO9xp-1KIhM3S43JxcnHmL0,16438
|
|
59
61
|
together/utils/tools.py,sha256=H2MTJhEqtBllaDvOyZehIO_IVNK3P17rSDeILtJIVag,2964
|
|
60
62
|
together/version.py,sha256=p03ivHyE0SyWU4jAnRTBi_sOwywVWoZPU4g2gzRgG-Y,126
|
|
61
|
-
together-1.5.
|
|
62
|
-
together-1.5.
|
|
63
|
-
together-1.5.
|
|
64
|
-
together-1.5.
|
|
65
|
-
together-1.5.
|
|
63
|
+
together-1.5.4.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
64
|
+
together-1.5.4.dist-info/METADATA,sha256=E4OMaDCtldMKAzl55Fr56riUmPpfj287kvheY3DDRUE,14397
|
|
65
|
+
together-1.5.4.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
|
66
|
+
together-1.5.4.dist-info/entry_points.txt,sha256=G-b5NKW6lUUf1V1fH8IPTBb7jXnK7lhbX9H1zTEJXPs,50
|
|
67
|
+
together-1.5.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|