together 1.5.11__tar.gz → 1.5.13__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.
Files changed (68) hide show
  1. {together-1.5.11 → together-1.5.13}/PKG-INFO +1 -1
  2. {together-1.5.11 → together-1.5.13}/pyproject.toml +1 -1
  3. {together-1.5.11 → together-1.5.13}/src/together/cli/api/finetune.py +1 -1
  4. {together-1.5.11 → together-1.5.13}/src/together/client.py +4 -1
  5. {together-1.5.11 → together-1.5.13}/src/together/resources/__init__.py +3 -0
  6. together-1.5.13/src/together/resources/batch.py +136 -0
  7. {together-1.5.11 → together-1.5.13}/src/together/resources/files.py +1 -1
  8. {together-1.5.11 → together-1.5.13}/src/together/resources/finetune.py +5 -5
  9. {together-1.5.11 → together-1.5.13}/src/together/types/__init__.py +4 -0
  10. together-1.5.13/src/together/types/batch.py +53 -0
  11. {together-1.5.11 → together-1.5.13}/src/together/types/files.py +1 -0
  12. {together-1.5.11 → together-1.5.13}/LICENSE +0 -0
  13. {together-1.5.11 → together-1.5.13}/README.md +0 -0
  14. {together-1.5.11 → together-1.5.13}/src/together/__init__.py +0 -0
  15. {together-1.5.11 → together-1.5.13}/src/together/abstract/__init__.py +0 -0
  16. {together-1.5.11 → together-1.5.13}/src/together/abstract/api_requestor.py +0 -0
  17. {together-1.5.11 → together-1.5.13}/src/together/cli/__init__.py +0 -0
  18. {together-1.5.11 → together-1.5.13}/src/together/cli/api/__init__.py +0 -0
  19. {together-1.5.11 → together-1.5.13}/src/together/cli/api/chat.py +0 -0
  20. {together-1.5.11 → together-1.5.13}/src/together/cli/api/completions.py +0 -0
  21. {together-1.5.11 → together-1.5.13}/src/together/cli/api/endpoints.py +0 -0
  22. {together-1.5.11 → together-1.5.13}/src/together/cli/api/files.py +0 -0
  23. {together-1.5.11 → together-1.5.13}/src/together/cli/api/images.py +0 -0
  24. {together-1.5.11 → together-1.5.13}/src/together/cli/api/models.py +0 -0
  25. {together-1.5.11 → together-1.5.13}/src/together/cli/api/utils.py +0 -0
  26. {together-1.5.11 → together-1.5.13}/src/together/cli/cli.py +0 -0
  27. {together-1.5.11 → together-1.5.13}/src/together/constants.py +0 -0
  28. {together-1.5.11 → together-1.5.13}/src/together/error.py +0 -0
  29. {together-1.5.11 → together-1.5.13}/src/together/filemanager.py +0 -0
  30. {together-1.5.11 → together-1.5.13}/src/together/legacy/__init__.py +0 -0
  31. {together-1.5.11 → together-1.5.13}/src/together/legacy/base.py +0 -0
  32. {together-1.5.11 → together-1.5.13}/src/together/legacy/complete.py +0 -0
  33. {together-1.5.11 → together-1.5.13}/src/together/legacy/embeddings.py +0 -0
  34. {together-1.5.11 → together-1.5.13}/src/together/legacy/files.py +0 -0
  35. {together-1.5.11 → together-1.5.13}/src/together/legacy/finetune.py +0 -0
  36. {together-1.5.11 → together-1.5.13}/src/together/legacy/images.py +0 -0
  37. {together-1.5.11 → together-1.5.13}/src/together/legacy/models.py +0 -0
  38. {together-1.5.11 → together-1.5.13}/src/together/resources/audio/__init__.py +0 -0
  39. {together-1.5.11 → together-1.5.13}/src/together/resources/audio/speech.py +0 -0
  40. {together-1.5.11 → together-1.5.13}/src/together/resources/chat/__init__.py +0 -0
  41. {together-1.5.11 → together-1.5.13}/src/together/resources/chat/completions.py +0 -0
  42. {together-1.5.11 → together-1.5.13}/src/together/resources/code_interpreter.py +0 -0
  43. {together-1.5.11 → together-1.5.13}/src/together/resources/completions.py +0 -0
  44. {together-1.5.11 → together-1.5.13}/src/together/resources/embeddings.py +0 -0
  45. {together-1.5.11 → together-1.5.13}/src/together/resources/endpoints.py +0 -0
  46. {together-1.5.11 → together-1.5.13}/src/together/resources/images.py +0 -0
  47. {together-1.5.11 → together-1.5.13}/src/together/resources/models.py +0 -0
  48. {together-1.5.11 → together-1.5.13}/src/together/resources/rerank.py +0 -0
  49. {together-1.5.11 → together-1.5.13}/src/together/together_response.py +0 -0
  50. {together-1.5.11 → together-1.5.13}/src/together/types/abstract.py +0 -0
  51. {together-1.5.11 → together-1.5.13}/src/together/types/audio_speech.py +0 -0
  52. {together-1.5.11 → together-1.5.13}/src/together/types/chat_completions.py +0 -0
  53. {together-1.5.11 → together-1.5.13}/src/together/types/code_interpreter.py +0 -0
  54. {together-1.5.11 → together-1.5.13}/src/together/types/common.py +0 -0
  55. {together-1.5.11 → together-1.5.13}/src/together/types/completions.py +0 -0
  56. {together-1.5.11 → together-1.5.13}/src/together/types/embeddings.py +0 -0
  57. {together-1.5.11 → together-1.5.13}/src/together/types/endpoints.py +0 -0
  58. {together-1.5.11 → together-1.5.13}/src/together/types/error.py +0 -0
  59. {together-1.5.11 → together-1.5.13}/src/together/types/finetune.py +0 -0
  60. {together-1.5.11 → together-1.5.13}/src/together/types/images.py +0 -0
  61. {together-1.5.11 → together-1.5.13}/src/together/types/models.py +0 -0
  62. {together-1.5.11 → together-1.5.13}/src/together/types/rerank.py +0 -0
  63. {together-1.5.11 → together-1.5.13}/src/together/utils/__init__.py +0 -0
  64. {together-1.5.11 → together-1.5.13}/src/together/utils/_log.py +0 -0
  65. {together-1.5.11 → together-1.5.13}/src/together/utils/api_helpers.py +0 -0
  66. {together-1.5.11 → together-1.5.13}/src/together/utils/files.py +0 -0
  67. {together-1.5.11 → together-1.5.13}/src/together/utils/tools.py +0 -0
  68. {together-1.5.11 → together-1.5.13}/src/together/version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: together
