together 1.5.34__py3-none-any.whl → 2.0.0a6__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 -114
- 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/{cli → lib/cli}/api/endpoints.py +65 -81
- together/{cli/api/evaluation.py → lib/cli/api/evals.py} +152 -43
- together/{cli → lib/cli}/api/files.py +20 -17
- together/{cli/api/finetune.py → lib/cli/api/fine_tuning.py} +116 -172
- together/{cli → lib/cli}/api/models.py +34 -27
- together/lib/cli/api/utils.py +50 -0
- together/{cli → lib/cli}/cli.py +16 -26
- together/{constants.py → lib/constants.py} +11 -24
- 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 +397 -0
- together/{utils → lib/utils}/__init__.py +6 -14
- together/{utils → lib/utils}/_log.py +11 -16
- together/{utils → lib/utils}/files.py +90 -288
- together/lib/utils/serializer.py +10 -0
- together/{utils → lib/utils}/tools.py +19 -55
- together/resources/__init__.py +225 -39
- together/resources/audio/__init__.py +72 -48
- together/resources/audio/audio.py +198 -0
- together/resources/audio/speech.py +574 -128
- together/resources/audio/transcriptions.py +247 -261
- together/resources/audio/translations.py +221 -241
- together/resources/audio/voices.py +111 -41
- 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 -263
- 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 +884 -225
- together/resources/embeddings.py +172 -68
- together/resources/endpoints.py +589 -477
- together/resources/evals.py +452 -0
- together/resources/files.py +397 -129
- together/resources/fine_tuning.py +1033 -0
- together/resources/hardware.py +181 -0
- together/resources/images.py +258 -104
- together/resources/jobs.py +214 -0
- together/resources/models.py +223 -193
- together/resources/rerank.py +190 -92
- together/resources/videos.py +286 -214
- together/types/__init__.py +66 -167
- 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_create_response.py +10 -0
- together/types/video_job.py +57 -0
- together-2.0.0a6.dist-info/METADATA +729 -0
- together-2.0.0a6.dist-info/RECORD +165 -0
- {together-1.5.34.dist-info → together-2.0.0a6.dist-info}/WHEEL +1 -1
- together-2.0.0a6.dist-info/entry_points.txt +2 -0
- {together-1.5.34.dist-info → together-2.0.0a6.dist-info}/licenses/LICENSE +1 -1
- together/abstract/api_requestor.py +0 -770
- together/cli/api/chat.py +0 -298
- together/cli/api/completions.py +0 -119
- together/cli/api/images.py +0 -93
- together/cli/api/utils.py +0 -139
- together/client.py +0 -186
- together/error.py +0 -194
- together/filemanager.py +0 -635
- 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/batch.py +0 -165
- together/resources/code_interpreter.py +0 -82
- together/resources/evaluation.py +0 -808
- together/resources/finetune.py +0 -1388
- together/together_response.py +0 -50
- together/types/abstract.py +0 -26
- together/types/audio_speech.py +0 -311
- together/types/batch.py +0 -54
- together/types/chat_completions.py +0 -210
- together/types/code_interpreter.py +0 -57
- together/types/common.py +0 -67
- together/types/completions.py +0 -107
- together/types/embeddings.py +0 -35
- together/types/endpoints.py +0 -123
- together/types/error.py +0 -16
- together/types/evaluation.py +0 -93
- together/types/files.py +0 -93
- together/types/finetune.py +0 -464
- together/types/images.py +0 -42
- together/types/models.py +0 -96
- together/types/rerank.py +0 -43
- together/types/videos.py +0 -69
- together/utils/api_helpers.py +0 -124
- together/version.py +0 -6
- together-1.5.34.dist-info/METADATA +0 -583
- together-1.5.34.dist-info/RECORD +0 -77
- together-1.5.34.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/_client.py
ADDED
|
@@ -0,0 +1,1033 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from typing import TYPE_CHECKING, Any, Mapping
|
|
7
|
+
from typing_extensions import Self, override
|
|
8
|
+
|
|
9
|
+
import httpx
|
|
10
|
+
|
|
11
|
+
from . import _exceptions
|
|
12
|
+
from ._qs import Querystring
|
|
13
|
+
from ._types import (
|
|
14
|
+
Omit,
|
|
15
|
+
Timeout,
|
|
16
|
+
NotGiven,
|
|
17
|
+
Transport,
|
|
18
|
+
ProxiesTypes,
|
|
19
|
+
RequestOptions,
|
|
20
|
+
not_given,
|
|
21
|
+
)
|
|
22
|
+
from ._utils import is_given, get_async_library
|
|
23
|
+
from ._compat import cached_property
|
|
24
|
+
from ._version import __version__
|
|
25
|
+
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
|
|
26
|
+
from ._exceptions import TogetherError, APIStatusError
|
|
27
|
+
from ._base_client import (
|
|
28
|
+
DEFAULT_MAX_RETRIES,
|
|
29
|
+
SyncAPIClient,
|
|
30
|
+
AsyncAPIClient,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
if TYPE_CHECKING:
|
|
34
|
+
from .resources import (
|
|
35
|
+
chat,
|
|
36
|
+
jobs,
|
|
37
|
+
audio,
|
|
38
|
+
evals,
|
|
39
|
+
files,
|
|
40
|
+
images,
|
|
41
|
+
models,
|
|
42
|
+
rerank,
|
|
43
|
+
videos,
|
|
44
|
+
batches,
|
|
45
|
+
hardware,
|
|
46
|
+
endpoints,
|
|
47
|
+
embeddings,
|
|
48
|
+
completions,
|
|
49
|
+
fine_tuning,
|
|
50
|
+
code_interpreter,
|
|
51
|
+
)
|
|
52
|
+
from .resources.jobs import JobsResource, AsyncJobsResource
|
|
53
|
+
from .resources.evals import EvalsResource, AsyncEvalsResource
|
|
54
|
+
from .resources.files import FilesResource, AsyncFilesResource
|
|
55
|
+
from .resources.images import ImagesResource, AsyncImagesResource
|
|
56
|
+
from .resources.models import ModelsResource, AsyncModelsResource
|
|
57
|
+
from .resources.rerank import RerankResource, AsyncRerankResource
|
|
58
|
+
from .resources.videos import VideosResource, AsyncVideosResource
|
|
59
|
+
from .resources.batches import BatchesResource, AsyncBatchesResource
|
|
60
|
+
from .resources.hardware import HardwareResource, AsyncHardwareResource
|
|
61
|
+
from .resources.chat.chat import ChatResource, AsyncChatResource
|
|
62
|
+
from .resources.endpoints import EndpointsResource, AsyncEndpointsResource
|
|
63
|
+
from .resources.embeddings import EmbeddingsResource, AsyncEmbeddingsResource
|
|
64
|
+
from .resources.audio.audio import AudioResource, AsyncAudioResource
|
|
65
|
+
from .resources.completions import CompletionsResource, AsyncCompletionsResource
|
|
66
|
+
from .resources.fine_tuning import FineTuningResource, AsyncFineTuningResource
|
|
67
|
+
from .resources.code_interpreter.code_interpreter import CodeInterpreterResource, AsyncCodeInterpreterResource
|
|
68
|
+
|
|
69
|
+
__all__ = [
|
|
70
|
+
"Timeout",
|
|
71
|
+
"Transport",
|
|
72
|
+
"ProxiesTypes",
|
|
73
|
+
"RequestOptions",
|
|
74
|
+
"Together",
|
|
75
|
+
"AsyncTogether",
|
|
76
|
+
"Client",
|
|
77
|
+
"AsyncClient",
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class Together(SyncAPIClient):
|
|
82
|
+
# client options
|
|
83
|
+
api_key: str
|
|
84
|
+
|
|
85
|
+
def __init__(
|
|
86
|
+
self,
|
|
87
|
+
*,
|
|
88
|
+
api_key: str | None = None,
|
|
89
|
+
base_url: str | httpx.URL | None = None,
|
|
90
|
+
timeout: float | Timeout | None | NotGiven = not_given,
|
|
91
|
+
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
92
|
+
default_headers: Mapping[str, str] | None = None,
|
|
93
|
+
default_query: Mapping[str, object] | None = None,
|
|
94
|
+
# Configure a custom httpx client.
|
|
95
|
+
# We provide a `DefaultHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
|
|
96
|
+
# See the [httpx documentation](https://www.python-httpx.org/api/#client) for more details.
|
|
97
|
+
http_client: httpx.Client | None = None,
|
|
98
|
+
# Enable or disable schema validation for data returned by the API.
|
|
99
|
+
# When enabled an error APIResponseValidationError is raised
|
|
100
|
+
# if the API responds with invalid data for the expected schema.
|
|
101
|
+
#
|
|
102
|
+
# This parameter may be removed or changed in the future.
|
|
103
|
+
# If you rely on this feature, please open a GitHub issue
|
|
104
|
+
# outlining your use-case to help us decide if it should be
|
|
105
|
+
# part of our public interface in the future.
|
|
106
|
+
_strict_response_validation: bool = False,
|
|
107
|
+
) -> None:
|
|
108
|
+
"""Construct a new synchronous Together client instance.
|
|
109
|
+
|
|
110
|
+
This automatically infers the `api_key` argument from the `TOGETHER_API_KEY` environment variable if it is not provided.
|
|
111
|
+
"""
|
|
112
|
+
if api_key is None:
|
|
113
|
+
api_key = os.environ.get("TOGETHER_API_KEY")
|
|
114
|
+
if api_key is None:
|
|
115
|
+
raise TogetherError(
|
|
116
|
+
"The api_key client option must be set either by passing api_key to the client or by setting the TOGETHER_API_KEY environment variable"
|
|
117
|
+
)
|
|
118
|
+
self.api_key = api_key
|
|
119
|
+
|
|
120
|
+
if base_url is None:
|
|
121
|
+
base_url = os.environ.get("TOGETHER_BASE_URL")
|
|
122
|
+
self._base_url_overridden = base_url is not None
|
|
123
|
+
if base_url is None:
|
|
124
|
+
base_url = f"https://api.together.xyz/v1"
|
|
125
|
+
|
|
126
|
+
super().__init__(
|
|
127
|
+
version=__version__,
|
|
128
|
+
base_url=base_url,
|
|
129
|
+
max_retries=max_retries,
|
|
130
|
+
timeout=timeout,
|
|
131
|
+
http_client=http_client,
|
|
132
|
+
custom_headers=default_headers,
|
|
133
|
+
custom_query=default_query,
|
|
134
|
+
_strict_response_validation=_strict_response_validation,
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
self._default_stream_cls = Stream
|
|
138
|
+
|
|
139
|
+
@cached_property
|
|
140
|
+
def chat(self) -> ChatResource:
|
|
141
|
+
from .resources.chat import ChatResource
|
|
142
|
+
|
|
143
|
+
return ChatResource(self)
|
|
144
|
+
|
|
145
|
+
@cached_property
|
|
146
|
+
def completions(self) -> CompletionsResource:
|
|
147
|
+
from .resources.completions import CompletionsResource
|
|
148
|
+
|
|
149
|
+
return CompletionsResource(self)
|
|
150
|
+
|
|
151
|
+
@cached_property
|
|
152
|
+
def embeddings(self) -> EmbeddingsResource:
|
|
153
|
+
from .resources.embeddings import EmbeddingsResource
|
|
154
|
+
|
|
155
|
+
return EmbeddingsResource(self)
|
|
156
|
+
|
|
157
|
+
@cached_property
|
|
158
|
+
def files(self) -> FilesResource:
|
|
159
|
+
from .resources.files import FilesResource
|
|
160
|
+
|
|
161
|
+
return FilesResource(self)
|
|
162
|
+
|
|
163
|
+
@cached_property
|
|
164
|
+
def fine_tuning(self) -> FineTuningResource:
|
|
165
|
+
from .resources.fine_tuning import FineTuningResource
|
|
166
|
+
|
|
167
|
+
return FineTuningResource(self)
|
|
168
|
+
|
|
169
|
+
@cached_property
|
|
170
|
+
def code_interpreter(self) -> CodeInterpreterResource:
|
|
171
|
+
from .resources.code_interpreter import CodeInterpreterResource
|
|
172
|
+
|
|
173
|
+
return CodeInterpreterResource(self)
|
|
174
|
+
|
|
175
|
+
@cached_property
|
|
176
|
+
def images(self) -> ImagesResource:
|
|
177
|
+
from .resources.images import ImagesResource
|
|
178
|
+
|
|
179
|
+
return ImagesResource(self)
|
|
180
|
+
|
|
181
|
+
@cached_property
|
|
182
|
+
def videos(self) -> VideosResource:
|
|
183
|
+
from .resources.videos import VideosResource
|
|
184
|
+
|
|
185
|
+
return VideosResource(self)
|
|
186
|
+
|
|
187
|
+
@cached_property
|
|
188
|
+
def audio(self) -> AudioResource:
|
|
189
|
+
from .resources.audio import AudioResource
|
|
190
|
+
|
|
191
|
+
return AudioResource(self)
|
|
192
|
+
|
|
193
|
+
@cached_property
|
|
194
|
+
def models(self) -> ModelsResource:
|
|
195
|
+
from .resources.models import ModelsResource
|
|
196
|
+
|
|
197
|
+
return ModelsResource(self)
|
|
198
|
+
|
|
199
|
+
@cached_property
|
|
200
|
+
def jobs(self) -> JobsResource:
|
|
201
|
+
from .resources.jobs import JobsResource
|
|
202
|
+
|
|
203
|
+
return JobsResource(self)
|
|
204
|
+
|
|
205
|
+
@cached_property
|
|
206
|
+
def endpoints(self) -> EndpointsResource:
|
|
207
|
+
from .resources.endpoints import EndpointsResource
|
|
208
|
+
|
|
209
|
+
return EndpointsResource(self)
|
|
210
|
+
|
|
211
|
+
@cached_property
|
|
212
|
+
def hardware(self) -> HardwareResource:
|
|
213
|
+
from .resources.hardware import HardwareResource
|
|
214
|
+
|
|
215
|
+
return HardwareResource(self)
|
|
216
|
+
|
|
217
|
+
@cached_property
|
|
218
|
+
def rerank(self) -> RerankResource:
|
|
219
|
+
from .resources.rerank import RerankResource
|
|
220
|
+
|
|
221
|
+
return RerankResource(self)
|
|
222
|
+
|
|
223
|
+
@cached_property
|
|
224
|
+
def batches(self) -> BatchesResource:
|
|
225
|
+
from .resources.batches import BatchesResource
|
|
226
|
+
|
|
227
|
+
return BatchesResource(self)
|
|
228
|
+
|
|
229
|
+
@cached_property
|
|
230
|
+
def evals(self) -> EvalsResource:
|
|
231
|
+
from .resources.evals import EvalsResource
|
|
232
|
+
|
|
233
|
+
return EvalsResource(self)
|
|
234
|
+
|
|
235
|
+
@cached_property
|
|
236
|
+
def with_raw_response(self) -> TogetherWithRawResponse:
|
|
237
|
+
return TogetherWithRawResponse(self)
|
|
238
|
+
|
|
239
|
+
@cached_property
|
|
240
|
+
def with_streaming_response(self) -> TogetherWithStreamedResponse:
|
|
241
|
+
return TogetherWithStreamedResponse(self)
|
|
242
|
+
|
|
243
|
+
@property
|
|
244
|
+
@override
|
|
245
|
+
def qs(self) -> Querystring:
|
|
246
|
+
return Querystring(array_format="comma")
|
|
247
|
+
|
|
248
|
+
@property
|
|
249
|
+
@override
|
|
250
|
+
def auth_headers(self) -> dict[str, str]:
|
|
251
|
+
api_key = self.api_key
|
|
252
|
+
return {"Authorization": f"Bearer {api_key}"}
|
|
253
|
+
|
|
254
|
+
@property
|
|
255
|
+
@override
|
|
256
|
+
def default_headers(self) -> dict[str, str | Omit]:
|
|
257
|
+
return {
|
|
258
|
+
**super().default_headers,
|
|
259
|
+
"X-Stainless-Async": "false",
|
|
260
|
+
**self._custom_headers,
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
def copy(
|
|
264
|
+
self,
|
|
265
|
+
*,
|
|
266
|
+
api_key: str | None = None,
|
|
267
|
+
base_url: str | httpx.URL | None = None,
|
|
268
|
+
timeout: float | Timeout | None | NotGiven = not_given,
|
|
269
|
+
http_client: httpx.Client | None = None,
|
|
270
|
+
max_retries: int | NotGiven = not_given,
|
|
271
|
+
default_headers: Mapping[str, str] | None = None,
|
|
272
|
+
set_default_headers: Mapping[str, str] | None = None,
|
|
273
|
+
default_query: Mapping[str, object] | None = None,
|
|
274
|
+
set_default_query: Mapping[str, object] | None = None,
|
|
275
|
+
_extra_kwargs: Mapping[str, Any] = {},
|
|
276
|
+
) -> Self:
|
|
277
|
+
"""
|
|
278
|
+
Create a new client instance re-using the same options given to the current client with optional overriding.
|
|
279
|
+
"""
|
|
280
|
+
if default_headers is not None and set_default_headers is not None:
|
|
281
|
+
raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
|
|
282
|
+
|
|
283
|
+
if default_query is not None and set_default_query is not None:
|
|
284
|
+
raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
|
|
285
|
+
|
|
286
|
+
headers = self._custom_headers
|
|
287
|
+
if default_headers is not None:
|
|
288
|
+
headers = {**headers, **default_headers}
|
|
289
|
+
elif set_default_headers is not None:
|
|
290
|
+
headers = set_default_headers
|
|
291
|
+
|
|
292
|
+
params = self._custom_query
|
|
293
|
+
if default_query is not None:
|
|
294
|
+
params = {**params, **default_query}
|
|
295
|
+
elif set_default_query is not None:
|
|
296
|
+
params = set_default_query
|
|
297
|
+
|
|
298
|
+
http_client = http_client or self._client
|
|
299
|
+
client = self.__class__(
|
|
300
|
+
api_key=api_key or self.api_key,
|
|
301
|
+
base_url=base_url or self.base_url,
|
|
302
|
+
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
|
|
303
|
+
http_client=http_client,
|
|
304
|
+
max_retries=max_retries if is_given(max_retries) else self.max_retries,
|
|
305
|
+
default_headers=headers,
|
|
306
|
+
default_query=params,
|
|
307
|
+
**_extra_kwargs,
|
|
308
|
+
)
|
|
309
|
+
client._base_url_overridden = self._base_url_overridden or base_url is not None
|
|
310
|
+
return client
|
|
311
|
+
|
|
312
|
+
# Alias for `copy` for nicer inline usage, e.g.
|
|
313
|
+
# client.with_options(timeout=10).foo.create(...)
|
|
314
|
+
with_options = copy
|
|
315
|
+
|
|
316
|
+
@override
|
|
317
|
+
def _make_status_error(
|
|
318
|
+
self,
|
|
319
|
+
err_msg: str,
|
|
320
|
+
*,
|
|
321
|
+
body: object,
|
|
322
|
+
response: httpx.Response,
|
|
323
|
+
) -> APIStatusError:
|
|
324
|
+
if response.status_code == 400:
|
|
325
|
+
return _exceptions.BadRequestError(err_msg, response=response, body=body)
|
|
326
|
+
|
|
327
|
+
if response.status_code == 401:
|
|
328
|
+
return _exceptions.AuthenticationError(err_msg, response=response, body=body)
|
|
329
|
+
|
|
330
|
+
if response.status_code == 403:
|
|
331
|
+
return _exceptions.PermissionDeniedError(err_msg, response=response, body=body)
|
|
332
|
+
|
|
333
|
+
if response.status_code == 404:
|
|
334
|
+
return _exceptions.NotFoundError(err_msg, response=response, body=body)
|
|
335
|
+
|
|
336
|
+
if response.status_code == 409:
|
|
337
|
+
return _exceptions.ConflictError(err_msg, response=response, body=body)
|
|
338
|
+
|
|
339
|
+
if response.status_code == 422:
|
|
340
|
+
return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)
|
|
341
|
+
|
|
342
|
+
if response.status_code == 429:
|
|
343
|
+
return _exceptions.RateLimitError(err_msg, response=response, body=body)
|
|
344
|
+
|
|
345
|
+
if response.status_code >= 500:
|
|
346
|
+
return _exceptions.InternalServerError(err_msg, response=response, body=body)
|
|
347
|
+
return APIStatusError(err_msg, response=response, body=body)
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
class AsyncTogether(AsyncAPIClient):
|
|
351
|
+
# client options
|
|
352
|
+
api_key: str
|
|
353
|
+
|
|
354
|
+
def __init__(
|
|
355
|
+
self,
|
|
356
|
+
*,
|
|
357
|
+
api_key: str | None = None,
|
|
358
|
+
base_url: str | httpx.URL | None = None,
|
|
359
|
+
timeout: float | Timeout | None | NotGiven = not_given,
|
|
360
|
+
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
361
|
+
default_headers: Mapping[str, str] | None = None,
|
|
362
|
+
default_query: Mapping[str, object] | None = None,
|
|
363
|
+
# Configure a custom httpx client.
|
|
364
|
+
# We provide a `DefaultAsyncHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
|
|
365
|
+
# See the [httpx documentation](https://www.python-httpx.org/api/#asyncclient) for more details.
|
|
366
|
+
http_client: httpx.AsyncClient | None = None,
|
|
367
|
+
# Enable or disable schema validation for data returned by the API.
|
|
368
|
+
# When enabled an error APIResponseValidationError is raised
|
|
369
|
+
# if the API responds with invalid data for the expected schema.
|
|
370
|
+
#
|
|
371
|
+
# This parameter may be removed or changed in the future.
|
|
372
|
+
# If you rely on this feature, please open a GitHub issue
|
|
373
|
+
# outlining your use-case to help us decide if it should be
|
|
374
|
+
# part of our public interface in the future.
|
|
375
|
+
_strict_response_validation: bool = False,
|
|
376
|
+
) -> None:
|
|
377
|
+
"""Construct a new async AsyncTogether client instance.
|
|
378
|
+
|
|
379
|
+
This automatically infers the `api_key` argument from the `TOGETHER_API_KEY` environment variable if it is not provided.
|
|
380
|
+
"""
|
|
381
|
+
if api_key is None:
|
|
382
|
+
api_key = os.environ.get("TOGETHER_API_KEY")
|
|
383
|
+
if api_key is None:
|
|
384
|
+
raise TogetherError(
|
|
385
|
+
"The api_key client option must be set either by passing api_key to the client or by setting the TOGETHER_API_KEY environment variable"
|
|
386
|
+
)
|
|
387
|
+
self.api_key = api_key
|
|
388
|
+
|
|
389
|
+
if base_url is None:
|
|
390
|
+
base_url = os.environ.get("TOGETHER_BASE_URL")
|
|
391
|
+
self._base_url_overridden = base_url is not None
|
|
392
|
+
if base_url is None:
|
|
393
|
+
base_url = f"https://api.together.xyz/v1"
|
|
394
|
+
|
|
395
|
+
super().__init__(
|
|
396
|
+
version=__version__,
|
|
397
|
+
base_url=base_url,
|
|
398
|
+
max_retries=max_retries,
|
|
399
|
+
timeout=timeout,
|
|
400
|
+
http_client=http_client,
|
|
401
|
+
custom_headers=default_headers,
|
|
402
|
+
custom_query=default_query,
|
|
403
|
+
_strict_response_validation=_strict_response_validation,
|
|
404
|
+
)
|
|
405
|
+
|
|
406
|
+
self._default_stream_cls = AsyncStream
|
|
407
|
+
|
|
408
|
+
@cached_property
|
|
409
|
+
def chat(self) -> AsyncChatResource:
|
|
410
|
+
from .resources.chat import AsyncChatResource
|
|
411
|
+
|
|
412
|
+
return AsyncChatResource(self)
|
|
413
|
+
|
|
414
|
+
@cached_property
|
|
415
|
+
def completions(self) -> AsyncCompletionsResource:
|
|
416
|
+
from .resources.completions import AsyncCompletionsResource
|
|
417
|
+
|
|
418
|
+
return AsyncCompletionsResource(self)
|
|
419
|
+
|
|
420
|
+
@cached_property
|
|
421
|
+
def embeddings(self) -> AsyncEmbeddingsResource:
|
|
422
|
+
from .resources.embeddings import AsyncEmbeddingsResource
|
|
423
|
+
|
|
424
|
+
return AsyncEmbeddingsResource(self)
|
|
425
|
+
|
|
426
|
+
@cached_property
|
|
427
|
+
def files(self) -> AsyncFilesResource:
|
|
428
|
+
from .resources.files import AsyncFilesResource
|
|
429
|
+
|
|
430
|
+
return AsyncFilesResource(self)
|
|
431
|
+
|
|
432
|
+
@cached_property
|
|
433
|
+
def fine_tuning(self) -> AsyncFineTuningResource:
|
|
434
|
+
from .resources.fine_tuning import AsyncFineTuningResource
|
|
435
|
+
|
|
436
|
+
return AsyncFineTuningResource(self)
|
|
437
|
+
|
|
438
|
+
@cached_property
|
|
439
|
+
def code_interpreter(self) -> AsyncCodeInterpreterResource:
|
|
440
|
+
from .resources.code_interpreter import AsyncCodeInterpreterResource
|
|
441
|
+
|
|
442
|
+
return AsyncCodeInterpreterResource(self)
|
|
443
|
+
|
|
444
|
+
@cached_property
|
|
445
|
+
def images(self) -> AsyncImagesResource:
|
|
446
|
+
from .resources.images import AsyncImagesResource
|
|
447
|
+
|
|
448
|
+
return AsyncImagesResource(self)
|
|
449
|
+
|
|
450
|
+
@cached_property
|
|
451
|
+
def videos(self) -> AsyncVideosResource:
|
|
452
|
+
from .resources.videos import AsyncVideosResource
|
|
453
|
+
|
|
454
|
+
return AsyncVideosResource(self)
|
|
455
|
+
|
|
456
|
+
@cached_property
|
|
457
|
+
def audio(self) -> AsyncAudioResource:
|
|
458
|
+
from .resources.audio import AsyncAudioResource
|
|
459
|
+
|
|
460
|
+
return AsyncAudioResource(self)
|
|
461
|
+
|
|
462
|
+
@cached_property
|
|
463
|
+
def models(self) -> AsyncModelsResource:
|
|
464
|
+
from .resources.models import AsyncModelsResource
|
|
465
|
+
|
|
466
|
+
return AsyncModelsResource(self)
|
|
467
|
+
|
|
468
|
+
@cached_property
|
|
469
|
+
def jobs(self) -> AsyncJobsResource:
|
|
470
|
+
from .resources.jobs import AsyncJobsResource
|
|
471
|
+
|
|
472
|
+
return AsyncJobsResource(self)
|
|
473
|
+
|
|
474
|
+
@cached_property
|
|
475
|
+
def endpoints(self) -> AsyncEndpointsResource:
|
|
476
|
+
from .resources.endpoints import AsyncEndpointsResource
|
|
477
|
+
|
|
478
|
+
return AsyncEndpointsResource(self)
|
|
479
|
+
|
|
480
|
+
@cached_property
|
|
481
|
+
def hardware(self) -> AsyncHardwareResource:
|
|
482
|
+
from .resources.hardware import AsyncHardwareResource
|
|
483
|
+
|
|
484
|
+
return AsyncHardwareResource(self)
|
|
485
|
+
|
|
486
|
+
@cached_property
|
|
487
|
+
def rerank(self) -> AsyncRerankResource:
|
|
488
|
+
from .resources.rerank import AsyncRerankResource
|
|
489
|
+
|
|
490
|
+
return AsyncRerankResource(self)
|
|
491
|
+
|
|
492
|
+
@cached_property
|
|
493
|
+
def batches(self) -> AsyncBatchesResource:
|
|
494
|
+
from .resources.batches import AsyncBatchesResource
|
|
495
|
+
|
|
496
|
+
return AsyncBatchesResource(self)
|
|
497
|
+
|
|
498
|
+
@cached_property
|
|
499
|
+
def evals(self) -> AsyncEvalsResource:
|
|
500
|
+
from .resources.evals import AsyncEvalsResource
|
|
501
|
+
|
|
502
|
+
return AsyncEvalsResource(self)
|
|
503
|
+
|
|
504
|
+
@cached_property
|
|
505
|
+
def with_raw_response(self) -> AsyncTogetherWithRawResponse:
|
|
506
|
+
return AsyncTogetherWithRawResponse(self)
|
|
507
|
+
|
|
508
|
+
@cached_property
|
|
509
|
+
def with_streaming_response(self) -> AsyncTogetherWithStreamedResponse:
|
|
510
|
+
return AsyncTogetherWithStreamedResponse(self)
|
|
511
|
+
|
|
512
|
+
@property
|
|
513
|
+
@override
|
|
514
|
+
def qs(self) -> Querystring:
|
|
515
|
+
return Querystring(array_format="comma")
|
|
516
|
+
|
|
517
|
+
@property
|
|
518
|
+
@override
|
|
519
|
+
def auth_headers(self) -> dict[str, str]:
|
|
520
|
+
api_key = self.api_key
|
|
521
|
+
return {"Authorization": f"Bearer {api_key}"}
|
|
522
|
+
|
|
523
|
+
@property
|
|
524
|
+
@override
|
|
525
|
+
def default_headers(self) -> dict[str, str | Omit]:
|
|
526
|
+
return {
|
|
527
|
+
**super().default_headers,
|
|
528
|
+
"X-Stainless-Async": f"async:{get_async_library()}",
|
|
529
|
+
**self._custom_headers,
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
def copy(
|
|
533
|
+
self,
|
|
534
|
+
*,
|
|
535
|
+
api_key: str | None = None,
|
|
536
|
+
base_url: str | httpx.URL | None = None,
|
|
537
|
+
timeout: float | Timeout | None | NotGiven = not_given,
|
|
538
|
+
http_client: httpx.AsyncClient | None = None,
|
|
539
|
+
max_retries: int | NotGiven = not_given,
|
|
540
|
+
default_headers: Mapping[str, str] | None = None,
|
|
541
|
+
set_default_headers: Mapping[str, str] | None = None,
|
|
542
|
+
default_query: Mapping[str, object] | None = None,
|
|
543
|
+
set_default_query: Mapping[str, object] | None = None,
|
|
544
|
+
_extra_kwargs: Mapping[str, Any] = {},
|
|
545
|
+
) -> Self:
|
|
546
|
+
"""
|
|
547
|
+
Create a new client instance re-using the same options given to the current client with optional overriding.
|
|
548
|
+
"""
|
|
549
|
+
if default_headers is not None and set_default_headers is not None:
|
|
550
|
+
raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
|
|
551
|
+
|
|
552
|
+
if default_query is not None and set_default_query is not None:
|
|
553
|
+
raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
|
|
554
|
+
|
|
555
|
+
headers = self._custom_headers
|
|
556
|
+
if default_headers is not None:
|
|
557
|
+
headers = {**headers, **default_headers}
|
|
558
|
+
elif set_default_headers is not None:
|
|
559
|
+
headers = set_default_headers
|
|
560
|
+
|
|
561
|
+
params = self._custom_query
|
|
562
|
+
if default_query is not None:
|
|
563
|
+
params = {**params, **default_query}
|
|
564
|
+
elif set_default_query is not None:
|
|
565
|
+
params = set_default_query
|
|
566
|
+
|
|
567
|
+
http_client = http_client or self._client
|
|
568
|
+
client = self.__class__(
|
|
569
|
+
api_key=api_key or self.api_key,
|
|
570
|
+
base_url=base_url or self.base_url,
|
|
571
|
+
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
|
|
572
|
+
http_client=http_client,
|
|
573
|
+
max_retries=max_retries if is_given(max_retries) else self.max_retries,
|
|
574
|
+
default_headers=headers,
|
|
575
|
+
default_query=params,
|
|
576
|
+
**_extra_kwargs,
|
|
577
|
+
)
|
|
578
|
+
client._base_url_overridden = self._base_url_overridden or base_url is not None
|
|
579
|
+
return client
|
|
580
|
+
|
|
581
|
+
# Alias for `copy` for nicer inline usage, e.g.
|
|
582
|
+
# client.with_options(timeout=10).foo.create(...)
|
|
583
|
+
with_options = copy
|
|
584
|
+
|
|
585
|
+
@override
|
|
586
|
+
def _make_status_error(
|
|
587
|
+
self,
|
|
588
|
+
err_msg: str,
|
|
589
|
+
*,
|
|
590
|
+
body: object,
|
|
591
|
+
response: httpx.Response,
|
|
592
|
+
) -> APIStatusError:
|
|
593
|
+
if response.status_code == 400:
|
|
594
|
+
return _exceptions.BadRequestError(err_msg, response=response, body=body)
|
|
595
|
+
|
|
596
|
+
if response.status_code == 401:
|
|
597
|
+
return _exceptions.AuthenticationError(err_msg, response=response, body=body)
|
|
598
|
+
|
|
599
|
+
if response.status_code == 403:
|
|
600
|
+
return _exceptions.PermissionDeniedError(err_msg, response=response, body=body)
|
|
601
|
+
|
|
602
|
+
if response.status_code == 404:
|
|
603
|
+
return _exceptions.NotFoundError(err_msg, response=response, body=body)
|
|
604
|
+
|
|
605
|
+
if response.status_code == 409:
|
|
606
|
+
return _exceptions.ConflictError(err_msg, response=response, body=body)
|
|
607
|
+
|
|
608
|
+
if response.status_code == 422:
|
|
609
|
+
return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)
|
|
610
|
+
|
|
611
|
+
if response.status_code == 429:
|
|
612
|
+
return _exceptions.RateLimitError(err_msg, response=response, body=body)
|
|
613
|
+
|
|
614
|
+
if response.status_code >= 500:
|
|
615
|
+
return _exceptions.InternalServerError(err_msg, response=response, body=body)
|
|
616
|
+
return APIStatusError(err_msg, response=response, body=body)
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
class TogetherWithRawResponse:
|
|
620
|
+
_client: Together
|
|
621
|
+
|
|
622
|
+
def __init__(self, client: Together) -> None:
|
|
623
|
+
self._client = client
|
|
624
|
+
|
|
625
|
+
@cached_property
|
|
626
|
+
def chat(self) -> chat.ChatResourceWithRawResponse:
|
|
627
|
+
from .resources.chat import ChatResourceWithRawResponse
|
|
628
|
+
|
|
629
|
+
return ChatResourceWithRawResponse(self._client.chat)
|
|
630
|
+
|
|
631
|
+
@cached_property
|
|
632
|
+
def completions(self) -> completions.CompletionsResourceWithRawResponse:
|
|
633
|
+
from .resources.completions import CompletionsResourceWithRawResponse
|
|
634
|
+
|
|
635
|
+
return CompletionsResourceWithRawResponse(self._client.completions)
|
|
636
|
+
|
|
637
|
+
@cached_property
|
|
638
|
+
def embeddings(self) -> embeddings.EmbeddingsResourceWithRawResponse:
|
|
639
|
+
from .resources.embeddings import EmbeddingsResourceWithRawResponse
|
|
640
|
+
|
|
641
|
+
return EmbeddingsResourceWithRawResponse(self._client.embeddings)
|
|
642
|
+
|
|
643
|
+
@cached_property
|
|
644
|
+
def files(self) -> files.FilesResourceWithRawResponse:
|
|
645
|
+
from .resources.files import FilesResourceWithRawResponse
|
|
646
|
+
|
|
647
|
+
return FilesResourceWithRawResponse(self._client.files)
|
|
648
|
+
|
|
649
|
+
@cached_property
|
|
650
|
+
def fine_tuning(self) -> fine_tuning.FineTuningResourceWithRawResponse:
|
|
651
|
+
from .resources.fine_tuning import FineTuningResourceWithRawResponse
|
|
652
|
+
|
|
653
|
+
return FineTuningResourceWithRawResponse(self._client.fine_tuning)
|
|
654
|
+
|
|
655
|
+
@cached_property
|
|
656
|
+
def code_interpreter(self) -> code_interpreter.CodeInterpreterResourceWithRawResponse:
|
|
657
|
+
from .resources.code_interpreter import CodeInterpreterResourceWithRawResponse
|
|
658
|
+
|
|
659
|
+
return CodeInterpreterResourceWithRawResponse(self._client.code_interpreter)
|
|
660
|
+
|
|
661
|
+
@cached_property
|
|
662
|
+
def images(self) -> images.ImagesResourceWithRawResponse:
|
|
663
|
+
from .resources.images import ImagesResourceWithRawResponse
|
|
664
|
+
|
|
665
|
+
return ImagesResourceWithRawResponse(self._client.images)
|
|
666
|
+
|
|
667
|
+
@cached_property
|
|
668
|
+
def videos(self) -> videos.VideosResourceWithRawResponse:
|
|
669
|
+
from .resources.videos import VideosResourceWithRawResponse
|
|
670
|
+
|
|
671
|
+
return VideosResourceWithRawResponse(self._client.videos)
|
|
672
|
+
|
|
673
|
+
@cached_property
|
|
674
|
+
def audio(self) -> audio.AudioResourceWithRawResponse:
|
|
675
|
+
from .resources.audio import AudioResourceWithRawResponse
|
|
676
|
+
|
|
677
|
+
return AudioResourceWithRawResponse(self._client.audio)
|
|
678
|
+
|
|
679
|
+
@cached_property
|
|
680
|
+
def models(self) -> models.ModelsResourceWithRawResponse:
|
|
681
|
+
from .resources.models import ModelsResourceWithRawResponse
|
|
682
|
+
|
|
683
|
+
return ModelsResourceWithRawResponse(self._client.models)
|
|
684
|
+
|
|
685
|
+
@cached_property
|
|
686
|
+
def jobs(self) -> jobs.JobsResourceWithRawResponse:
|
|
687
|
+
from .resources.jobs import JobsResourceWithRawResponse
|
|
688
|
+
|
|
689
|
+
return JobsResourceWithRawResponse(self._client.jobs)
|
|
690
|
+
|
|
691
|
+
@cached_property
|
|
692
|
+
def endpoints(self) -> endpoints.EndpointsResourceWithRawResponse:
|
|
693
|
+
from .resources.endpoints import EndpointsResourceWithRawResponse
|
|
694
|
+
|
|
695
|
+
return EndpointsResourceWithRawResponse(self._client.endpoints)
|
|
696
|
+
|
|
697
|
+
@cached_property
|
|
698
|
+
def hardware(self) -> hardware.HardwareResourceWithRawResponse:
|
|
699
|
+
from .resources.hardware import HardwareResourceWithRawResponse
|
|
700
|
+
|
|
701
|
+
return HardwareResourceWithRawResponse(self._client.hardware)
|
|
702
|
+
|
|
703
|
+
@cached_property
|
|
704
|
+
def rerank(self) -> rerank.RerankResourceWithRawResponse:
|
|
705
|
+
from .resources.rerank import RerankResourceWithRawResponse
|
|
706
|
+
|
|
707
|
+
return RerankResourceWithRawResponse(self._client.rerank)
|
|
708
|
+
|
|
709
|
+
@cached_property
|
|
710
|
+
def batches(self) -> batches.BatchesResourceWithRawResponse:
|
|
711
|
+
from .resources.batches import BatchesResourceWithRawResponse
|
|
712
|
+
|
|
713
|
+
return BatchesResourceWithRawResponse(self._client.batches)
|
|
714
|
+
|
|
715
|
+
@cached_property
|
|
716
|
+
def evals(self) -> evals.EvalsResourceWithRawResponse:
|
|
717
|
+
from .resources.evals import EvalsResourceWithRawResponse
|
|
718
|
+
|
|
719
|
+
return EvalsResourceWithRawResponse(self._client.evals)
|
|
720
|
+
|
|
721
|
+
|
|
722
|
+
class AsyncTogetherWithRawResponse:
|
|
723
|
+
_client: AsyncTogether
|
|
724
|
+
|
|
725
|
+
def __init__(self, client: AsyncTogether) -> None:
|
|
726
|
+
self._client = client
|
|
727
|
+
|
|
728
|
+
@cached_property
|
|
729
|
+
def chat(self) -> chat.AsyncChatResourceWithRawResponse:
|
|
730
|
+
from .resources.chat import AsyncChatResourceWithRawResponse
|
|
731
|
+
|
|
732
|
+
return AsyncChatResourceWithRawResponse(self._client.chat)
|
|
733
|
+
|
|
734
|
+
@cached_property
|
|
735
|
+
def completions(self) -> completions.AsyncCompletionsResourceWithRawResponse:
|
|
736
|
+
from .resources.completions import AsyncCompletionsResourceWithRawResponse
|
|
737
|
+
|
|
738
|
+
return AsyncCompletionsResourceWithRawResponse(self._client.completions)
|
|
739
|
+
|
|
740
|
+
@cached_property
|
|
741
|
+
def embeddings(self) -> embeddings.AsyncEmbeddingsResourceWithRawResponse:
|
|
742
|
+
from .resources.embeddings import AsyncEmbeddingsResourceWithRawResponse
|
|
743
|
+
|
|
744
|
+
return AsyncEmbeddingsResourceWithRawResponse(self._client.embeddings)
|
|
745
|
+
|
|
746
|
+
@cached_property
|
|
747
|
+
def files(self) -> files.AsyncFilesResourceWithRawResponse:
|
|
748
|
+
from .resources.files import AsyncFilesResourceWithRawResponse
|
|
749
|
+
|
|
750
|
+
return AsyncFilesResourceWithRawResponse(self._client.files)
|
|
751
|
+
|
|
752
|
+
@cached_property
|
|
753
|
+
def fine_tuning(self) -> fine_tuning.AsyncFineTuningResourceWithRawResponse:
|
|
754
|
+
from .resources.fine_tuning import AsyncFineTuningResourceWithRawResponse
|
|
755
|
+
|
|
756
|
+
return AsyncFineTuningResourceWithRawResponse(self._client.fine_tuning)
|
|
757
|
+
|
|
758
|
+
@cached_property
|
|
759
|
+
def code_interpreter(self) -> code_interpreter.AsyncCodeInterpreterResourceWithRawResponse:
|
|
760
|
+
from .resources.code_interpreter import AsyncCodeInterpreterResourceWithRawResponse
|
|
761
|
+
|
|
762
|
+
return AsyncCodeInterpreterResourceWithRawResponse(self._client.code_interpreter)
|
|
763
|
+
|
|
764
|
+
@cached_property
|
|
765
|
+
def images(self) -> images.AsyncImagesResourceWithRawResponse:
|
|
766
|
+
from .resources.images import AsyncImagesResourceWithRawResponse
|
|
767
|
+
|
|
768
|
+
return AsyncImagesResourceWithRawResponse(self._client.images)
|
|
769
|
+
|
|
770
|
+
@cached_property
|
|
771
|
+
def videos(self) -> videos.AsyncVideosResourceWithRawResponse:
|
|
772
|
+
from .resources.videos import AsyncVideosResourceWithRawResponse
|
|
773
|
+
|
|
774
|
+
return AsyncVideosResourceWithRawResponse(self._client.videos)
|
|
775
|
+
|
|
776
|
+
@cached_property
|
|
777
|
+
def audio(self) -> audio.AsyncAudioResourceWithRawResponse:
|
|
778
|
+
from .resources.audio import AsyncAudioResourceWithRawResponse
|
|
779
|
+
|
|
780
|
+
return AsyncAudioResourceWithRawResponse(self._client.audio)
|
|
781
|
+
|
|
782
|
+
@cached_property
|
|
783
|
+
def models(self) -> models.AsyncModelsResourceWithRawResponse:
|
|
784
|
+
from .resources.models import AsyncModelsResourceWithRawResponse
|
|
785
|
+
|
|
786
|
+
return AsyncModelsResourceWithRawResponse(self._client.models)
|
|
787
|
+
|
|
788
|
+
@cached_property
|
|
789
|
+
def jobs(self) -> jobs.AsyncJobsResourceWithRawResponse:
|
|
790
|
+
from .resources.jobs import AsyncJobsResourceWithRawResponse
|
|
791
|
+
|
|
792
|
+
return AsyncJobsResourceWithRawResponse(self._client.jobs)
|
|
793
|
+
|
|
794
|
+
@cached_property
|
|
795
|
+
def endpoints(self) -> endpoints.AsyncEndpointsResourceWithRawResponse:
|
|
796
|
+
from .resources.endpoints import AsyncEndpointsResourceWithRawResponse
|
|
797
|
+
|
|
798
|
+
return AsyncEndpointsResourceWithRawResponse(self._client.endpoints)
|
|
799
|
+
|
|
800
|
+
@cached_property
|
|
801
|
+
def hardware(self) -> hardware.AsyncHardwareResourceWithRawResponse:
|
|
802
|
+
from .resources.hardware import AsyncHardwareResourceWithRawResponse
|
|
803
|
+
|
|
804
|
+
return AsyncHardwareResourceWithRawResponse(self._client.hardware)
|
|
805
|
+
|
|
806
|
+
@cached_property
|
|
807
|
+
def rerank(self) -> rerank.AsyncRerankResourceWithRawResponse:
|
|
808
|
+
from .resources.rerank import AsyncRerankResourceWithRawResponse
|
|
809
|
+
|
|
810
|
+
return AsyncRerankResourceWithRawResponse(self._client.rerank)
|
|
811
|
+
|
|
812
|
+
@cached_property
|
|
813
|
+
def batches(self) -> batches.AsyncBatchesResourceWithRawResponse:
|
|
814
|
+
from .resources.batches import AsyncBatchesResourceWithRawResponse
|
|
815
|
+
|
|
816
|
+
return AsyncBatchesResourceWithRawResponse(self._client.batches)
|
|
817
|
+
|
|
818
|
+
@cached_property
|
|
819
|
+
def evals(self) -> evals.AsyncEvalsResourceWithRawResponse:
|
|
820
|
+
from .resources.evals import AsyncEvalsResourceWithRawResponse
|
|
821
|
+
|
|
822
|
+
return AsyncEvalsResourceWithRawResponse(self._client.evals)
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
class TogetherWithStreamedResponse:
|
|
826
|
+
_client: Together
|
|
827
|
+
|
|
828
|
+
def __init__(self, client: Together) -> None:
|
|
829
|
+
self._client = client
|
|
830
|
+
|
|
831
|
+
@cached_property
|
|
832
|
+
def chat(self) -> chat.ChatResourceWithStreamingResponse:
|
|
833
|
+
from .resources.chat import ChatResourceWithStreamingResponse
|
|
834
|
+
|
|
835
|
+
return ChatResourceWithStreamingResponse(self._client.chat)
|
|
836
|
+
|
|
837
|
+
@cached_property
|
|
838
|
+
def completions(self) -> completions.CompletionsResourceWithStreamingResponse:
|
|
839
|
+
from .resources.completions import CompletionsResourceWithStreamingResponse
|
|
840
|
+
|
|
841
|
+
return CompletionsResourceWithStreamingResponse(self._client.completions)
|
|
842
|
+
|
|
843
|
+
@cached_property
|
|
844
|
+
def embeddings(self) -> embeddings.EmbeddingsResourceWithStreamingResponse:
|
|
845
|
+
from .resources.embeddings import EmbeddingsResourceWithStreamingResponse
|
|
846
|
+
|
|
847
|
+
return EmbeddingsResourceWithStreamingResponse(self._client.embeddings)
|
|
848
|
+
|
|
849
|
+
@cached_property
|
|
850
|
+
def files(self) -> files.FilesResourceWithStreamingResponse:
|
|
851
|
+
from .resources.files import FilesResourceWithStreamingResponse
|
|
852
|
+
|
|
853
|
+
return FilesResourceWithStreamingResponse(self._client.files)
|
|
854
|
+
|
|
855
|
+
@cached_property
|
|
856
|
+
def fine_tuning(self) -> fine_tuning.FineTuningResourceWithStreamingResponse:
|
|
857
|
+
from .resources.fine_tuning import FineTuningResourceWithStreamingResponse
|
|
858
|
+
|
|
859
|
+
return FineTuningResourceWithStreamingResponse(self._client.fine_tuning)
|
|
860
|
+
|
|
861
|
+
@cached_property
|
|
862
|
+
def code_interpreter(self) -> code_interpreter.CodeInterpreterResourceWithStreamingResponse:
|
|
863
|
+
from .resources.code_interpreter import CodeInterpreterResourceWithStreamingResponse
|
|
864
|
+
|
|
865
|
+
return CodeInterpreterResourceWithStreamingResponse(self._client.code_interpreter)
|
|
866
|
+
|
|
867
|
+
@cached_property
|
|
868
|
+
def images(self) -> images.ImagesResourceWithStreamingResponse:
|
|
869
|
+
from .resources.images import ImagesResourceWithStreamingResponse
|
|
870
|
+
|
|
871
|
+
return ImagesResourceWithStreamingResponse(self._client.images)
|
|
872
|
+
|
|
873
|
+
@cached_property
|
|
874
|
+
def videos(self) -> videos.VideosResourceWithStreamingResponse:
|
|
875
|
+
from .resources.videos import VideosResourceWithStreamingResponse
|
|
876
|
+
|
|
877
|
+
return VideosResourceWithStreamingResponse(self._client.videos)
|
|
878
|
+
|
|
879
|
+
@cached_property
|
|
880
|
+
def audio(self) -> audio.AudioResourceWithStreamingResponse:
|
|
881
|
+
from .resources.audio import AudioResourceWithStreamingResponse
|
|
882
|
+
|
|
883
|
+
return AudioResourceWithStreamingResponse(self._client.audio)
|
|
884
|
+
|
|
885
|
+
@cached_property
|
|
886
|
+
def models(self) -> models.ModelsResourceWithStreamingResponse:
|
|
887
|
+
from .resources.models import ModelsResourceWithStreamingResponse
|
|
888
|
+
|
|
889
|
+
return ModelsResourceWithStreamingResponse(self._client.models)
|
|
890
|
+
|
|
891
|
+
@cached_property
|
|
892
|
+
def jobs(self) -> jobs.JobsResourceWithStreamingResponse:
|
|
893
|
+
from .resources.jobs import JobsResourceWithStreamingResponse
|
|
894
|
+
|
|
895
|
+
return JobsResourceWithStreamingResponse(self._client.jobs)
|
|
896
|
+
|
|
897
|
+
@cached_property
|
|
898
|
+
def endpoints(self) -> endpoints.EndpointsResourceWithStreamingResponse:
|
|
899
|
+
from .resources.endpoints import EndpointsResourceWithStreamingResponse
|
|
900
|
+
|
|
901
|
+
return EndpointsResourceWithStreamingResponse(self._client.endpoints)
|
|
902
|
+
|
|
903
|
+
@cached_property
|
|
904
|
+
def hardware(self) -> hardware.HardwareResourceWithStreamingResponse:
|
|
905
|
+
from .resources.hardware import HardwareResourceWithStreamingResponse
|
|
906
|
+
|
|
907
|
+
return HardwareResourceWithStreamingResponse(self._client.hardware)
|
|
908
|
+
|
|
909
|
+
@cached_property
|
|
910
|
+
def rerank(self) -> rerank.RerankResourceWithStreamingResponse:
|
|
911
|
+
from .resources.rerank import RerankResourceWithStreamingResponse
|
|
912
|
+
|
|
913
|
+
return RerankResourceWithStreamingResponse(self._client.rerank)
|
|
914
|
+
|
|
915
|
+
@cached_property
|
|
916
|
+
def batches(self) -> batches.BatchesResourceWithStreamingResponse:
|
|
917
|
+
from .resources.batches import BatchesResourceWithStreamingResponse
|
|
918
|
+
|
|
919
|
+
return BatchesResourceWithStreamingResponse(self._client.batches)
|
|
920
|
+
|
|
921
|
+
@cached_property
|
|
922
|
+
def evals(self) -> evals.EvalsResourceWithStreamingResponse:
|
|
923
|
+
from .resources.evals import EvalsResourceWithStreamingResponse
|
|
924
|
+
|
|
925
|
+
return EvalsResourceWithStreamingResponse(self._client.evals)
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
class AsyncTogetherWithStreamedResponse:
|
|
929
|
+
_client: AsyncTogether
|
|
930
|
+
|
|
931
|
+
def __init__(self, client: AsyncTogether) -> None:
|
|
932
|
+
self._client = client
|
|
933
|
+
|
|
934
|
+
@cached_property
|
|
935
|
+
def chat(self) -> chat.AsyncChatResourceWithStreamingResponse:
|
|
936
|
+
from .resources.chat import AsyncChatResourceWithStreamingResponse
|
|
937
|
+
|
|
938
|
+
return AsyncChatResourceWithStreamingResponse(self._client.chat)
|
|
939
|
+
|
|
940
|
+
@cached_property
|
|
941
|
+
def completions(self) -> completions.AsyncCompletionsResourceWithStreamingResponse:
|
|
942
|
+
from .resources.completions import AsyncCompletionsResourceWithStreamingResponse
|
|
943
|
+
|
|
944
|
+
return AsyncCompletionsResourceWithStreamingResponse(self._client.completions)
|
|
945
|
+
|
|
946
|
+
@cached_property
|
|
947
|
+
def embeddings(self) -> embeddings.AsyncEmbeddingsResourceWithStreamingResponse:
|
|
948
|
+
from .resources.embeddings import AsyncEmbeddingsResourceWithStreamingResponse
|
|
949
|
+
|
|
950
|
+
return AsyncEmbeddingsResourceWithStreamingResponse(self._client.embeddings)
|
|
951
|
+
|
|
952
|
+
@cached_property
|
|
953
|
+
def files(self) -> files.AsyncFilesResourceWithStreamingResponse:
|
|
954
|
+
from .resources.files import AsyncFilesResourceWithStreamingResponse
|
|
955
|
+
|
|
956
|
+
return AsyncFilesResourceWithStreamingResponse(self._client.files)
|
|
957
|
+
|
|
958
|
+
@cached_property
|
|
959
|
+
def fine_tuning(self) -> fine_tuning.AsyncFineTuningResourceWithStreamingResponse:
|
|
960
|
+
from .resources.fine_tuning import AsyncFineTuningResourceWithStreamingResponse
|
|
961
|
+
|
|
962
|
+
return AsyncFineTuningResourceWithStreamingResponse(self._client.fine_tuning)
|
|
963
|
+
|
|
964
|
+
@cached_property
|
|
965
|
+
def code_interpreter(self) -> code_interpreter.AsyncCodeInterpreterResourceWithStreamingResponse:
|
|
966
|
+
from .resources.code_interpreter import AsyncCodeInterpreterResourceWithStreamingResponse
|
|
967
|
+
|
|
968
|
+
return AsyncCodeInterpreterResourceWithStreamingResponse(self._client.code_interpreter)
|
|
969
|
+
|
|
970
|
+
@cached_property
|
|
971
|
+
def images(self) -> images.AsyncImagesResourceWithStreamingResponse:
|
|
972
|
+
from .resources.images import AsyncImagesResourceWithStreamingResponse
|
|
973
|
+
|
|
974
|
+
return AsyncImagesResourceWithStreamingResponse(self._client.images)
|
|
975
|
+
|
|
976
|
+
@cached_property
|
|
977
|
+
def videos(self) -> videos.AsyncVideosResourceWithStreamingResponse:
|
|
978
|
+
from .resources.videos import AsyncVideosResourceWithStreamingResponse
|
|
979
|
+
|
|
980
|
+
return AsyncVideosResourceWithStreamingResponse(self._client.videos)
|
|
981
|
+
|
|
982
|
+
@cached_property
|
|
983
|
+
def audio(self) -> audio.AsyncAudioResourceWithStreamingResponse:
|
|
984
|
+
from .resources.audio import AsyncAudioResourceWithStreamingResponse
|
|
985
|
+
|
|
986
|
+
return AsyncAudioResourceWithStreamingResponse(self._client.audio)
|
|
987
|
+
|
|
988
|
+
@cached_property
|
|
989
|
+
def models(self) -> models.AsyncModelsResourceWithStreamingResponse:
|
|
990
|
+
from .resources.models import AsyncModelsResourceWithStreamingResponse
|
|
991
|
+
|
|
992
|
+
return AsyncModelsResourceWithStreamingResponse(self._client.models)
|
|
993
|
+
|
|
994
|
+
@cached_property
|
|
995
|
+
def jobs(self) -> jobs.AsyncJobsResourceWithStreamingResponse:
|
|
996
|
+
from .resources.jobs import AsyncJobsResourceWithStreamingResponse
|
|
997
|
+
|
|
998
|
+
return AsyncJobsResourceWithStreamingResponse(self._client.jobs)
|
|
999
|
+
|
|
1000
|
+
@cached_property
|
|
1001
|
+
def endpoints(self) -> endpoints.AsyncEndpointsResourceWithStreamingResponse:
|
|
1002
|
+
from .resources.endpoints import AsyncEndpointsResourceWithStreamingResponse
|
|
1003
|
+
|
|
1004
|
+
return AsyncEndpointsResourceWithStreamingResponse(self._client.endpoints)
|
|
1005
|
+
|
|
1006
|
+
@cached_property
|
|
1007
|
+
def hardware(self) -> hardware.AsyncHardwareResourceWithStreamingResponse:
|
|
1008
|
+
from .resources.hardware import AsyncHardwareResourceWithStreamingResponse
|
|
1009
|
+
|
|
1010
|
+
return AsyncHardwareResourceWithStreamingResponse(self._client.hardware)
|
|
1011
|
+
|
|
1012
|
+
@cached_property
|
|
1013
|
+
def rerank(self) -> rerank.AsyncRerankResourceWithStreamingResponse:
|
|
1014
|
+
from .resources.rerank import AsyncRerankResourceWithStreamingResponse
|
|
1015
|
+
|
|
1016
|
+
return AsyncRerankResourceWithStreamingResponse(self._client.rerank)
|
|
1017
|
+
|
|
1018
|
+
@cached_property
|
|
1019
|
+
def batches(self) -> batches.AsyncBatchesResourceWithStreamingResponse:
|
|
1020
|
+
from .resources.batches import AsyncBatchesResourceWithStreamingResponse
|
|
1021
|
+
|
|
1022
|
+
return AsyncBatchesResourceWithStreamingResponse(self._client.batches)
|
|
1023
|
+
|
|
1024
|
+
@cached_property
|
|
1025
|
+
def evals(self) -> evals.AsyncEvalsResourceWithStreamingResponse:
|
|
1026
|
+
from .resources.evals import AsyncEvalsResourceWithStreamingResponse
|
|
1027
|
+
|
|
1028
|
+
return AsyncEvalsResourceWithStreamingResponse(self._client.evals)
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
Client = Together
|
|
1032
|
+
|
|
1033
|
+
AsyncClient = AsyncTogether
|