together 1.1.5__py3-none-any.whl → 1.2.1__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/cli/api/files.py CHANGED
@@ -32,12 +32,17 @@ def files(ctx: click.Context) -> None:
32
32
  default=FilePurpose.FineTune.value,
33
33
  help="Purpose of file upload. Acceptable values in enum `together.types.FilePurpose`. Defaults to `fine-tunes`.",
34
34
  )
35
- def upload(ctx: click.Context, file: pathlib.Path, purpose: str) -> None:
35
+ @click.option(
36
+ "--check/--no-check",
37
+ default=True,
38
+ help="Whether to check the file before uploading.",
39
+ )
40
+ def upload(ctx: click.Context, file: pathlib.Path, purpose: str, check: bool) -> None:
36
41
  """Upload file"""
37
42
 
38
43
  client: Together = ctx.obj
39
44
 
40
- response = client.files.upload(file=file, purpose=purpose)
45
+ response = client.files.upload(file=file, purpose=purpose, check=check)
41
46
 
42
47
  click.echo(json.dumps(response.model_dump(), indent=4))
43
48
 
together/error.py CHANGED
@@ -23,9 +23,12 @@ class TogetherException(Exception):
23
23
  if isinstance(message, TogetherErrorResponse)
24
24
  else message
25
25
  )
26
- self._message = f"Error code: {http_status} - {_message}"
26
+ if http_status is not None:
27
+ self._message = f"Error code: {http_status} - {_message}"
28
+ else:
29
+ self._message = str(_message)
27
30
 
28
- super(TogetherException, self).__init__(self._message)
31
+ super().__init__(self._message)
29
32
 
30
33
  self.http_status = http_status
31
34
  self.headers = headers or {}
together/legacy/files.py CHANGED
@@ -53,9 +53,11 @@ class Files:
53
53
 
54
54
  client = together.Together(api_key=api_key)
55
55
 
56
- response = client.files.upload(file=file).model_dump()
56
+ # disabling the check, because it was run previously
57
+ response = client.files.upload(file=file, check=False).model_dump()
57
58
 
58
- response["report_dict"] = report_dict
59
+ if check:
60
+ response["report_dict"] = report_dict
59
61
 
60
62
  return response
61
63
 
@@ -1,8 +1,10 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from pathlib import Path
4
+ from pprint import pformat
4
5
 
5
6
  from together.abstract import api_requestor
7
+ from together.error import FileTypeError
6
8
  from together.filemanager import DownloadManager, UploadManager
7
9
  from together.together_response import TogetherResponse
