together 1.2.11__py3-none-any.whl → 2.0.0a8__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/__init__.py +101 -63
- together/_base_client.py +1995 -0
- together/_client.py +1033 -0
- together/_compat.py +219 -0
- together/_constants.py +14 -0
- together/_exceptions.py +108 -0
- together/_files.py +123 -0
- together/_models.py +857 -0
- together/_qs.py +150 -0
- together/_resource.py +43 -0
- together/_response.py +830 -0
- together/_streaming.py +370 -0
- together/_types.py +260 -0
- together/_utils/__init__.py +64 -0
- together/_utils/_compat.py +45 -0
- together/_utils/_datetime_parse.py +136 -0
- together/_utils/_logs.py +25 -0
- together/_utils/_proxy.py +65 -0
- together/_utils/_reflection.py +42 -0
- together/_utils/_resources_proxy.py +24 -0
- together/_utils/_streams.py +12 -0
- together/_utils/_sync.py +58 -0
- together/_utils/_transform.py +457 -0
- together/_utils/_typing.py +156 -0
- together/_utils/_utils.py +421 -0
- together/_version.py +4 -0
- together/lib/.keep +4 -0
- together/lib/__init__.py +23 -0
- together/lib/cli/api/endpoints.py +467 -0
- together/lib/cli/api/evals.py +588 -0
- together/{cli → lib/cli}/api/files.py +20 -17
- together/lib/cli/api/fine_tuning.py +566 -0
- together/lib/cli/api/models.py +140 -0
- together/lib/cli/api/utils.py +50 -0
- together/{cli → lib/cli}/cli.py +17 -23
- together/lib/constants.py +61 -0
- together/lib/resources/__init__.py +11 -0
- together/lib/resources/files.py +999 -0
- together/lib/resources/fine_tuning.py +280 -0
- together/lib/resources/models.py +35 -0
- together/lib/types/__init__.py +13 -0
- together/lib/types/error.py +9 -0
- together/lib/types/fine_tuning.py +455 -0
- together/{utils → lib/utils}/__init__.py +7 -10
- together/{utils → lib/utils}/_log.py +18 -13
- together/lib/utils/files.py +628 -0
- together/lib/utils/serializer.py +10 -0
- together/{utils → lib/utils}/tools.py +17 -2
- together/resources/__init__.py +225 -24
- together/resources/audio/__init__.py +75 -0
- together/resources/audio/audio.py +198 -0
- together/resources/audio/speech.py +605 -0
- together/resources/audio/transcriptions.py +282 -0
- together/resources/audio/translations.py +256 -0
- together/resources/audio/voices.py +135 -0
- together/resources/batches.py +417 -0
- together/resources/chat/__init__.py +30 -21
- together/resources/chat/chat.py +102 -0
- together/resources/chat/completions.py +1063 -257
- together/resources/code_interpreter/__init__.py +33 -0
- together/resources/code_interpreter/code_interpreter.py +258 -0
- together/resources/code_interpreter/sessions.py +135 -0
- together/resources/completions.py +890 -225
- together/resources/embeddings.py +172 -68
- together/resources/endpoints.py +711 -0
- together/resources/evals.py +452 -0
- together/resources/files.py +397 -120
- together/resources/fine_tuning.py +1033 -0
- together/resources/hardware.py +181 -0
- together/resources/images.py +256 -108
- together/resources/jobs.py +214 -0
- together/resources/models.py +251 -44
- together/resources/rerank.py +190 -92
- together/resources/videos.py +374 -0
- together/types/__init__.py +66 -73
- together/types/audio/__init__.py +10 -0
- together/types/audio/speech_create_params.py +75 -0
- together/types/audio/transcription_create_params.py +54 -0
- together/types/audio/transcription_create_response.py +111 -0
- together/types/audio/translation_create_params.py +40 -0
- together/types/audio/translation_create_response.py +70 -0
- together/types/audio/voice_list_response.py +23 -0
- together/types/audio_speech_stream_chunk.py +16 -0
- together/types/autoscaling.py +13 -0
- together/types/autoscaling_param.py +15 -0
- together/types/batch_create_params.py +24 -0
- together/types/batch_create_response.py +14 -0
- together/types/batch_job.py +45 -0
- together/types/batch_list_response.py +10 -0
- together/types/chat/__init__.py +18 -0
- together/types/chat/chat_completion.py +60 -0
- together/types/chat/chat_completion_chunk.py +61 -0
- together/types/chat/chat_completion_structured_message_image_url_param.py +18 -0
- together/types/chat/chat_completion_structured_message_text_param.py +13 -0
- together/types/chat/chat_completion_structured_message_video_url_param.py +18 -0
- together/types/chat/chat_completion_usage.py +13 -0
- together/types/chat/chat_completion_warning.py +9 -0
- together/types/chat/completion_create_params.py +329 -0
- together/types/code_interpreter/__init__.py +5 -0
- together/types/code_interpreter/session_list_response.py +31 -0
- together/types/code_interpreter_execute_params.py +45 -0
- together/types/completion.py +42 -0
- together/types/completion_chunk.py +66 -0
- together/types/completion_create_params.py +138 -0
- together/types/dedicated_endpoint.py +44 -0
- together/types/embedding.py +24 -0
- together/types/embedding_create_params.py +31 -0
- together/types/endpoint_create_params.py +43 -0
- together/types/endpoint_list_avzones_response.py +11 -0
- together/types/endpoint_list_params.py +18 -0
- together/types/endpoint_list_response.py +41 -0
- together/types/endpoint_update_params.py +27 -0
- together/types/eval_create_params.py +263 -0
- together/types/eval_create_response.py +16 -0
- together/types/eval_list_params.py +21 -0
- together/types/eval_list_response.py +10 -0
- together/types/eval_status_response.py +100 -0
- together/types/evaluation_job.py +139 -0
- together/types/execute_response.py +108 -0
- together/types/file_delete_response.py +13 -0
- together/types/file_list.py +12 -0
- together/types/file_purpose.py +9 -0
- together/types/file_response.py +31 -0
- together/types/file_type.py +7 -0
- together/types/fine_tuning_cancel_response.py +194 -0
- together/types/fine_tuning_content_params.py +24 -0
- together/types/fine_tuning_delete_params.py +11 -0
- together/types/fine_tuning_delete_response.py +12 -0
- together/types/fine_tuning_list_checkpoints_response.py +21 -0
- together/types/fine_tuning_list_events_response.py +12 -0
- together/types/fine_tuning_list_response.py +199 -0
- together/types/finetune_event.py +41 -0
- together/types/finetune_event_type.py +33 -0
- together/types/finetune_response.py +177 -0
- together/types/hardware_list_params.py +16 -0
- together/types/hardware_list_response.py +58 -0
- together/types/image_data_b64.py +15 -0
- together/types/image_data_url.py +15 -0
- together/types/image_file.py +23 -0
- together/types/image_generate_params.py +85 -0
- together/types/job_list_response.py +47 -0
- together/types/job_retrieve_response.py +43 -0
- together/types/log_probs.py +18 -0
- together/types/model_list_response.py +10 -0
- together/types/model_object.py +42 -0
- together/types/model_upload_params.py +36 -0
- together/types/model_upload_response.py +23 -0
- together/types/rerank_create_params.py +36 -0
- together/types/rerank_create_response.py +36 -0
- together/types/tool_choice.py +23 -0
- together/types/tool_choice_param.py +23 -0
- together/types/tools_param.py +23 -0
- together/types/training_method_dpo.py +22 -0
- together/types/training_method_sft.py +18 -0
- together/types/video_create_params.py +86 -0
- together/types/video_job.py +57 -0
- together-2.0.0a8.dist-info/METADATA +680 -0
- together-2.0.0a8.dist-info/RECORD +164 -0
- {together-1.2.11.dist-info → together-2.0.0a8.dist-info}/WHEEL +1 -1
- together-2.0.0a8.dist-info/entry_points.txt +2 -0
- {together-1.2.11.dist-info → together-2.0.0a8.dist-info/licenses}/LICENSE +1 -1
- together/abstract/api_requestor.py +0 -723
- together/cli/api/chat.py +0 -276
- together/cli/api/completions.py +0 -119
- together/cli/api/finetune.py +0 -272
- together/cli/api/images.py +0 -82
- together/cli/api/models.py +0 -42
- together/client.py +0 -157
- together/constants.py +0 -31
- together/error.py +0 -191
- together/filemanager.py +0 -388
- together/legacy/__init__.py +0 -0
- together/legacy/base.py +0 -27
- together/legacy/complete.py +0 -93
- together/legacy/embeddings.py +0 -27
- together/legacy/files.py +0 -146
- together/legacy/finetune.py +0 -177
- together/legacy/images.py +0 -27
- together/legacy/models.py +0 -44
- together/resources/finetune.py +0 -489
- together/together_response.py +0 -50
- together/types/abstract.py +0 -26
- together/types/chat_completions.py +0 -171
- together/types/common.py +0 -65
- together/types/completions.py +0 -104
- together/types/embeddings.py +0 -35
- together/types/error.py +0 -16
- together/types/files.py +0 -89
- together/types/finetune.py +0 -265
- together/types/images.py +0 -42
- together/types/models.py +0 -44
- together/types/rerank.py +0 -43
- together/utils/api_helpers.py +0 -84
- together/utils/files.py +0 -204
- together/version.py +0 -6
- together-1.2.11.dist-info/METADATA +0 -408
- together-1.2.11.dist-info/RECORD +0 -58
- together-1.2.11.dist-info/entry_points.txt +0 -3
- /together/{abstract → lib/cli}/__init__.py +0 -0
- /together/{cli → lib/cli/api}/__init__.py +0 -0
- /together/{cli/api/__init__.py → py.typed} +0 -0
together/cli/api/images.py
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import base64
|
|
2
|
-
import pathlib
|
|
3
|
-
|
|
4
|
-
import click
|
|
5
|
-
from PIL import Image
|
|
6
|
-
|
|
7
|
-
from together import Together
|
|
8
|
-
from together.types import ImageResponse
|
|
9
|
-
from together.types.images import ImageChoicesData
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@click.group()
|
|
13
|
-
@click.pass_context
|
|
14
|
-
def images(ctx: click.Context) -> None:
|
|
15
|
-
"""Images generations API commands"""
|
|
16
|
-
pass
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
@images.command()
|
|
20
|
-
@click.pass_context
|
|
21
|
-
@click.argument("prompt", type=str, required=True)
|
|
22
|
-
@click.option("--model", type=str, required=True, help="Model name")
|
|
23
|
-
@click.option("--steps", type=int, default=20, help="Number of steps to run generation")
|
|
24
|
-
@click.option("--seed", type=int, default=None, help="Random seed")
|
|
25
|
-
@click.option("--n", type=int, default=1, help="Number of images to generate")
|
|
26
|
-
@click.option("--height", type=int, default=1024, help="Image height")
|
|
27
|
-
@click.option("--width", type=int, default=1024, help="Image width")
|
|
28
|
-
@click.option("--negative-prompt", type=str, default=None, help="Negative prompt")
|
|
29
|
-
@click.option(
|
|
30
|
-
"--output",
|
|
31
|
-
type=click.Path(exists=True, file_okay=False, resolve_path=True),
|
|
32
|
-
required=False,
|
|
33
|
-
default=pathlib.Path("."),
|
|
34
|
-
help="Output directory",
|
|
35
|
-
)
|
|
36
|
-
@click.option("--prefix", type=str, required=False, default="image-")
|
|
37
|
-
@click.option("--no-show", is_flag=True, help="Do not open images in viewer")
|
|
38
|
-
def generate(
|
|
39
|
-
ctx: click.Context,
|
|
40
|
-
prompt: str,
|
|
41
|
-
model: str,
|
|
42
|
-
steps: int,
|
|
43
|
-
seed: int,
|
|
44
|
-
n: int,
|
|
45
|
-
height: int,
|
|
46
|
-
width: int,
|
|
47
|
-
negative_prompt: str,
|
|
48
|
-
output: pathlib.Path,
|
|
49
|
-
prefix: str,
|
|
50
|
-
no_show: bool,
|
|
51
|
-
) -> None:
|
|
52
|
-
"""Generate image"""
|
|
53
|
-
|
|
54
|
-
client: Together = ctx.obj
|
|
55
|
-
|
|
56
|
-
response = client.images.generate(
|
|
57
|
-
prompt=prompt,
|
|
58
|
-
model=model,
|
|
59
|
-
steps=steps,
|
|
60
|
-
seed=seed,
|
|
61
|
-
n=n,
|
|
62
|
-
height=height,
|
|
63
|
-
width=width,
|
|
64
|
-
negative_prompt=negative_prompt,
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
assert isinstance(response, ImageResponse)
|
|
68
|
-
assert isinstance(response.data, list)
|
|
69
|
-
|
|
70
|
-
for i, choice in enumerate(response.data):
|
|
71
|
-
assert isinstance(choice, ImageChoicesData)
|
|
72
|
-
|
|
73
|
-
with open(f"{output}/{prefix}{choice.index}.png", "wb") as f:
|
|
74
|
-
f.write(base64.b64decode(choice.b64_json))
|
|
75
|
-
|
|
76
|
-
click.echo(
|
|
77
|
-
f"Image [{i + 1}/{len(response.data)}] saved to {output}/{prefix}{choice.index}.png"
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
if not no_show:
|
|
81
|
-
image = Image.open(f"{output}/{prefix}{choice.index}.png")
|
|
82
|
-
image.show()
|
together/cli/api/models.py
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
from textwrap import wrap
|
|
2
|
-
|
|
3
|
-
import click
|
|
4
|
-
from tabulate import tabulate
|
|
5
|
-
|
|
6
|
-
from together import Together
|
|
7
|
-
from together.types.models import ModelObject
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@click.group()
|
|
11
|
-
@click.pass_context
|
|
12
|
-
def models(ctx: click.Context) -> None:
|
|
13
|
-
"""Models API commands"""
|
|
14
|
-
pass
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
@models.command()
|
|
18
|
-
@click.pass_context
|
|
19
|
-
def list(ctx: click.Context) -> None:
|
|
20
|
-
"""List models"""
|
|
21
|
-
client: Together = ctx.obj
|
|
22
|
-
|
|
23
|
-
response = client.models.list()
|
|
24
|
-
|
|
25
|
-
display_list = []
|
|
26
|
-
|
|
27
|
-
model: ModelObject
|
|
28
|
-
for model in response:
|
|
29
|
-
display_list.append(
|
|
30
|
-
{
|
|
31
|
-
"ID": "\n".join(wrap(model.id or "", width=30)),
|
|
32
|
-
"Name": "\n".join(wrap(model.display_name or "", width=30)),
|
|
33
|
-
"Organization": model.organization,
|
|
34
|
-
"Type": model.type,
|
|
35
|
-
"Context Length": model.context_length,
|
|
36
|
-
"License": "\n".join(wrap(model.license or "", width=30)),
|
|
37
|
-
"Input per 1M token": model.pricing.input,
|
|
38
|
-
"Output per 1M token": model.pricing.output,
|
|
39
|
-
}
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
click.echo(tabulate(display_list, headers="keys", tablefmt="grid"))
|
together/client.py
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import os
|
|
4
|
-
from typing import Dict
|
|
5
|
-
|
|
6
|
-
from together import resources
|
|
7
|
-
from together.constants import BASE_URL, MAX_RETRIES, TIMEOUT_SECS
|
|
8
|
-
from together.error import AuthenticationError
|
|
9
|
-
from together.types import TogetherClient
|
|
10
|
-
from together.utils import enforce_trailing_slash
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class Together:
|
|
14
|
-
completions: resources.Completions
|
|
15
|
-
chat: resources.Chat
|
|
16
|
-
embeddings: resources.Embeddings
|
|
17
|
-
files: resources.Files
|
|
18
|
-
images: resources.Images
|
|
19
|
-
models: resources.Models
|
|
20
|
-
fine_tuning: resources.FineTuning
|
|
21
|
-
rerank: resources.Rerank
|
|
22
|
-
|
|
23
|
-
# client options
|
|
24
|
-
client: TogetherClient
|
|
25
|
-
|
|
26
|
-
def __init__(
|
|
27
|
-
self,
|
|
28
|
-
*,
|
|
29
|
-
api_key: str | None = None,
|
|
30
|
-
base_url: str | None = None,
|
|
31
|
-
timeout: float | None = None,
|
|
32
|
-
max_retries: int | None = None,
|
|
33
|
-
supplied_headers: Dict[str, str] | None = None,
|
|
34
|
-
) -> None:
|
|
35
|
-
"""Construct a new synchronous together client instance.
|
|
36
|
-
|
|
37
|
-
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
|
|
38
|
-
- `api_key` from `TOGETHER_API_KEY`
|
|
39
|
-
- `base_url` from `TOGETHER_BASE_URL`
|
|
40
|
-
"""
|
|
41
|
-
|
|
42
|
-
# get api key
|
|
43
|
-
if not api_key:
|
|
44
|
-
api_key = os.environ.get("TOGETHER_API_KEY")
|
|
45
|
-
|
|
46
|
-
if not api_key:
|
|
47
|
-
raise AuthenticationError(
|
|
48
|
-
"The api_key client option must be set either by passing api_key to the client or by setting the "
|
|
49
|
-
"TOGETHER_API_KEY environment variable"
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
# get base url
|
|
53
|
-
if not base_url:
|
|
54
|
-
base_url = os.environ.get("TOGETHER_BASE_URL")
|
|
55
|
-
|
|
56
|
-
if not base_url:
|
|
57
|
-
base_url = BASE_URL
|
|
58
|
-
|
|
59
|
-
if timeout is None:
|
|
60
|
-
timeout = TIMEOUT_SECS
|
|
61
|
-
|
|
62
|
-
if max_retries is None:
|
|
63
|
-
max_retries = MAX_RETRIES
|
|
64
|
-
|
|
65
|
-
# TogetherClient object
|
|
66
|
-
self.client = TogetherClient(
|
|
67
|
-
api_key=api_key,
|
|
68
|
-
base_url=enforce_trailing_slash(base_url),
|
|
69
|
-
timeout=timeout,
|
|
70
|
-
max_retries=max_retries,
|
|
71
|
-
supplied_headers=supplied_headers,
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
self.completions = resources.Completions(self.client)
|
|
75
|
-
self.chat = resources.Chat(self.client)
|
|
76
|
-
self.embeddings = resources.Embeddings(self.client)
|
|
77
|
-
self.files = resources.Files(self.client)
|
|
78
|
-
self.images = resources.Images(self.client)
|
|
79
|
-
self.models = resources.Models(self.client)
|
|
80
|
-
self.fine_tuning = resources.FineTuning(self.client)
|
|
81
|
-
self.rerank = resources.Rerank(self.client)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
class AsyncTogether:
|
|
85
|
-
completions: resources.AsyncCompletions
|
|
86
|
-
chat: resources.AsyncChat
|
|
87
|
-
embeddings: resources.AsyncEmbeddings
|
|
88
|
-
files: resources.AsyncFiles
|
|
89
|
-
images: resources.AsyncImages
|
|
90
|
-
models: resources.AsyncModels
|
|
91
|
-
fine_tuning: resources.AsyncFineTuning
|
|
92
|
-
rerank: resources.AsyncRerank
|
|
93
|
-
|
|
94
|
-
# client options
|
|
95
|
-
client: TogetherClient
|
|
96
|
-
|
|
97
|
-
def __init__(
|
|
98
|
-
self,
|
|
99
|
-
*,
|
|
100
|
-
api_key: str | None = None,
|
|
101
|
-
base_url: str | None = None,
|
|
102
|
-
timeout: float | None = None,
|
|
103
|
-
max_retries: int | None = None,
|
|
104
|
-
supplied_headers: Dict[str, str] | None = None,
|
|
105
|
-
) -> None:
|
|
106
|
-
"""Construct a new async together client instance.
|
|
107
|
-
|
|
108
|
-
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
|
|
109
|
-
- `api_key` from `TOGETHER_API_KEY`
|
|
110
|
-
- `base_url` from `TOGETHER_BASE_URL`
|
|
111
|
-
"""
|
|
112
|
-
|
|
113
|
-
# get api key
|
|
114
|
-
if not api_key:
|
|
115
|
-
api_key = os.environ.get("TOGETHER_API_KEY")
|
|
116
|
-
|
|
117
|
-
if not api_key:
|
|
118
|
-
raise AuthenticationError(
|
|
119
|
-
"The api_key client option must be set either by passing api_key to the client or by setting the "
|
|
120
|
-
"TOGETHER_API_KEY environment variable"
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
# get base url
|
|
124
|
-
if not base_url:
|
|
125
|
-
base_url = os.environ.get("TOGETHER_BASE_URL")
|
|
126
|
-
|
|
127
|
-
if not base_url:
|
|
128
|
-
base_url = BASE_URL
|
|
129
|
-
|
|
130
|
-
if timeout is None:
|
|
131
|
-
timeout = TIMEOUT_SECS
|
|
132
|
-
|
|
133
|
-
if max_retries is None:
|
|
134
|
-
max_retries = MAX_RETRIES
|
|
135
|
-
|
|
136
|
-
# TogetherClient object
|
|
137
|
-
self.client = TogetherClient(
|
|
138
|
-
api_key=api_key,
|
|
139
|
-
base_url=enforce_trailing_slash(base_url),
|
|
140
|
-
timeout=timeout,
|
|
141
|
-
max_retries=max_retries,
|
|
142
|
-
supplied_headers=supplied_headers,
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
self.completions = resources.AsyncCompletions(self.client)
|
|
146
|
-
self.chat = resources.AsyncChat(self.client)
|
|
147
|
-
self.embeddings = resources.AsyncEmbeddings(self.client)
|
|
148
|
-
self.files = resources.AsyncFiles(self.client)
|
|
149
|
-
self.images = resources.AsyncImages(self.client)
|
|
150
|
-
self.models = resources.AsyncModels(self.client)
|
|
151
|
-
self.fine_tuning = resources.AsyncFineTuning(self.client)
|
|
152
|
-
self.rerank = resources.AsyncRerank(self.client)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
Client = Together
|
|
156
|
-
|
|
157
|
-
AsyncClient = AsyncTogether
|
together/constants.py
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# Session constants
|
|
2
|
-
TIMEOUT_SECS = 600
|
|
3
|
-
MAX_SESSION_LIFETIME_SECS = 180
|
|
4
|
-
MAX_CONNECTION_RETRIES = 2
|
|
5
|
-
MAX_RETRIES = 5
|
|
6
|
-
INITIAL_RETRY_DELAY = 0.5
|
|
7
|
-
MAX_RETRY_DELAY = 8.0
|
|
8
|
-
|
|
9
|
-
# API defaults
|
|
10
|
-
BASE_URL = "https://api.together.xyz/v1"
|
|
11
|
-
|
|
12
|
-
# Download defaults
|
|
13
|
-
DOWNLOAD_BLOCK_SIZE = 10 * 1024 * 1024 # 10 MB
|
|
14
|
-
DISABLE_TQDM = False
|
|
15
|
-
|
|
16
|
-
# Messages
|
|
17
|
-
MISSING_API_KEY_MESSAGE = """TOGETHER_API_KEY not found.
|
|
18
|
-
Please set it as an environment variable or set it as together.api_key
|
|
19
|
-
Find your TOGETHER_API_KEY at https://api.together.xyz/settings/api-keys"""
|
|
20
|
-
|
|
21
|
-
# Minimum number of samples required for fine-tuning file
|
|
22
|
-
MIN_SAMPLES = 100
|
|
23
|
-
|
|
24
|
-
# the number of bytes in a gigabyte, used to convert bytes to GB for readable comparison
|
|
25
|
-
NUM_BYTES_IN_GB = 2**30
|
|
26
|
-
|
|
27
|
-
# maximum number of GB sized files we support finetuning for
|
|
28
|
-
MAX_FILE_SIZE_GB = 4.9
|
|
29
|
-
|
|
30
|
-
# expected columns for Parquet files
|
|
31
|
-
PARQUET_EXPECTED_COLUMNS = ["input_ids", "attention_mask", "labels"]
|
together/error.py
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import json
|
|
4
|
-
from typing import Any, Dict
|
|
5
|
-
|
|
6
|
-
from requests import RequestException
|
|
7
|
-
|
|
8
|
-
from together.types.error import TogetherErrorResponse
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class TogetherException(Exception):
|
|
12
|
-
def __init__(
|
|
13
|
-
self,
|
|
14
|
-
message: (
|
|
15
|
-
TogetherErrorResponse | Exception | str | RequestException | None
|
|
16
|
-
) = None,
|
|
17
|
-
headers: str | Dict[Any, Any] | None = None,
|
|
18
|
-
request_id: str | None = None,
|
|
19
|
-
http_status: int | None = None,
|
|
20
|
-
) -> None:
|
|
21
|
-
_message = (
|
|
22
|
-
json.dumps(message.model_dump(exclude_none=True))
|
|
23
|
-
if isinstance(message, TogetherErrorResponse)
|
|
24
|
-
else message
|
|
25
|
-
)
|
|
26
|
-
if http_status is not None:
|
|
27
|
-
self._message = f"Error code: {http_status} - {_message}"
|
|
28
|
-
else:
|
|
29
|
-
self._message = str(_message)
|
|
30
|
-
|
|
31
|
-
super().__init__(self._message)
|
|
32
|
-
|
|
33
|
-
self.http_status = http_status
|
|
34
|
-
self.headers = headers or {}
|
|
35
|
-
self.request_id = request_id
|
|
36
|
-
|
|
37
|
-
def __repr__(self) -> str:
|
|
38
|
-
repr_message = json.dumps(
|
|
39
|
-
{
|
|
40
|
-
"response": self._message,
|
|
41
|
-
"status": self.http_status,
|
|
42
|
-
"request_id": self.request_id,
|
|
43
|
-
"headers": self.headers,
|
|
44
|
-
}
|
|
45
|
-
)
|
|
46
|
-
return "%s(%r)" % (self.__class__.__name__, repr_message)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
class AuthenticationError(TogetherException):
|
|
50
|
-
def __init__(
|
|
51
|
-
self,
|
|
52
|
-
message: (
|
|
53
|
-
TogetherErrorResponse | Exception | str | RequestException | None
|
|
54
|
-
) = None,
|
|
55
|
-
**kwargs: Any,
|
|
56
|
-
) -> None:
|
|
57
|
-
super().__init__(message=message, **kwargs)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
class ResponseError(TogetherException):
|
|
61
|
-
def __init__(
|
|
62
|
-
self,
|
|
63
|
-
message: (
|
|
64
|
-
TogetherErrorResponse | Exception | str | RequestException | None
|
|
65
|
-
) = None,
|
|
66
|
-
**kwargs: Any,
|
|
67
|
-
) -> None:
|
|
68
|
-
super().__init__(message=message, **kwargs)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
class JSONError(TogetherException):
|
|
72
|
-
def __init__(
|
|
73
|
-
self,
|
|
74
|
-
message: (
|
|
75
|
-
TogetherErrorResponse | Exception | str | RequestException | None
|
|
76
|
-
) = None,
|
|
77
|
-
**kwargs: Any,
|
|
78
|
-
) -> None:
|
|
79
|
-
super().__init__(message=message, **kwargs)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
class InstanceError(TogetherException):
|
|
83
|
-
def __init__(self, model: str | None = "model", **kwargs: Any) -> None:
|
|
84
|
-
super().__init__(**kwargs)
|
|
85
|
-
self.message = f"""No running instances for {model}.
|
|
86
|
-
You can start an instance with one of the following methods:
|
|
87
|
-
1. navigating to the Together Playground at api.together.ai
|
|
88
|
-
2. starting one in python using together.Models.start(model_name)
|
|
89
|
-
3. `$ together models start <MODEL_NAME>` at the command line.
|
|
90
|
-
See `together.Models.list()` in python or `$ together models list` in command line
|
|
91
|
-
to get an updated list of valid model names.
|
|
92
|
-
"""
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
class RateLimitError(TogetherException):
|
|
96
|
-
def __init__(
|
|
97
|
-
self,
|
|
98
|
-
message: (
|
|
99
|
-
TogetherErrorResponse | Exception | str | RequestException | None
|
|
100
|
-
) = None,
|
|
101
|
-
**kwargs: Any,
|
|
102
|
-
) -> None:
|
|
103
|
-
super().__init__(message=message, **kwargs)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
class FileTypeError(TogetherException):
|
|
107
|
-
def __init__(
|
|
108
|
-
self,
|
|
109
|
-
message: (
|
|
110
|
-
TogetherErrorResponse | Exception | str | RequestException | None
|
|
111
|
-
) = None,
|
|
112
|
-
**kwargs: Any,
|
|
113
|
-
) -> None:
|
|
114
|
-
super().__init__(message=message, **kwargs)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
class AttributeError(TogetherException):
|
|
118
|
-
def __init__(
|
|
119
|
-
self,
|
|
120
|
-
message: (
|
|
121
|
-
TogetherErrorResponse | Exception | str | RequestException | None
|
|
122
|
-
) = None,
|
|
123
|
-
**kwargs: Any,
|
|
124
|
-
) -> None:
|
|
125
|
-
super().__init__(message=message, **kwargs)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
class Timeout(TogetherException):
|
|
129
|
-
def __init__(
|
|
130
|
-
self,
|
|
131
|
-
message: (
|
|
132
|
-
TogetherErrorResponse | Exception | str | RequestException | None
|
|
133
|
-
) = None,
|
|
134
|
-
**kwargs: Any,
|
|
135
|
-
) -> None:
|
|
136
|
-
super().__init__(message=message, **kwargs)
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
class APIConnectionError(TogetherException):
|
|
140
|
-
def __init__(
|
|
141
|
-
self,
|
|
142
|
-
message: (
|
|
143
|
-
TogetherErrorResponse | Exception | str | RequestException | None
|
|
144
|
-
) = None,
|
|
145
|
-
**kwargs: Any,
|
|
146
|
-
) -> None:
|
|
147
|
-
super().__init__(message=message, **kwargs)
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
class InvalidRequestError(TogetherException):
|
|
151
|
-
def __init__(
|
|
152
|
-
self,
|
|
153
|
-
message: (
|
|
154
|
-
TogetherErrorResponse | Exception | str | RequestException | None
|
|
155
|
-
) = None,
|
|
156
|
-
**kwargs: Any,
|
|
157
|
-
) -> None:
|
|
158
|
-
super().__init__(message=message, **kwargs)
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
class APIError(TogetherException):
|
|
162
|
-
def __init__(
|
|
163
|
-
self,
|
|
164
|
-
message: (
|
|
165
|
-
TogetherErrorResponse | Exception | str | RequestException | None
|
|
166
|
-
) = None,
|
|
167
|
-
**kwargs: Any,
|
|
168
|
-
) -> None:
|
|
169
|
-
super().__init__(message=message, **kwargs)
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
class ServiceUnavailableError(TogetherException):
|
|
173
|
-
def __init__(
|
|
174
|
-
self,
|
|
175
|
-
message: (
|
|
176
|
-
TogetherErrorResponse | Exception | str | RequestException | None
|
|
177
|
-
) = None,
|
|
178
|
-
**kwargs: Any,
|
|
179
|
-
) -> None:
|
|
180
|
-
super().__init__(message=message, **kwargs)
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
class DownloadError(TogetherException):
|
|
184
|
-
def __init__(
|
|
185
|
-
self,
|
|
186
|
-
message: (
|
|
187
|
-
TogetherErrorResponse | Exception | str | RequestException | None
|
|
188
|
-
) = None,
|
|
189
|
-
**kwargs: Any,
|
|
190
|
-
) -> None:
|
|
191
|
-
super().__init__(message=message, **kwargs)
|