3
- Version: 1.5.11
3
+ Version: 1.5.13
4
4
  Summary: Python client for Together's Cloud Platform!
5
5
  License: Apache-2.0
6
6
  Author: Together AI
@@ -12,7 +12,7 @@ build-backend = "poetry.masonry.api"
12
12
 
13
13
  [tool.poetry]
14
14
  name = "together"
15
- version = "1.5.11"
15
+ version = "1.5.13"
16
16
  authors = ["Together AI <support@together.ai>"]
17
17
  description = "Python client for Together's Cloud Platform!"
18
18
  readme = "README.md"
@@ -82,7 +82,7 @@ def fine_tuning(ctx: click.Context) -> None:
82
82
  @click.option(
83
83
  "--lr-scheduler-type",
84
84
  type=click.Choice(["linear", "cosine"]),
85
- default="linear",
85
+ default="cosine",
86
86
  help="Learning rate scheduler type",
87
87
  )
88
88
  @click.option(
@@ -23,6 +23,7 @@ class Together:
23
23
  fine_tuning: resources.FineTuning
24
24
  rerank: resources.Rerank
25
25
  audio: resources.Audio
26
+ batches: resources.Batches
26
27
  code_interpreter: CodeInterpreter
27
28
 
28
29
  # client options
@@ -90,6 +91,7 @@ class Together:
90
91
  self.audio = resources.Audio(self.client)
91
92
  self.endpoints = resources.Endpoints(self.client)
92
93
  self.code_interpreter = CodeInterpreter(self.client)
94
+ self.batches = resources.Batches(self.client)
93
95
 
94
96
 
95
97
  class AsyncTogether:
@@ -102,7 +104,7 @@ class AsyncTogether:
102
104
  fine_tuning: resources.AsyncFineTuning
103
105
  rerank: resources.AsyncRerank
104
106
  code_interpreter: CodeInterpreter
105
-
107
+ batches: resources.AsyncBatches
106
108
  # client options
107
109
  client: TogetherClient
108
110
 
@@ -166,6 +168,7 @@ class AsyncTogether:
166
168
  self.fine_tuning = resources.AsyncFineTuning(self.client)
167
169
  self.rerank = resources.AsyncRerank(self.client)
168
170
  self.code_interpreter = CodeInterpreter(self.client)
171
+ self.batches = resources.AsyncBatches(self.client)
169
172
 
170
173
 
171
174
  Client = Together
@@ -8,6 +8,7 @@ from together.resources.finetune import AsyncFineTuning, FineTuning
8
8
  from together.resources.images import AsyncImages, Images
9
9
  from together.resources.models import AsyncModels, Models
10
10
  from together.resources.rerank import AsyncRerank, Rerank
11
+ from together.resources.batch import Batches, AsyncBatches
11
12
 
12
13
 
13
14
  __all__ = [
@@ -31,4 +32,6 @@ __all__ = [
31
32
  "Audio",
32
33
  "AsyncEndpoints",
33
34
  "Endpoints",
35
+ "Batches",
36
+ "AsyncBatches",
34
37
  ]
@@ -0,0 +1,136 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import List
4
+
5
+ from together.abstract import api_requestor
6
+ from together.together_response import TogetherResponse
7
+ from together.types import (
8
+ TogetherClient,
9
+ TogetherRequest,
10
+ BatchJob,
11
+ )
12
+
13
+
14
+ class Batches:
15
+ def __init__(self, client: TogetherClient) -> None:
16
+ self._client = client
17
+
18
+ def create_batch(self, file_id: str, endpoint: str) -> BatchJob:
19
+
20
+ requestor = api_requestor.APIRequestor(
21
+ client=self._client,
22
+ )
23
+
24
+ parameter_payload = {
25
+ "input_file_id": file_id,
26
+ "endpoint": endpoint,
27
+ "completion_window": "24h",
28
+ }
29
+
30
+ response, _, _ = requestor.request(
31
+ options=TogetherRequest(
32
+ method="POST",
33
+ url=f"batches",
34
+ params=parameter_payload,
35
+ ),
36
+ stream=False,
37
+ )
38
+
39
+ assert isinstance(response, TogetherResponse)
40
+ response_body = response.data.get("job", {})
41
+ return BatchJob(**response_body)
42
+
43
+ def get_batch(self, batch_job_id: str) -> BatchJob:
44
+ requestor = api_requestor.APIRequestor(
45
+ client=self._client,
46
+ )
47
+
48
+ response, _, _ = requestor.request(
49
+ options=TogetherRequest(
50
+ method="GET",
51
+ url=f"batches/{batch_job_id}",
52
+ ),
53
+ stream=False,
54
+ )
55
+
56
+ assert isinstance(response, TogetherResponse)
57
+ return BatchJob(**response.data)
58
+
59
+ def list_batches(self) -> List[BatchJob]:
60
+ requestor = api_requestor.APIRequestor(
61
+ client=self._client,
62
+ )
63
+
64
+ response, _, _ = requestor.request(
65
+ options=TogetherRequest(
66
+ method="GET",
67
+ url="batches",
68
+ ),
69
+ stream=False,
70
+ )
71
+
72
+ assert isinstance(response, TogetherResponse)
73
+ jobs = response.data or []
74
+ return [BatchJob(**job) for job in jobs]
75
+
76
+
77
+ class AsyncBatches:
78
+ def __init__(self, client: TogetherClient) -> None:
79
+ self._client = client
80
+
81
+ async def create_batch(self, file_id: str, endpoint: str) -> BatchJob:
82
+ requestor = api_requestor.APIRequestor(
83
+ client=self._client,
84
+ )
85
+
86
+ parameter_payload = {
87
+ "input_file_id": file_id,
88
+ "endpoint": endpoint,
89
+ "completion_window": "24h",
90
+ }
91
+
92
+ response, _, _ = await requestor.arequest(
93
+ options=TogetherRequest(
94
+ method="POST",
95
+ url=f"batches",
96
+ params=parameter_payload,
97
+ ),
98
+ stream=False,
99
+ )
100
+
101
+ assert isinstance(response, TogetherResponse)
102
+ response_body = response.data.get("job", {})
103
+ return BatchJob(**response_body)
104
+
105
+ async def get_batch(self, batch_job_id: str) -> BatchJob:
106
+ requestor = api_requestor.APIRequestor(
107
+ client=self._client,
108
+ )
109
+
110
+ response, _, _ = await requestor.arequest(
111
+ options=TogetherRequest(
112
+ method="GET",
113
+ url=f"batches/{batch_job_id}",
114
+ ),
115
+ stream=False,
116
+ )
117
+
118
+ assert isinstance(response, TogetherResponse)
119
+ return BatchJob(**response.data)
120
+
121
+ async def list_batches(self) -> List[BatchJob]:
122
+ requestor = api_requestor.APIRequestor(
123
+ client=self._client,
124
+ )
125
+
126
+ response, _, _ = await requestor.arequest(
127
+ options=TogetherRequest(
128
+ method="GET",
129
+ url="batches",
130
+ ),
131
+ stream=False,
132
+ )
133
+
134
+ assert isinstance(response, TogetherResponse)
135
+ jobs = response.data or []
136
+ return [BatchJob(**job) for job in jobs]
@@ -32,7 +32,7 @@ class Files:
32
32
  ) -> FileResponse:
33
33
  upload_manager = UploadManager(self._client)
34
34
 
35
- if check:
35
+ if check and purpose == FilePurpose.FineTune:
36
36
  report_dict = check_file(file)
37
37
  if not report_dict["is_check_passed"]:
38
38
  raise FileTypeError(
@@ -53,7 +53,7 @@ def create_finetune_request(
53
53
  n_checkpoints: int | None = 1,
54
54
  batch_size: int | Literal["max"] = "max",
55
55
  learning_rate: float | None = 0.00001,
56
- lr_scheduler_type: Literal["linear", "cosine"] = "linear",
56
+ lr_scheduler_type: Literal["linear", "cosine"] = "cosine",
57
57
  min_lr_ratio: float = 0.0,
58
58
  scheduler_num_cycles: float = 0.5,
59
59
  warmup_ratio: float | None = None,
@@ -281,7 +281,7 @@ class FineTuning:
281
281
  n_checkpoints: int | None = 1,
282
282
  batch_size: int | Literal["max"] = "max",
283
283
  learning_rate: float | None = 0.00001,
284
- lr_scheduler_type: Literal["linear", "cosine"] = "linear",
284
+ lr_scheduler_type: Literal["linear", "cosine"] = "cosine",
285
285
  min_lr_ratio: float = 0.0,
286
286
  scheduler_num_cycles: float = 0.5,
287
287
  warmup_ratio: float = 0.0,
@@ -318,7 +318,7 @@ class FineTuning:
318
318
  batch_size (int or "max"): Batch size for fine-tuning. Defaults to max.
319
319
  learning_rate (float, optional): Learning rate multiplier to use for training
320
320
  Defaults to 0.00001.
321
- lr_scheduler_type (Literal["linear", "cosine"]): Learning rate scheduler type. Defaults to "linear".
321
+ lr_scheduler_type (Literal["linear", "cosine"]): Learning rate scheduler type. Defaults to "cosine".
322
322
  min_lr_ratio (float, optional): Min learning rate ratio of the initial learning rate for
323
323
  the learning rate scheduler. Defaults to 0.0.
324
324
  scheduler_num_cycles (float, optional): Number or fraction of cycles for the cosine learning rate scheduler. Defaults to 0.5.
@@ -693,7 +693,7 @@ class AsyncFineTuning:
693
693
  n_checkpoints: int | None = 1,
694
694
  batch_size: int | Literal["max"] = "max",
695
695
  learning_rate: float | None = 0.00001,
696
- lr_scheduler_type: Literal["linear", "cosine"] = "linear",
696
+ lr_scheduler_type: Literal["linear", "cosine"] = "cosine",
697
697
  min_lr_ratio: float = 0.0,
698
698
  scheduler_num_cycles: float = 0.5,
699
699
  warmup_ratio: float = 0.0,
@@ -730,7 +730,7 @@ class AsyncFineTuning:
730
730
  batch_size (int, optional): Batch size for fine-tuning. Defaults to max.
731
731
  learning_rate (float, optional): Learning rate multiplier to use for training
732
732
  Defaults to 0.00001.
733
- lr_scheduler_type (Literal["linear", "cosine"]): Learning rate scheduler type. Defaults to "linear".
733
+ lr_scheduler_type (Literal["linear", "cosine"]): Learning rate scheduler type. Defaults to "cosine".
734
734
  min_lr_ratio (float, optional): Min learning rate ratio of the initial learning rate for
735
735
  the learning rate scheduler. Defaults to 0.0.
736
736
  scheduler_num_cycles (float, optional): Number or fraction of cycles for the cosine learning rate scheduler. Defaults to 0.5.
@@ -52,6 +52,7 @@ from together.types.finetune import (
52
52
  from together.types.images import ImageRequest, ImageResponse
53
53
  from together.types.models import ModelObject
54
54
  from together.types.rerank import RerankRequest, RerankResponse
55
+ from together.types.batch import BatchJob, BatchJobStatus, BatchEndpoint
55
56
 
56
57
 
57
58
  __all__ = [
@@ -104,4 +105,7 @@ __all__ = [
104
105
  "DedicatedEndpoint",
105
106
  "ListEndpoint",
106
107
  "Autoscaling",
108
+ "BatchJob",
109
+ "BatchJobStatus",
110
+ "BatchEndpoint",
107
111
  ]
@@ -0,0 +1,53 @@
1
+ from __future__ import annotations
2
+
3
+ from enum import Enum
4
+ from typing import Optional
5
+ from datetime import datetime
6
+
7
+ from pydantic import Field
8
+
9
+ from together.types.abstract import BaseModel
10
+
11
+
12
+ class BatchJobStatus(str, Enum):
13
+ """
14
+ The status of a batch job
15
+ """
16
+
17
+ VALIDATING = "VALIDATING"
18
+ IN_PROGRESS = "IN_PROGRESS"
19
+ COMPLETED = "COMPLETED"
20
+ FAILED = "FAILED"
21
+ EXPIRED = "EXPIRED"
22
+ CANCELLED = "CANCELLED"
23
+
24
+
25
+ class BatchEndpoint(str, Enum):
26
+ """
27
+ The endpoint of a batch job
28
+ """
29
+
30
+ COMPLETIONS = "/v1/completions"
31
+ CHAT_COMPLETIONS = "/v1/chat/completions"
32
+ # More endpoints can be added here as needed
33
+
34
+
35
+ class BatchJob(BaseModel):
36
+ """
37
+ A batch job object
38
+ """
39
+
40
+ id: str
41
+ user_id: str
42
+ input_file_id: str
43
+ file_size_bytes: int
44
+ status: BatchJobStatus
45
+ job_deadline: datetime
46
+ created_at: datetime
47
+ endpoint: str
48
+ progress: float = 0.0
49
+ model_id: Optional[str] = None
50
+ output_file_id: Optional[str] = None
51
+ error_file_id: Optional[str] = None
52
+ error: Optional[str] = None
53
+ completed_at: Optional[datetime] = None
@@ -13,6 +13,7 @@ from together.types.common import (
13
13
 
14
14
  class FilePurpose(str, Enum):
15
15
  FineTune = "fine-tune"
16
+ BatchAPI = "batch-api"
16
17
 
17
18
 
18
19
  class FileType(str, Enum):
File without changes
File without changes