8
10
  from together.types import (
@@ -14,7 +16,7 @@ from together.types import (
14
16
  TogetherClient,
15
17
  TogetherRequest,
16
18
  )
17
- from together.utils import normalize_key
19
+ from together.utils import check_file, normalize_key
18
20
 
19
21
 
20
22
  class Files:
@@ -22,10 +24,21 @@ class Files:
22
24
  self._client = client
23
25
 
24
26
  def upload(
25
- self, file: Path | str, *, purpose: FilePurpose | str = FilePurpose.FineTune
27
+ self,
28
+ file: Path | str,
29
+ *,
30
+ purpose: FilePurpose | str = FilePurpose.FineTune,
31
+ check: bool = True,
26
32
  ) -> FileResponse:
27
33
  upload_manager = UploadManager(self._client)
28
34
 
35
+ if check:
36
+ report_dict = check_file(file)
37
+ if not report_dict["is_check_passed"]:
38
+ raise FileTypeError(
39
+ f"Invalid file supplied, failed to upload. Report:\n{pformat(report_dict)}"
40
+ )
41
+
29
42
  if isinstance(file, str):
30
43
  file = Path(file)
31
44
 
@@ -61,7 +61,7 @@ class CompletionRequest(BaseModel):
61
61
  class CompletionChoicesData(BaseModel):
62
62
  index: int
63
63
  logprobs: LogprobsPart | None = None
64
- finish_reason: FinishReason
64
+ finish_reason: FinishReason | None = None
65
65
  text: str
66
66
 
67
67
 
@@ -24,6 +24,7 @@ class FinetuneJobStatus(str, Enum):
24
24
  STATUS_CANCEL_REQUESTED = "cancel_requested"
25
25
  STATUS_CANCELLED = "cancelled"
26
26
  STATUS_ERROR = "error"
27
+ STATUS_USER_ERROR = "user_error"
27
28
  STATUS_COMPLETED = "completed"
28
29
 
29
30
 
@@ -67,6 +68,7 @@ class FinetuneEventType(str, Enum):
67
68
  MODEL_UPLOAD_COMPLETE = "MODEL_UPLOAD_COMPLETE"
68
69
  JOB_COMPLETE = "JOB_COMPLETE"
69
70
  JOB_ERROR = "JOB_ERROR"
71
+ JOB_USER_ERROR = "JOB_USER_ERROR"
70
72
  CANCEL_REQUESTED = "CANCEL_REQUESTED"
71
73
  JOB_RESTARTED = "JOB_RESTARTED"
72
74
  REFUND = "REFUND"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: together
3
- Version: 1.1.5
3
+ Version: 1.2.1
4
4
  Summary: Python client for Together's Cloud Platform!
5
5
  Home-page: https://github.com/togethercomputer/together-python
6
6
  License: Apache-2.0
@@ -5,20 +5,20 @@ together/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  together/cli/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  together/cli/api/chat.py,sha256=qmDcYohGe1ODfvYEDN6Z2eZO3qODgmeUTll8P5qoKYQ,9170
7
7
  together/cli/api/completions.py,sha256=v6KvGsXnPCdSM7WIu_QmKXOA4iVjW93k3dLwfIBkxPQ,4199
8
- together/cli/api/files.py,sha256=1iOZpCDC-R2s7sOxWe539DU9KKJcrZGayeeksQLutRk,3186
8
+ together/cli/api/files.py,sha256=hOiN1ftwbSAs3gcVqwmPymhmzDYiIUrFWXFHVcWWom8,3329
9
9
  together/cli/api/finetune.py,sha256=mSQSasmVQLtNzjJLeoEEwvewfEcpSkjKyozWqwb-7p0,5417
10
10
  together/cli/api/images.py,sha256=01dFYa2sK1HqUwVCD9FlwcjqkYWLoNxFZkzok13EriE,2363
11
11
  together/cli/api/models.py,sha256=xWEzu8ZpxM_Pz9KEjRPRVuv_v22RayYZ4QcgiezT5tE,1126
12
12
  together/cli/cli.py,sha256=RC0tgapkSOFjsRPg8p-8dx9D2LDzm8YmVCHUjk_aVyQ,1977
13
13
  together/client.py,sha256=7QT5lwn7-QGf0vtgbhslQujm4986CgfE2spyMYP4JyU,4774
14
14
  together/constants.py,sha256=WHe6JA9TliwgErkCnovWPS9w9xXfA3X5PtKJv_y2JxQ,908
15
- together/error.py,sha256=cILzwDde18INNFYgbYdgvVfOhEjRZM9sg9I8Rl6nc_Y,5329
15
+ together/error.py,sha256=IWomy3KpDyuWS7uK4US2a4CkG4HC3oQEGQvVtul4nM8,5402
16
16
  together/filemanager.py,sha256=QHhBn73oVFdgUpSYXYLmJzHJ9c5wYEMJC0ur6ZgDeYo,11269
17
17
  together/legacy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  together/legacy/base.py,sha256=ehrX1SCfRbK5OA83wL1q7-tfF-yuZOUxzjxYfFtdvvQ,727
19
19
  together/legacy/complete.py,sha256=8itEMlyuora2EIO-b-tvjvpHfKhxckDEiqaN-z6ccQs,2343
20
20
  together/legacy/embeddings.py,sha256=Sm4XNVBm00JUNQT65hlZE5tIwsKar2PdmK0_lZ4dw_4,591
21
- together/legacy/files.py,sha256=Xi5hUnfiZX2IqHkoKLjG3PUWrVuVYDcNCvH1FmBbrmo,3863
21
+ together/legacy/files.py,sha256=TFIJZvHlAY-SxQ4PJuCr-A4uRPL2znDhsbSTaTklCD0,3959
22
22
  together/legacy/finetune.py,sha256=Uujbmo_wdCko84mZbDTXMkNBySgMUvVXtULb0w96rDI,4917
23
23
  together/legacy/images.py,sha256=An5dmwU6Mo8mU-CJmI51J9EhOnYwcG9YXF8UgDcIm8E,582
24
24
  together/legacy/models.py,sha256=EEyRNw7AuMoKNXm1nWfT-k2wsAFq213WoyDVGRjwJWs,1053
@@ -27,7 +27,7 @@ together/resources/chat/__init__.py,sha256=RsTptdP8MeGjcdIjze896-J27cRvCbUoMft0X
27
27
  together/resources/chat/completions.py,sha256=QGrg0fGsn16k6jpxbQGoIBRivHWgEimPWAEVdKSAVGk,14084
28
28
  together/resources/completions.py,sha256=5s-jly2vbpI1rWhFwVijCmCOyhEZuDuwJblrm3HD0Gs,11353
29
29
  together/resources/embeddings.py,sha256=yRG0JaF4u_MEynQ4TBgCOVf9bKSvGI1fRaQx3CHUiB0,2546
30
- together/resources/files.py,sha256=_9mM5e49mMs4BCwW07-dnoxagvPPFhq1oUnsMsLMIYA,4593
30
+ together/resources/files.py,sha256=bnPbaF25e4InBRPvHwXHXT-oSX1Z1sZRsnQW5wq82U4,4990
31
31
  together/resources/finetune.py,sha256=DcA0A3I9khS8nMv2KpVNjDVI92knnI2o-O_93Z8gP-U,12416
32
32
  together/resources/images.py,sha256=gFzXy7gLzr20KsXJXHEsOZtJJpuR6pH1d8XHCd6Dl9E,4775
33
33
  together/resources/models.py,sha256=2dtHhXAqTDOOpwSbYLzWcKTC0-m2Szlb7LDYvp7Jr4w,1786
@@ -36,11 +36,11 @@ together/types/__init__.py,sha256=K7Gv6hLmobIfqfmijZbZwFrwxK_YKIDR_v94_ElFmVA,14
36
36
  together/types/abstract.py,sha256=1lFQI_3WjsR_t1128AeKW0aTk6EiM6Gh1J3ZuyLLPao,642
37
37
  together/types/chat_completions.py,sha256=VxuvcHM9IQVWfD1qKu6gDWdrV5UainjkV3pGm_4Oiyo,4335
38
38
  together/types/common.py,sha256=0evjGduXV_tStd0TkGNwvU4fDjfLGUOuUJz6Vl5KYbs,1491
39
- together/types/completions.py,sha256=qOvTqoxc5ZLGFgukVm9-Vx9UKNnBQZGuFIz7HCGHAoQ,2887
39
+ together/types/completions.py,sha256=yydloTQePGaY97Lx-kbkvgCqBFhHFl7jU5s7uf9Ncg0,2901
40
40
  together/types/embeddings.py,sha256=J7grkYYn7xhqeKaBO2T-8XQRtHhkzYzymovtGdIUK5A,751
41
41
  together/types/error.py,sha256=OVlCs3cx_2WhZK4JzHT8SQyRIIqKOP1AZQ4y1PydjAE,370
42
42
  together/types/files.py,sha256=-rEUfsV6f2vZB9NrFxT4_933ubsDIUNkPB-3OlOFk4A,1954
43
- together/types/finetune.py,sha256=C5z5iaH3E_wBiW1USLfUzv3trJxCf36hYh3l55pUaME,5775
43
+ together/types/finetune.py,sha256=eK2Zv47ccvbenGv87PmNCBsqPQleiA3KxoK7KjsuYTM,5850
44
44
  together/types/images.py,sha256=zX4Vt38tFDKU6yGb_hBY_N5eSTn3KPdpP5Ce_qnRHXQ,915
45
45
  together/types/models.py,sha256=3zag9x2fus2McNmLkr3fKzQL-2RNIT1-tiabI-z21p8,1013
46
46
  together/utils/__init__.py,sha256=VpjeRTya1m5eEE-Qe1zYTFsNAvuEA-dy7M2eG9Xu4fc,662
@@ -49,8 +49,8 @@ together/utils/api_helpers.py,sha256=RSF7SRhbjHzroMOSWAXscflByM1r1ta_1SpxkAT22iE
49
49
  together/utils/files.py,sha256=gMLthqfP5hKxVAerHMdy7gLXzdfY6lyOXdpW24Y4X3I,7165
50
50
  together/utils/tools.py,sha256=3-lXWP3cBCzOVSZg9tr5zOT1jaVeKAKVWxO2fcXZTh8,1788
51
51
  together/version.py,sha256=p03ivHyE0SyWU4jAnRTBi_sOwywVWoZPU4g2gzRgG-Y,126
52
- together-1.1.5.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
53
- together-1.1.5.dist-info/METADATA,sha256=cByMGtmLlDdbVgw5Pl_xEvi3cSyMDzE1YC3ZMqj0Qu0,11812
54
- together-1.1.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
55
- together-1.1.5.dist-info/entry_points.txt,sha256=G-b5NKW6lUUf1V1fH8IPTBb7jXnK7lhbX9H1zTEJXPs,50
56
- together-1.1.5.dist-info/RECORD,,
52
+ together-1.2.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
53
+ together-1.2.1.dist-info/METADATA,sha256=61lkQQva68_obMLTd0sLYhgHi7hWJnCxBkEJA9_eCS4,11812
54
+ together-1.2.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
55
+ together-1.2.1.dist-info/entry_points.txt,sha256=G-b5NKW6lUUf1V1fH8IPTBb7jXnK7lhbX9H1zTEJXPs,50
56
+ together-1.2.1.dist-info/RECORD,,