together 1.1.5__tar.gz → 1.2.1__tar.gz
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-1.1.5 → together-1.2.1}/PKG-INFO +1 -1
- {together-1.1.5 → together-1.2.1}/pyproject.toml +1 -1
- {together-1.1.5 → together-1.2.1}/src/together/cli/api/files.py +7 -2
- {together-1.1.5 → together-1.2.1}/src/together/error.py +5 -2
- {together-1.1.5 → together-1.2.1}/src/together/legacy/files.py +4 -2
- {together-1.1.5 → together-1.2.1}/src/together/resources/files.py +15 -2
- {together-1.1.5 → together-1.2.1}/src/together/types/completions.py +1 -1
- {together-1.1.5 → together-1.2.1}/src/together/types/finetune.py +2 -0
- {together-1.1.5 → together-1.2.1}/LICENSE +0 -0
- {together-1.1.5 → together-1.2.1}/README.md +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/__init__.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/abstract/__init__.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/abstract/api_requestor.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/cli/__init__.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/cli/api/__init__.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/cli/api/chat.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/cli/api/completions.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/cli/api/finetune.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/cli/api/images.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/cli/api/models.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/cli/cli.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/client.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/constants.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/filemanager.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/legacy/__init__.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/legacy/base.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/legacy/complete.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/legacy/embeddings.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/legacy/finetune.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/legacy/images.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/legacy/models.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/resources/__init__.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/resources/chat/__init__.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/resources/chat/completions.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/resources/completions.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/resources/embeddings.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/resources/finetune.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/resources/images.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/resources/models.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/together_response.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/types/__init__.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/types/abstract.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/types/chat_completions.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/types/common.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/types/embeddings.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/types/error.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/types/files.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/types/images.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/types/models.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/utils/__init__.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/utils/_log.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/utils/api_helpers.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/utils/files.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/utils/tools.py +0 -0
- {together-1.1.5 → together-1.2.1}/src/together/version.py +0 -0
|
@@ -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
|
-
|
|
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
|
|
|
@@ -23,9 +23,12 @@ class TogetherException(Exception):
|
|
|
23
23
|
if isinstance(message, TogetherErrorResponse)
|
|
24
24
|
else message
|
|
25
25
|
)
|
|
26
|
-
|
|
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(
|
|
31
|
+
super().__init__(self._message)
|
|
29
32
|
|
|
30
33
|
self.http_status = http_status
|
|
31
34
|
self.headers = headers or {}
|
|
@@ -53,9 +53,11 @@ class Files:
|
|
|
53
53
|
|
|
54
54
|
client = together.Together(api_key=api_key)
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
# disabling the check, because it was run previously
|
|
57
|
+
response = client.files.upload(file=file, check=False).model_dump()
|
|
57
58
|
|
|
58
|
-
|
|
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,
|
|
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
|
|
|
@@ -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"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|