together 1.2.3__tar.gz → 1.2.5__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.2.3 → together-1.2.5}/PKG-INFO +1 -1
- {together-1.2.3 → together-1.2.5}/pyproject.toml +2 -2
- {together-1.2.3 → together-1.2.5}/src/together/__init__.py +14 -6
- {together-1.2.3 → together-1.2.5}/src/together/abstract/api_requestor.py +30 -18
- {together-1.2.3 → together-1.2.5}/src/together/cli/api/chat.py +4 -2
- {together-1.2.3 → together-1.2.5}/src/together/cli/api/completions.py +4 -2
- {together-1.2.3 → together-1.2.5}/src/together/cli/api/files.py +4 -4
- {together-1.2.3 → together-1.2.5}/src/together/cli/api/finetune.py +4 -4
- {together-1.2.3 → together-1.2.5}/src/together/error.py +1 -1
- together-1.2.5/src/together/legacy/__init__.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/legacy/complete.py +6 -4
- {together-1.2.3 → together-1.2.5}/src/together/legacy/embeddings.py +3 -1
- {together-1.2.3 → together-1.2.5}/src/together/legacy/files.py +9 -5
- {together-1.2.3 → together-1.2.5}/src/together/legacy/finetune.py +10 -6
- {together-1.2.3 → together-1.2.5}/src/together/legacy/images.py +3 -1
- {together-1.2.3 → together-1.2.5}/src/together/legacy/models.py +2 -2
- {together-1.2.3 → together-1.2.5}/src/together/resources/chat/completions.py +2 -2
- {together-1.2.3 → together-1.2.5}/src/together/resources/completions.py +2 -2
- {together-1.2.3 → together-1.2.5}/src/together/resources/embeddings.py +2 -2
- {together-1.2.3 → together-1.2.5}/src/together/resources/finetune.py +2 -2
- {together-1.2.3 → together-1.2.5}/src/together/resources/images.py +2 -2
- {together-1.2.3 → together-1.2.5}/src/together/types/chat_completions.py +5 -2
- together-1.2.3/src/together/abstract/__init__.py +0 -1
- {together-1.2.3 → together-1.2.5}/LICENSE +0 -0
- {together-1.2.3 → together-1.2.5}/README.md +0 -0
- {together-1.2.3/src/together/cli → together-1.2.5/src/together/abstract}/__init__.py +0 -0
- {together-1.2.3/src/together/cli/api → together-1.2.5/src/together/cli}/__init__.py +0 -0
- {together-1.2.3/src/together/legacy → together-1.2.5/src/together/cli/api}/__init__.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/cli/api/images.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/cli/api/models.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/cli/cli.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/client.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/constants.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/filemanager.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/legacy/base.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/resources/__init__.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/resources/chat/__init__.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/resources/files.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/resources/models.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/together_response.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/types/__init__.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/types/abstract.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/types/common.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/types/completions.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/types/embeddings.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/types/error.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/types/files.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/types/finetune.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/types/images.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/types/models.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/utils/__init__.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/utils/_log.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/utils/api_helpers.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/utils/files.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/utils/tools.py +0 -0
- {together-1.2.3 → together-1.2.5}/src/together/version.py +0 -0
|
@@ -12,7 +12,7 @@ build-backend = "poetry.masonry.api"
|
|
|
12
12
|
|
|
13
13
|
[tool.poetry]
|
|
14
14
|
name = "together"
|
|
15
|
-
version = "1.2.
|
|
15
|
+
version = "1.2.5"
|
|
16
16
|
authors = [
|
|
17
17
|
"Together AI <support@together.ai>"
|
|
18
18
|
]
|
|
@@ -50,7 +50,7 @@ optional = true
|
|
|
50
50
|
|
|
51
51
|
[tool.poetry.group.quality.dependencies]
|
|
52
52
|
black = ">=23.1,<25.0"
|
|
53
|
-
ruff = ">=0.3.2,<0.
|
|
53
|
+
ruff = ">=0.3.2,<0.5.0"
|
|
54
54
|
types-tqdm = "^4.65.0.0"
|
|
55
55
|
types-tabulate = "^0.9.0.3"
|
|
56
56
|
pre-commit = "3.5.0"
|
|
@@ -16,6 +16,12 @@ from together import (
|
|
|
16
16
|
)
|
|
17
17
|
from together.version import VERSION
|
|
18
18
|
|
|
19
|
+
from together.legacy.complete import AsyncComplete, Complete, Completion
|
|
20
|
+
from together.legacy.embeddings import Embeddings
|
|
21
|
+
from together.legacy.files import Files
|
|
22
|
+
from together.legacy.finetune import Finetune
|
|
23
|
+
from together.legacy.images import Image
|
|
24
|
+
from together.legacy.models import Models
|
|
19
25
|
|
|
20
26
|
version = VERSION
|
|
21
27
|
|
|
@@ -37,12 +43,6 @@ from together.client import AsyncClient, AsyncTogether, Client, Together
|
|
|
37
43
|
api_key: str | None = None # To be deprecated in the next major release
|
|
38
44
|
|
|
39
45
|
# Legacy functions
|
|
40
|
-
from together.legacy.complete import AsyncComplete, Complete, Completion
|
|
41
|
-
from together.legacy.embeddings import Embeddings
|
|
42
|
-
from together.legacy.files import Files
|
|
43
|
-
from together.legacy.finetune import Finetune
|
|
44
|
-
from together.legacy.images import Image
|
|
45
|
-
from together.legacy.models import Models
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
__all__ = [
|
|
@@ -61,4 +61,12 @@ __all__ = [
|
|
|
61
61
|
"together_response",
|
|
62
62
|
"client",
|
|
63
63
|
"utils",
|
|
64
|
+
"Complete",
|
|
65
|
+
"AsyncComplete",
|
|
66
|
+
"Completion",
|
|
67
|
+
"Embeddings",
|
|
68
|
+
"Files",
|
|
69
|
+
"Finetune",
|
|
70
|
+
"Image",
|
|
71
|
+
"Models",
|
|
64
72
|
]
|
|
@@ -121,7 +121,7 @@ class APIRequestor:
|
|
|
121
121
|
See also
|
|
122
122
|
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After#syntax
|
|
123
123
|
"""
|
|
124
|
-
if response_headers
|
|
124
|
+
if not response_headers:
|
|
125
125
|
return None
|
|
126
126
|
|
|
127
127
|
# First, try the non-standard `retry-after-ms` header for milliseconds,
|
|
@@ -485,6 +485,8 @@ class APIRequestor:
|
|
|
485
485
|
_thread_context.session.close()
|
|
486
486
|
_thread_context.session = _make_session(MAX_CONNECTION_RETRIES)
|
|
487
487
|
_thread_context.session_create_time = time.time()
|
|
488
|
+
|
|
489
|
+
result = None
|
|
488
490
|
try:
|
|
489
491
|
result = _thread_context.session.request(
|
|
490
492
|
options.method,
|
|
@@ -500,11 +502,13 @@ class APIRequestor:
|
|
|
500
502
|
except requests.exceptions.Timeout as e:
|
|
501
503
|
utils.log_debug("Encountered requests.exceptions.Timeout")
|
|
502
504
|
|
|
505
|
+
result_headers = dict(result.headers) if result is not None else {}
|
|
506
|
+
|
|
503
507
|
if remaining_retries > 0:
|
|
504
508
|
return self._retry_request(
|
|
505
509
|
options,
|
|
506
510
|
remaining_retries=remaining_retries,
|
|
507
|
-
response_headers=
|
|
511
|
+
response_headers=result_headers,
|
|
508
512
|
stream=stream,
|
|
509
513
|
request_timeout=request_timeout,
|
|
510
514
|
)
|
|
@@ -513,11 +517,13 @@ class APIRequestor:
|
|
|
513
517
|
except requests.exceptions.RequestException as e:
|
|
514
518
|
utils.log_debug("Encountered requests.exceptions.RequestException")
|
|
515
519
|
|
|
520
|
+
result_headers = dict(result.headers) if result is not None else {}
|
|
521
|
+
|
|
516
522
|
if remaining_retries > 0:
|
|
517
523
|
return self._retry_request(
|
|
518
524
|
options,
|
|
519
525
|
remaining_retries=remaining_retries,
|
|
520
|
-
response_headers=
|
|
526
|
+
response_headers=result_headers,
|
|
521
527
|
stream=stream,
|
|
522
528
|
request_timeout=request_timeout,
|
|
523
529
|
)
|
|
@@ -527,26 +533,32 @@ class APIRequestor:
|
|
|
527
533
|
) from e
|
|
528
534
|
|
|
529
535
|
# retry on 5XX error or rate-limit
|
|
530
|
-
if
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
if remaining_retries > 0:
|
|
536
|
-
return self._retry_request(
|
|
537
|
-
options,
|
|
538
|
-
remaining_retries=remaining_retries,
|
|
539
|
-
response_headers=dict(result.headers),
|
|
540
|
-
stream=stream,
|
|
541
|
-
request_timeout=request_timeout,
|
|
536
|
+
if result is not None:
|
|
537
|
+
if 500 <= result.status_code < 600 or result.status_code == 429:
|
|
538
|
+
utils.log_debug(
|
|
539
|
+
f"Encountered requests.exceptions.HTTPError. Error code: {result.status_code}"
|
|
542
540
|
)
|
|
543
541
|
|
|
542
|
+
result_headers = dict(result.headers) if result is not None else {}
|
|
543
|
+
|
|
544
|
+
if remaining_retries > 0:
|
|
545
|
+
return self._retry_request(
|
|
546
|
+
options,
|
|
547
|
+
remaining_retries=remaining_retries,
|
|
548
|
+
response_headers=result_headers,
|
|
549
|
+
stream=stream,
|
|
550
|
+
request_timeout=request_timeout,
|
|
551
|
+
)
|
|
552
|
+
|
|
553
|
+
status_code = result.status_code if result is not None else 0
|
|
554
|
+
result_headers = dict(result.headers) if result is not None else {}
|
|
555
|
+
|
|
544
556
|
utils.log_debug(
|
|
545
557
|
"Together API response",
|
|
546
558
|
path=abs_url,
|
|
547
|
-
response_code=
|
|
548
|
-
processing_ms=
|
|
549
|
-
request_id=
|
|
559
|
+
response_code=status_code,
|
|
560
|
+
processing_ms=result_headers.get("x-total-time"),
|
|
561
|
+
request_id=result_headers.get("CF-RAY"),
|
|
550
562
|
)
|
|
551
563
|
|
|
552
564
|
return result # type: ignore
|
|
@@ -238,7 +238,7 @@ def chat(
|
|
|
238
238
|
assert chunk.choices
|
|
239
239
|
|
|
240
240
|
if raw:
|
|
241
|
-
click.echo(f"{json.dumps(chunk.model_dump())}")
|
|
241
|
+
click.echo(f"{json.dumps(chunk.model_dump(exclude_none=True))}")
|
|
242
242
|
continue
|
|
243
243
|
|
|
244
244
|
should_print_header = len(chunk.choices) > 1
|
|
@@ -261,7 +261,9 @@ def chat(
|
|
|
261
261
|
assert isinstance(response.choices, list)
|
|
262
262
|
|
|
263
263
|
if raw:
|
|
264
|
-
click.echo(
|
|
264
|
+
click.echo(
|
|
265
|
+
f"{json.dumps(response.model_dump(exclude_none=True), indent=4)}"
|
|
266
|
+
)
|
|
265
267
|
return
|
|
266
268
|
|
|
267
269
|
should_print_header = len(response.choices) > 1
|
|
@@ -80,7 +80,7 @@ def completions(
|
|
|
80
80
|
assert chunk.choices
|
|
81
81
|
|
|
82
82
|
if raw:
|
|
83
|
-
click.echo(f"{json.dumps(chunk.model_dump())}")
|
|
83
|
+
click.echo(f"{json.dumps(chunk.model_dump(exclude_none=True))}")
|
|
84
84
|
continue
|
|
85
85
|
|
|
86
86
|
should_print_header = len(chunk.choices) > 1
|
|
@@ -104,7 +104,9 @@ def completions(
|
|
|
104
104
|
assert isinstance(response.choices, list)
|
|
105
105
|
|
|
106
106
|
if raw:
|
|
107
|
-
click.echo(
|
|
107
|
+
click.echo(
|
|
108
|
+
f"{json.dumps(response.model_dump(exclude_none=True), indent=4)}"
|
|
109
|
+
)
|
|
108
110
|
return
|
|
109
111
|
|
|
110
112
|
should_print_header = len(response.choices) > 1
|
|
@@ -44,7 +44,7 @@ def upload(ctx: click.Context, file: pathlib.Path, purpose: str, check: bool) ->
|
|
|
44
44
|
|
|
45
45
|
response = client.files.upload(file=file, purpose=purpose, check=check)
|
|
46
46
|
|
|
47
|
-
click.echo(json.dumps(response.model_dump(), indent=4))
|
|
47
|
+
click.echo(json.dumps(response.model_dump(exclude_none=True), indent=4))
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
@files.command()
|
|
@@ -83,7 +83,7 @@ def retrieve(ctx: click.Context, id: str) -> None:
|
|
|
83
83
|
|
|
84
84
|
response = client.files.retrieve(id=id)
|
|
85
85
|
|
|
86
|
-
click.echo(json.dumps(response.model_dump(), indent=4))
|
|
86
|
+
click.echo(json.dumps(response.model_dump(exclude_none=True), indent=4))
|
|
87
87
|
|
|
88
88
|
|
|
89
89
|
@files.command()
|
|
@@ -97,7 +97,7 @@ def retrieve_content(ctx: click.Context, id: str, output: str) -> None:
|
|
|
97
97
|
|
|
98
98
|
response = client.files.retrieve_content(id=id, output=output)
|
|
99
99
|
|
|
100
|
-
click.echo(json.dumps(response.model_dump(), indent=4))
|
|
100
|
+
click.echo(json.dumps(response.model_dump(exclude_none=True), indent=4))
|
|
101
101
|
|
|
102
102
|
|
|
103
103
|
@files.command()
|
|
@@ -110,7 +110,7 @@ def delete(ctx: click.Context, id: str) -> None:
|
|
|
110
110
|
|
|
111
111
|
response = client.files.delete(id=id)
|
|
112
112
|
|
|
113
|
-
click.echo(json.dumps(response.model_dump(), indent=4))
|
|
113
|
+
click.echo(json.dumps(response.model_dump(exclude_none=True), indent=4))
|
|
114
114
|
|
|
115
115
|
|
|
116
116
|
@files.command()
|
|
@@ -97,7 +97,7 @@ def create(
|
|
|
97
97
|
wandb_api_key=wandb_api_key,
|
|
98
98
|
)
|
|
99
99
|
|
|
100
|
-
click.echo(json.dumps(response.model_dump(), indent=4))
|
|
100
|
+
click.echo(json.dumps(response.model_dump(exclude_none=True), indent=4))
|
|
101
101
|
|
|
102
102
|
|
|
103
103
|
@fine_tuning.command()
|
|
@@ -142,7 +142,7 @@ def retrieve(ctx: click.Context, fine_tune_id: str) -> None:
|
|
|
142
142
|
# remove events from response for cleaner output
|
|
143
143
|
response.events = None
|
|
144
144
|
|
|
145
|
-
click.echo(json.dumps(response.model_dump(), indent=4))
|
|
145
|
+
click.echo(json.dumps(response.model_dump(exclude_none=True), indent=4))
|
|
146
146
|
|
|
147
147
|
|
|
148
148
|
@fine_tuning.command()
|
|
@@ -164,7 +164,7 @@ def cancel(ctx: click.Context, fine_tune_id: str, quiet: bool = False) -> None:
|
|
|
164
164
|
return
|
|
165
165
|
response = client.fine_tuning.cancel(fine_tune_id)
|
|
166
166
|
|
|
167
|
-
click.echo(json.dumps(response.model_dump(), indent=4))
|
|
167
|
+
click.echo(json.dumps(response.model_dump(exclude_none=True), indent=4))
|
|
168
168
|
|
|
169
169
|
|
|
170
170
|
@fine_tuning.command()
|
|
@@ -223,4 +223,4 @@ def download(
|
|
|
223
223
|
fine_tune_id, output=output_dir, checkpoint_step=checkpoint_step
|
|
224
224
|
)
|
|
225
225
|
|
|
226
|
-
click.echo(json.dumps(response.model_dump(), indent=4))
|
|
226
|
+
click.echo(json.dumps(response.model_dump(exclude_none=True), indent=4))
|
|
File without changes
|
|
@@ -25,9 +25,11 @@ class Complete:
|
|
|
25
25
|
|
|
26
26
|
client = together.Together(api_key=api_key)
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
result = client.completions.create(prompt=prompt, stream=False, **kwargs)
|
|
29
|
+
|
|
30
|
+
assert isinstance(result, CompletionResponse)
|
|
31
|
+
|
|
32
|
+
return result.model_dump(exclude_none=True)
|
|
31
33
|
|
|
32
34
|
@classmethod
|
|
33
35
|
@deprecated # type: ignore
|
|
@@ -46,7 +48,7 @@ class Complete:
|
|
|
46
48
|
client = together.Together(api_key=api_key)
|
|
47
49
|
|
|
48
50
|
return (
|
|
49
|
-
token.model_dump() # type: ignore
|
|
51
|
+
token.model_dump(exclude_none=True) # type: ignore
|
|
50
52
|
for token in client.completions.create(prompt=prompt, stream=True, **kwargs)
|
|
51
53
|
)
|
|
52
54
|
|
|
@@ -24,7 +24,7 @@ class Files:
|
|
|
24
24
|
|
|
25
25
|
client = together.Together(api_key=api_key)
|
|
26
26
|
|
|
27
|
-
return client.files.list().model_dump()
|
|
27
|
+
return client.files.list().model_dump(exclude_none=True)
|
|
28
28
|
|
|
29
29
|
@classmethod
|
|
30
30
|
def check(self, file: str) -> Dict[str, object]:
|
|
@@ -54,7 +54,9 @@ class Files:
|
|
|
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
|
+
response = client.files.upload(file=file, check=False).model_dump(
|
|
58
|
+
exclude_none=True
|
|
59
|
+
)
|
|
58
60
|
|
|
59
61
|
if check:
|
|
60
62
|
response["report_dict"] = report_dict
|
|
@@ -76,7 +78,7 @@ class Files:
|
|
|
76
78
|
|
|
77
79
|
client = together.Together(api_key=api_key)
|
|
78
80
|
|
|
79
|
-
return client.files.delete(id=file_id).model_dump()
|
|
81
|
+
return client.files.delete(id=file_id).model_dump(exclude_none=True)
|
|
80
82
|
|
|
81
83
|
@classmethod
|
|
82
84
|
@deprecated # type: ignore
|
|
@@ -93,7 +95,7 @@ class Files:
|
|
|
93
95
|
|
|
94
96
|
client = together.Together(api_key=api_key)
|
|
95
97
|
|
|
96
|
-
return client.files.retrieve(id=file_id).model_dump()
|
|
98
|
+
return client.files.retrieve(id=file_id).model_dump(exclude_none=True)
|
|
97
99
|
|
|
98
100
|
@classmethod
|
|
99
101
|
@deprecated # type: ignore
|
|
@@ -111,7 +113,9 @@ class Files:
|
|
|
111
113
|
|
|
112
114
|
client = together.Together(api_key=api_key)
|
|
113
115
|
|
|
114
|
-
return client.files.retrieve_content(id=file_id, output=output).
|
|
116
|
+
return client.files.retrieve_content(id=file_id, output=output).dict(
|
|
117
|
+
exclude_none=True
|
|
118
|
+
)
|
|
115
119
|
|
|
116
120
|
@classmethod
|
|
117
121
|
@deprecated # type: ignore
|
|
@@ -47,7 +47,7 @@ class Finetune:
|
|
|
47
47
|
learning_rate=learning_rate,
|
|
48
48
|
suffix=suffix,
|
|
49
49
|
wandb_api_key=wandb_api_key,
|
|
50
|
-
).model_dump()
|
|
50
|
+
).model_dump(exclude_none=True)
|
|
51
51
|
|
|
52
52
|
@classmethod
|
|
53
53
|
@deprecated # type: ignore
|
|
@@ -63,7 +63,7 @@ class Finetune:
|
|
|
63
63
|
|
|
64
64
|
client = together.Together(api_key=api_key)
|
|
65
65
|
|
|
66
|
-
return client.fine_tuning.list().model_dump()
|
|
66
|
+
return client.fine_tuning.list().model_dump(exclude_none=True)
|
|
67
67
|
|
|
68
68
|
@classmethod
|
|
69
69
|
@deprecated # type: ignore
|
|
@@ -80,7 +80,9 @@ class Finetune:
|
|
|
80
80
|
|
|
81
81
|
client = together.Together(api_key=api_key)
|
|
82
82
|
|
|
83
|
-
return client.fine_tuning.retrieve(id=fine_tune_id).model_dump(
|
|
83
|
+
return client.fine_tuning.retrieve(id=fine_tune_id).model_dump(
|
|
84
|
+
exclude_none=True
|
|
85
|
+
)
|
|
84
86
|
|
|
85
87
|
@classmethod
|
|
86
88
|
@deprecated # type: ignore
|
|
@@ -97,7 +99,7 @@ class Finetune:
|
|
|
97
99
|
|
|
98
100
|
client = together.Together(api_key=api_key)
|
|
99
101
|
|
|
100
|
-
return client.fine_tuning.cancel(id=fine_tune_id).model_dump()
|
|
102
|
+
return client.fine_tuning.cancel(id=fine_tune_id).model_dump(exclude_none=True)
|
|
101
103
|
|
|
102
104
|
@classmethod
|
|
103
105
|
@deprecated # type: ignore
|
|
@@ -114,7 +116,9 @@ class Finetune:
|
|
|
114
116
|
|
|
115
117
|
client = together.Together(api_key=api_key)
|
|
116
118
|
|
|
117
|
-
return client.fine_tuning.list_events(id=fine_tune_id).model_dump(
|
|
119
|
+
return client.fine_tuning.list_events(id=fine_tune_id).model_dump(
|
|
120
|
+
exclude_none=True
|
|
121
|
+
)
|
|
118
122
|
|
|
119
123
|
@classmethod
|
|
120
124
|
@deprecated # type: ignore
|
|
@@ -170,4 +174,4 @@ class Finetune:
|
|
|
170
174
|
|
|
171
175
|
return client.fine_tuning.download(
|
|
172
176
|
id=fine_tune_id, output=output, checkpoint_step=step
|
|
173
|
-
).model_dump()
|
|
177
|
+
).model_dump(exclude_none=True)
|
|
@@ -20,7 +20,7 @@ class Models:
|
|
|
20
20
|
|
|
21
21
|
client = together.Together(api_key=api_key)
|
|
22
22
|
|
|
23
|
-
return [item.model_dump() for item in client.models.list()]
|
|
23
|
+
return [item.model_dump(exclude_none=True) for item in client.models.list()]
|
|
24
24
|
|
|
25
25
|
@classmethod
|
|
26
26
|
@deprecated # type: ignore
|
|
@@ -41,4 +41,4 @@ class Models:
|
|
|
41
41
|
|
|
42
42
|
for item in model_list:
|
|
43
43
|
if item.id == model:
|
|
44
|
-
return item.model_dump()
|
|
44
|
+
return item.model_dump(exclude_none=True)
|
|
@@ -131,7 +131,7 @@ class ChatCompletions:
|
|
|
131
131
|
response_format=response_format,
|
|
132
132
|
tools=tools,
|
|
133
133
|
tool_choice=tool_choice,
|
|
134
|
-
).model_dump()
|
|
134
|
+
).model_dump(exclude_none=True)
|
|
135
135
|
|
|
136
136
|
response, _, _ = requestor.request(
|
|
137
137
|
options=TogetherRequest(
|
|
@@ -268,7 +268,7 @@ class AsyncChatCompletions:
|
|
|
268
268
|
response_format=response_format,
|
|
269
269
|
tools=tools,
|
|
270
270
|
tool_choice=tool_choice,
|
|
271
|
-
).model_dump()
|
|
271
|
+
).model_dump(exclude_none=True)
|
|
272
272
|
|
|
273
273
|
response, _, _ = await requestor.arequest(
|
|
274
274
|
options=TogetherRequest(
|
|
@@ -113,7 +113,7 @@ class Completions:
|
|
|
113
113
|
echo=echo,
|
|
114
114
|
n=n,
|
|
115
115
|
safety_model=safety_model,
|
|
116
|
-
).model_dump()
|
|
116
|
+
).model_dump(exclude_none=True)
|
|
117
117
|
|
|
118
118
|
response, _, _ = requestor.request(
|
|
119
119
|
options=TogetherRequest(
|
|
@@ -232,7 +232,7 @@ class AsyncCompletions:
|
|
|
232
232
|
echo=echo,
|
|
233
233
|
n=n,
|
|
234
234
|
safety_model=safety_model,
|
|
235
|
-
).model_dump()
|
|
235
|
+
).model_dump(exclude_none=True)
|
|
236
236
|
|
|
237
237
|
response, _, _ = await requestor.arequest(
|
|
238
238
|
options=TogetherRequest(
|
|
@@ -40,7 +40,7 @@ class Embeddings:
|
|
|
40
40
|
parameter_payload = EmbeddingRequest(
|
|
41
41
|
input=input,
|
|
42
42
|
model=model,
|
|
43
|
-
).model_dump()
|
|
43
|
+
).model_dump(exclude_none=True)
|
|
44
44
|
|
|
45
45
|
response, _, _ = requestor.request(
|
|
46
46
|
options=TogetherRequest(
|
|
@@ -84,7 +84,7 @@ class AsyncEmbeddings:
|
|
|
84
84
|
parameter_payload = EmbeddingRequest(
|
|
85
85
|
input=input,
|
|
86
86
|
model=model,
|
|
87
|
-
).model_dump()
|
|
87
|
+
).model_dump(exclude_none=True)
|
|
88
88
|
|
|
89
89
|
response, _, _ = await requestor.arequest(
|
|
90
90
|
options=TogetherRequest(
|
|
@@ -90,7 +90,7 @@ class FineTuning:
|
|
|
90
90
|
training_type=training_type,
|
|
91
91
|
suffix=suffix,
|
|
92
92
|
wandb_key=wandb_api_key,
|
|
93
|
-
).model_dump()
|
|
93
|
+
).model_dump(exclude_none=True)
|
|
94
94
|
|
|
95
95
|
response, _, _ = requestor.request(
|
|
96
96
|
options=TogetherRequest(
|
|
@@ -304,7 +304,7 @@ class AsyncFineTuning:
|
|
|
304
304
|
learning_rate=learning_rate,
|
|
305
305
|
suffix=suffix,
|
|
306
306
|
wandb_key=wandb_api_key,
|
|
307
|
-
).model_dump()
|
|
307
|
+
).model_dump(exclude_none=True)
|
|
308
308
|
|
|
309
309
|
response, _, _ = await requestor.arequest(
|
|
310
310
|
options=TogetherRequest(
|
|
@@ -67,7 +67,7 @@ class Images:
|
|
|
67
67
|
height=height,
|
|
68
68
|
width=width,
|
|
69
69
|
negative_prompt=negative_prompt,
|
|
70
|
-
).model_dump()
|
|
70
|
+
).model_dump(exclude_none=True)
|
|
71
71
|
|
|
72
72
|
response, _, _ = requestor.request(
|
|
73
73
|
options=TogetherRequest(
|
|
@@ -140,7 +140,7 @@ class AsyncImages:
|
|
|
140
140
|
height=height,
|
|
141
141
|
width=width,
|
|
142
142
|
negative_prompt=negative_prompt,
|
|
143
|
-
).model_dump()
|
|
143
|
+
).model_dump(exclude_none=True)
|
|
144
144
|
|
|
145
145
|
response, _, _ = await requestor.arequest(
|
|
146
146
|
options=TogetherRequest(
|
|
@@ -4,7 +4,7 @@ import warnings
|
|
|
4
4
|
from enum import Enum
|
|
5
5
|
from typing import Any, Dict, List
|
|
6
6
|
|
|
7
|
-
from pydantic import
|
|
7
|
+
from pydantic import model_validator
|
|
8
8
|
from typing_extensions import Self
|
|
9
9
|
|
|
10
10
|
from together.types.abstract import BaseModel
|
|
@@ -48,7 +48,10 @@ class ChatCompletionMessage(BaseModel):
|
|
|
48
48
|
|
|
49
49
|
class ResponseFormat(BaseModel):
|
|
50
50
|
type: ResponseFormatType
|
|
51
|
-
schema_: Dict[str, Any] | None =
|
|
51
|
+
schema_: Dict[str, Any] | None = None
|
|
52
|
+
|
|
53
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
54
|
+
return {"schema": self.schema_, "type": self.type}
|
|
52
55
|
|
|
53
56
|
|
|
54
57
|
class FunctionTool(BaseModel):
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from together.abstract.api_requestor import APIRequestor
|
|
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
|