scale-gp-beta 0.1.0a2__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.
Files changed (78) hide show
  1. scale_gp/__init__.py +96 -0
  2. scale_gp/_base_client.py +2058 -0
  3. scale_gp/_client.py +544 -0
  4. scale_gp/_compat.py +219 -0
  5. scale_gp/_constants.py +14 -0
  6. scale_gp/_exceptions.py +108 -0
  7. scale_gp/_files.py +123 -0
  8. scale_gp/_models.py +801 -0
  9. scale_gp/_qs.py +150 -0
  10. scale_gp/_resource.py +43 -0
  11. scale_gp/_response.py +830 -0
  12. scale_gp/_streaming.py +333 -0
  13. scale_gp/_types.py +217 -0
  14. scale_gp/_utils/__init__.py +57 -0
  15. scale_gp/_utils/_logs.py +25 -0
  16. scale_gp/_utils/_proxy.py +62 -0
  17. scale_gp/_utils/_reflection.py +42 -0
  18. scale_gp/_utils/_streams.py +12 -0
  19. scale_gp/_utils/_sync.py +86 -0
  20. scale_gp/_utils/_transform.py +402 -0
  21. scale_gp/_utils/_typing.py +149 -0
  22. scale_gp/_utils/_utils.py +414 -0
  23. scale_gp/_version.py +4 -0
  24. scale_gp/lib/.keep +4 -0
  25. scale_gp/pagination.py +83 -0
  26. scale_gp/py.typed +0 -0
  27. scale_gp/resources/__init__.py +103 -0
  28. scale_gp/resources/chat/__init__.py +33 -0
  29. scale_gp/resources/chat/chat.py +102 -0
  30. scale_gp/resources/chat/completions.py +1054 -0
  31. scale_gp/resources/completions.py +765 -0
  32. scale_gp/resources/files/__init__.py +33 -0
  33. scale_gp/resources/files/content.py +162 -0
  34. scale_gp/resources/files/files.py +558 -0
  35. scale_gp/resources/inference.py +210 -0
  36. scale_gp/resources/models.py +834 -0
  37. scale_gp/resources/question_sets.py +680 -0
  38. scale_gp/resources/questions.py +396 -0
  39. scale_gp/types/__init__.py +33 -0
  40. scale_gp/types/chat/__init__.py +8 -0
  41. scale_gp/types/chat/chat_completion.py +257 -0
  42. scale_gp/types/chat/chat_completion_chunk.py +240 -0
  43. scale_gp/types/chat/completion_create_params.py +156 -0
  44. scale_gp/types/chat/completion_create_response.py +11 -0
  45. scale_gp/types/completion.py +116 -0
  46. scale_gp/types/completion_create_params.py +108 -0
  47. scale_gp/types/file.py +30 -0
  48. scale_gp/types/file_create_params.py +13 -0
  49. scale_gp/types/file_delete_response.py +16 -0
  50. scale_gp/types/file_list.py +27 -0
  51. scale_gp/types/file_list_params.py +16 -0
  52. scale_gp/types/file_update_params.py +12 -0
  53. scale_gp/types/files/__init__.py +3 -0
  54. scale_gp/types/inference_create_params.py +25 -0
  55. scale_gp/types/inference_create_response.py +11 -0
  56. scale_gp/types/inference_model.py +167 -0
  57. scale_gp/types/inference_model_list.py +27 -0
  58. scale_gp/types/inference_response.py +14 -0
  59. scale_gp/types/inference_response_chunk.py +14 -0
  60. scale_gp/types/model_create_params.py +165 -0
  61. scale_gp/types/model_delete_response.py +16 -0
  62. scale_gp/types/model_list_params.py +20 -0
  63. scale_gp/types/model_update_params.py +161 -0
  64. scale_gp/types/question.py +68 -0
  65. scale_gp/types/question_create_params.py +59 -0
  66. scale_gp/types/question_list.py +27 -0
  67. scale_gp/types/question_list_params.py +16 -0
  68. scale_gp/types/question_set.py +106 -0
  69. scale_gp/types/question_set_create_params.py +115 -0
  70. scale_gp/types/question_set_delete_response.py +16 -0
  71. scale_gp/types/question_set_list.py +27 -0
  72. scale_gp/types/question_set_list_params.py +20 -0
  73. scale_gp/types/question_set_retrieve_params.py +12 -0
  74. scale_gp/types/question_set_update_params.py +23 -0
  75. scale_gp_beta-0.1.0a2.dist-info/METADATA +440 -0
  76. scale_gp_beta-0.1.0a2.dist-info/RECORD +78 -0
  77. scale_gp_beta-0.1.0a2.dist-info/WHEEL +4 -0
  78. scale_gp_beta-0.1.0a2.dist-info/licenses/LICENSE +201 -0
scale_gp/_client.py ADDED
@@ -0,0 +1,544 @@
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 Any, Dict, Union, Mapping, cast
7
+ from typing_extensions import Self, Literal, override
8
+
9
+ import httpx
10
+
11
+ from . import _exceptions
12
+ from ._qs import Querystring
13
+ from ._types import (
14
+ NOT_GIVEN,
15
+ Omit,
16
+ Timeout,
17
+ NotGiven,
18
+ Transport,
19
+ ProxiesTypes,
20
+ RequestOptions,
21
+ )
22
+ from ._utils import (
23
+ is_given,
24
+ get_async_library,
25
+ )
26
+ from ._version import __version__
27
+ from .resources import models, inference, questions, completions, question_sets
28
+ from ._streaming import Stream as Stream, AsyncStream as AsyncStream
29
+ from ._exceptions import APIStatusError, SGPClientError
30
+ from ._base_client import (
31
+ DEFAULT_MAX_RETRIES,
32
+ SyncAPIClient,
33
+ AsyncAPIClient,
34
+ )
35
+ from .resources.chat import chat
36
+ from .resources.files import files
37
+
38
+ __all__ = [
39
+ "ENVIRONMENTS",
40
+ "Timeout",
41
+ "Transport",
42
+ "ProxiesTypes",
43
+ "RequestOptions",
44
+ "SGPClient",
45
+ "AsyncSGPClient",
46
+ "Client",
47
+ "AsyncClient",
48
+ ]
49
+
50
+ ENVIRONMENTS: Dict[str, str] = {
51
+ "production": "https://api.egp.scale.com",
52
+ "development": "http://127.0.0.1:5003/public",
53
+ }
54
+
55
+
56
+ class SGPClient(SyncAPIClient):
57
+ completions: completions.CompletionsResource
58
+ chat: chat.ChatResource
59
+ inference: inference.InferenceResource
60
+ questions: questions.QuestionsResource
61
+ question_sets: question_sets.QuestionSetsResource
62
+ files: files.FilesResource
63
+ models: models.ModelsResource
64
+ with_raw_response: SGPClientWithRawResponse
65
+ with_streaming_response: SGPClientWithStreamedResponse
66
+
67
+ # client options
68
+ api_key: str
69
+ account_id: str
70
+
71
+ _environment: Literal["production", "development"] | NotGiven
72
+
73
+ def __init__(
74
+ self,
75
+ *,
76
+ api_key: str | None = None,
77
+ account_id: str | None = None,
78
+ environment: Literal["production", "development"] | NotGiven = NOT_GIVEN,
79
+ base_url: str | httpx.URL | None | NotGiven = NOT_GIVEN,
80
+ timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
81
+ max_retries: int = DEFAULT_MAX_RETRIES,
82
+ default_headers: Mapping[str, str] | None = None,
83
+ default_query: Mapping[str, object] | None = None,
84
+ # Configure a custom httpx client.
85
+ # We provide a `DefaultHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
86
+ # See the [httpx documentation](https://www.python-httpx.org/api/#client) for more details.
87
+ http_client: httpx.Client | None = None,
88
+ # Enable or disable schema validation for data returned by the API.
89
+ # When enabled an error APIResponseValidationError is raised
90
+ # if the API responds with invalid data for the expected schema.
91
+ #
92
+ # This parameter may be removed or changed in the future.
93
+ # If you rely on this feature, please open a GitHub issue
94
+ # outlining your use-case to help us decide if it should be
95
+ # part of our public interface in the future.
96
+ _strict_response_validation: bool = False,
97
+ ) -> None:
98
+ """Construct a new synchronous SGPClient client instance.
99
+
100
+ This automatically infers the following arguments from their corresponding environment variables if they are not provided:
101
+ - `api_key` from `SGP_API_KEY`
102
+ - `account_id` from `SGP_ACCOUNT_ID`
103
+ """
104
+ if api_key is None:
105
+ api_key = os.environ.get("SGP_API_KEY")
106
+ if api_key is None:
107
+ raise SGPClientError(
108
+ "The api_key client option must be set either by passing api_key to the client or by setting the SGP_API_KEY environment variable"
109
+ )
110
+ self.api_key = api_key
111
+
112
+ if account_id is None:
113
+ account_id = os.environ.get("SGP_ACCOUNT_ID")
114
+ if account_id is None:
115
+ raise SGPClientError(
116
+ "The account_id client option must be set either by passing account_id to the client or by setting the SGP_ACCOUNT_ID environment variable"
117
+ )
118
+ self.account_id = account_id
119
+
120
+ self._environment = environment
121
+
122
+ base_url_env = os.environ.get("SGP_CLIENT_BASE_URL")
123
+ if is_given(base_url) and base_url is not None:
124
+ # cast required because mypy doesn't understand the type narrowing
125
+ base_url = cast("str | httpx.URL", base_url) # pyright: ignore[reportUnnecessaryCast]
126
+ elif is_given(environment):
127
+ if base_url_env and base_url is not None:
128
+ raise ValueError(
129
+ "Ambiguous URL; The `SGP_CLIENT_BASE_URL` env var and the `environment` argument are given. If you want to use the environment, you must pass base_url=None",
130
+ )
131
+
132
+ try:
133
+ base_url = ENVIRONMENTS[environment]
134
+ except KeyError as exc:
135
+ raise ValueError(f"Unknown environment: {environment}") from exc
136
+ elif base_url_env is not None:
137
+ base_url = base_url_env
138
+ else:
139
+ self._environment = environment = "production"
140
+
141
+ try:
142
+ base_url = ENVIRONMENTS[environment]
143
+ except KeyError as exc:
144
+ raise ValueError(f"Unknown environment: {environment}") from exc
145
+
146
+ super().__init__(
147
+ version=__version__,
148
+ base_url=base_url,
149
+ max_retries=max_retries,
150
+ timeout=timeout,
151
+ http_client=http_client,
152
+ custom_headers=default_headers,
153
+ custom_query=default_query,
154
+ _strict_response_validation=_strict_response_validation,
155
+ )
156
+
157
+ self.completions = completions.CompletionsResource(self)
158
+ self.chat = chat.ChatResource(self)
159
+ self.inference = inference.InferenceResource(self)
160
+ self.questions = questions.QuestionsResource(self)
161
+ self.question_sets = question_sets.QuestionSetsResource(self)
162
+ self.files = files.FilesResource(self)
163
+ self.models = models.ModelsResource(self)
164
+ self.with_raw_response = SGPClientWithRawResponse(self)
165
+ self.with_streaming_response = SGPClientWithStreamedResponse(self)
166
+
167
+ @property
168
+ @override
169
+ def qs(self) -> Querystring:
170
+ return Querystring(array_format="comma")
171
+
172
+ @property
173
+ @override
174
+ def auth_headers(self) -> dict[str, str]:
175
+ api_key = self.api_key
176
+ return {"x-api-key": api_key}
177
+
178
+ @property
179
+ @override
180
+ def default_headers(self) -> dict[str, str | Omit]:
181
+ return {
182
+ **super().default_headers,
183
+ "X-Stainless-Async": "false",
184
+ "x-selected-account-id": self.account_id,
185
+ **self._custom_headers,
186
+ }
187
+
188
+ def copy(
189
+ self,
190
+ *,
191
+ api_key: str | None = None,
192
+ account_id: str | None = None,
193
+ environment: Literal["production", "development"] | None = None,
194
+ base_url: str | httpx.URL | None = None,
195
+ timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
196
+ http_client: httpx.Client | None = None,
197
+ max_retries: int | NotGiven = NOT_GIVEN,
198
+ default_headers: Mapping[str, str] | None = None,
199
+ set_default_headers: Mapping[str, str] | None = None,
200
+ default_query: Mapping[str, object] | None = None,
201
+ set_default_query: Mapping[str, object] | None = None,
202
+ _extra_kwargs: Mapping[str, Any] = {},
203
+ ) -> Self:
204
+ """
205
+ Create a new client instance re-using the same options given to the current client with optional overriding.
206
+ """
207
+ if default_headers is not None and set_default_headers is not None:
208
+ raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
209
+
210
+ if default_query is not None and set_default_query is not None:
211
+ raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
212
+
213
+ headers = self._custom_headers
214
+ if default_headers is not None:
215
+ headers = {**headers, **default_headers}
216
+ elif set_default_headers is not None:
217
+ headers = set_default_headers
218
+
219
+ params = self._custom_query
220
+ if default_query is not None:
221
+ params = {**params, **default_query}
222
+ elif set_default_query is not None:
223
+ params = set_default_query
224
+
225
+ http_client = http_client or self._client
226
+ return self.__class__(
227
+ api_key=api_key or self.api_key,
228
+ account_id=account_id or self.account_id,
229
+ base_url=base_url or self.base_url,
230
+ environment=environment or self._environment,
231
+ timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
232
+ http_client=http_client,
233
+ max_retries=max_retries if is_given(max_retries) else self.max_retries,
234
+ default_headers=headers,
235
+ default_query=params,
236
+ **_extra_kwargs,
237
+ )
238
+
239
+ # Alias for `copy` for nicer inline usage, e.g.
240
+ # client.with_options(timeout=10).foo.create(...)
241
+ with_options = copy
242
+
243
+ @override
244
+ def _make_status_error(
245
+ self,
246
+ err_msg: str,
247
+ *,
248
+ body: object,
249
+ response: httpx.Response,
250
+ ) -> APIStatusError:
251
+ if response.status_code == 400:
252
+ return _exceptions.BadRequestError(err_msg, response=response, body=body)
253
+
254
+ if response.status_code == 401:
255
+ return _exceptions.AuthenticationError(err_msg, response=response, body=body)
256
+
257
+ if response.status_code == 403:
258
+ return _exceptions.PermissionDeniedError(err_msg, response=response, body=body)
259
+
260
+ if response.status_code == 404:
261
+ return _exceptions.NotFoundError(err_msg, response=response, body=body)
262
+
263
+ if response.status_code == 409:
264
+ return _exceptions.ConflictError(err_msg, response=response, body=body)
265
+
266
+ if response.status_code == 422:
267
+ return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)
268
+
269
+ if response.status_code == 429:
270
+ return _exceptions.RateLimitError(err_msg, response=response, body=body)
271
+
272
+ if response.status_code >= 500:
273
+ return _exceptions.InternalServerError(err_msg, response=response, body=body)
274
+ return APIStatusError(err_msg, response=response, body=body)
275
+
276
+
277
+ class AsyncSGPClient(AsyncAPIClient):
278
+ completions: completions.AsyncCompletionsResource
279
+ chat: chat.AsyncChatResource
280
+ inference: inference.AsyncInferenceResource
281
+ questions: questions.AsyncQuestionsResource
282
+ question_sets: question_sets.AsyncQuestionSetsResource
283
+ files: files.AsyncFilesResource
284
+ models: models.AsyncModelsResource
285
+ with_raw_response: AsyncSGPClientWithRawResponse
286
+ with_streaming_response: AsyncSGPClientWithStreamedResponse
287
+
288
+ # client options
289
+ api_key: str
290
+ account_id: str
291
+
292
+ _environment: Literal["production", "development"] | NotGiven
293
+
294
+ def __init__(
295
+ self,
296
+ *,
297
+ api_key: str | None = None,
298
+ account_id: str | None = None,
299
+ environment: Literal["production", "development"] | NotGiven = NOT_GIVEN,
300
+ base_url: str | httpx.URL | None | NotGiven = NOT_GIVEN,
301
+ timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
302
+ max_retries: int = DEFAULT_MAX_RETRIES,
303
+ default_headers: Mapping[str, str] | None = None,
304
+ default_query: Mapping[str, object] | None = None,
305
+ # Configure a custom httpx client.
306
+ # We provide a `DefaultAsyncHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
307
+ # See the [httpx documentation](https://www.python-httpx.org/api/#asyncclient) for more details.
308
+ http_client: httpx.AsyncClient | None = None,
309
+ # Enable or disable schema validation for data returned by the API.
310
+ # When enabled an error APIResponseValidationError is raised
311
+ # if the API responds with invalid data for the expected schema.
312
+ #
313
+ # This parameter may be removed or changed in the future.
314
+ # If you rely on this feature, please open a GitHub issue
315
+ # outlining your use-case to help us decide if it should be
316
+ # part of our public interface in the future.
317
+ _strict_response_validation: bool = False,
318
+ ) -> None:
319
+ """Construct a new async SGPClient client instance.
320
+
321
+ This automatically infers the following arguments from their corresponding environment variables if they are not provided:
322
+ - `api_key` from `SGP_API_KEY`
323
+ - `account_id` from `SGP_ACCOUNT_ID`
324
+ """
325
+ if api_key is None:
326
+ api_key = os.environ.get("SGP_API_KEY")
327
+ if api_key is None:
328
+ raise SGPClientError(
329
+ "The api_key client option must be set either by passing api_key to the client or by setting the SGP_API_KEY environment variable"
330
+ )
331
+ self.api_key = api_key
332
+
333
+ if account_id is None:
334
+ account_id = os.environ.get("SGP_ACCOUNT_ID")
335
+ if account_id is None:
336
+ raise SGPClientError(
337
+ "The account_id client option must be set either by passing account_id to the client or by setting the SGP_ACCOUNT_ID environment variable"
338
+ )
339
+ self.account_id = account_id
340
+
341
+ self._environment = environment
342
+
343
+ base_url_env = os.environ.get("SGP_CLIENT_BASE_URL")
344
+ if is_given(base_url) and base_url is not None:
345
+ # cast required because mypy doesn't understand the type narrowing
346
+ base_url = cast("str | httpx.URL", base_url) # pyright: ignore[reportUnnecessaryCast]
347
+ elif is_given(environment):
348
+ if base_url_env and base_url is not None:
349
+ raise ValueError(
350
+ "Ambiguous URL; The `SGP_CLIENT_BASE_URL` env var and the `environment` argument are given. If you want to use the environment, you must pass base_url=None",
351
+ )
352
+
353
+ try:
354
+ base_url = ENVIRONMENTS[environment]
355
+ except KeyError as exc:
356
+ raise ValueError(f"Unknown environment: {environment}") from exc
357
+ elif base_url_env is not None:
358
+ base_url = base_url_env
359
+ else:
360
+ self._environment = environment = "production"
361
+
362
+ try:
363
+ base_url = ENVIRONMENTS[environment]
364
+ except KeyError as exc:
365
+ raise ValueError(f"Unknown environment: {environment}") from exc
366
+
367
+ super().__init__(
368
+ version=__version__,
369
+ base_url=base_url,
370
+ max_retries=max_retries,
371
+ timeout=timeout,
372
+ http_client=http_client,
373
+ custom_headers=default_headers,
374
+ custom_query=default_query,
375
+ _strict_response_validation=_strict_response_validation,
376
+ )
377
+
378
+ self.completions = completions.AsyncCompletionsResource(self)
379
+ self.chat = chat.AsyncChatResource(self)
380
+ self.inference = inference.AsyncInferenceResource(self)
381
+ self.questions = questions.AsyncQuestionsResource(self)
382
+ self.question_sets = question_sets.AsyncQuestionSetsResource(self)
383
+ self.files = files.AsyncFilesResource(self)
384
+ self.models = models.AsyncModelsResource(self)
385
+ self.with_raw_response = AsyncSGPClientWithRawResponse(self)
386
+ self.with_streaming_response = AsyncSGPClientWithStreamedResponse(self)
387
+
388
+ @property
389
+ @override
390
+ def qs(self) -> Querystring:
391
+ return Querystring(array_format="comma")
392
+
393
+ @property
394
+ @override
395
+ def auth_headers(self) -> dict[str, str]:
396
+ api_key = self.api_key
397
+ return {"x-api-key": api_key}
398
+
399
+ @property
400
+ @override
401
+ def default_headers(self) -> dict[str, str | Omit]:
402
+ return {
403
+ **super().default_headers,
404
+ "X-Stainless-Async": f"async:{get_async_library()}",
405
+ "x-selected-account-id": self.account_id,
406
+ **self._custom_headers,
407
+ }
408
+
409
+ def copy(
410
+ self,
411
+ *,
412
+ api_key: str | None = None,
413
+ account_id: str | None = None,
414
+ environment: Literal["production", "development"] | None = None,
415
+ base_url: str | httpx.URL | None = None,
416
+ timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
417
+ http_client: httpx.AsyncClient | None = None,
418
+ max_retries: int | NotGiven = NOT_GIVEN,
419
+ default_headers: Mapping[str, str] | None = None,
420
+ set_default_headers: Mapping[str, str] | None = None,
421
+ default_query: Mapping[str, object] | None = None,
422
+ set_default_query: Mapping[str, object] | None = None,
423
+ _extra_kwargs: Mapping[str, Any] = {},
424
+ ) -> Self:
425
+ """
426
+ Create a new client instance re-using the same options given to the current client with optional overriding.
427
+ """
428
+ if default_headers is not None and set_default_headers is not None:
429
+ raise ValueError("The `default_headers` and `set_default_headers` arguments are mutually exclusive")
430
+
431
+ if default_query is not None and set_default_query is not None:
432
+ raise ValueError("The `default_query` and `set_default_query` arguments are mutually exclusive")
433
+
434
+ headers = self._custom_headers
435
+ if default_headers is not None:
436
+ headers = {**headers, **default_headers}
437
+ elif set_default_headers is not None:
438
+ headers = set_default_headers
439
+
440
+ params = self._custom_query
441
+ if default_query is not None:
442
+ params = {**params, **default_query}
443
+ elif set_default_query is not None:
444
+ params = set_default_query
445
+
446
+ http_client = http_client or self._client
447
+ return self.__class__(
448
+ api_key=api_key or self.api_key,
449
+ account_id=account_id or self.account_id,
450
+ base_url=base_url or self.base_url,
451
+ environment=environment or self._environment,
452
+ timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
453
+ http_client=http_client,
454
+ max_retries=max_retries if is_given(max_retries) else self.max_retries,
455
+ default_headers=headers,
456
+ default_query=params,
457
+ **_extra_kwargs,
458
+ )
459
+
460
+ # Alias for `copy` for nicer inline usage, e.g.
461
+ # client.with_options(timeout=10).foo.create(...)
462
+ with_options = copy
463
+
464
+ @override
465
+ def _make_status_error(
466
+ self,
467
+ err_msg: str,
468
+ *,
469
+ body: object,
470
+ response: httpx.Response,
471
+ ) -> APIStatusError:
472
+ if response.status_code == 400:
473
+ return _exceptions.BadRequestError(err_msg, response=response, body=body)
474
+
475
+ if response.status_code == 401:
476
+ return _exceptions.AuthenticationError(err_msg, response=response, body=body)
477
+
478
+ if response.status_code == 403:
479
+ return _exceptions.PermissionDeniedError(err_msg, response=response, body=body)
480
+
481
+ if response.status_code == 404:
482
+ return _exceptions.NotFoundError(err_msg, response=response, body=body)
483
+
484
+ if response.status_code == 409:
485
+ return _exceptions.ConflictError(err_msg, response=response, body=body)
486
+
487
+ if response.status_code == 422:
488
+ return _exceptions.UnprocessableEntityError(err_msg, response=response, body=body)
489
+
490
+ if response.status_code == 429:
491
+ return _exceptions.RateLimitError(err_msg, response=response, body=body)
492
+
493
+ if response.status_code >= 500:
494
+ return _exceptions.InternalServerError(err_msg, response=response, body=body)
495
+ return APIStatusError(err_msg, response=response, body=body)
496
+
497
+
498
+ class SGPClientWithRawResponse:
499
+ def __init__(self, client: SGPClient) -> None:
500
+ self.completions = completions.CompletionsResourceWithRawResponse(client.completions)
501
+ self.chat = chat.ChatResourceWithRawResponse(client.chat)
502
+ self.inference = inference.InferenceResourceWithRawResponse(client.inference)
503
+ self.questions = questions.QuestionsResourceWithRawResponse(client.questions)
504
+ self.question_sets = question_sets.QuestionSetsResourceWithRawResponse(client.question_sets)
505
+ self.files = files.FilesResourceWithRawResponse(client.files)
506
+ self.models = models.ModelsResourceWithRawResponse(client.models)
507
+
508
+
509
+ class AsyncSGPClientWithRawResponse:
510
+ def __init__(self, client: AsyncSGPClient) -> None:
511
+ self.completions = completions.AsyncCompletionsResourceWithRawResponse(client.completions)
512
+ self.chat = chat.AsyncChatResourceWithRawResponse(client.chat)
513
+ self.inference = inference.AsyncInferenceResourceWithRawResponse(client.inference)
514
+ self.questions = questions.AsyncQuestionsResourceWithRawResponse(client.questions)
515
+ self.question_sets = question_sets.AsyncQuestionSetsResourceWithRawResponse(client.question_sets)
516
+ self.files = files.AsyncFilesResourceWithRawResponse(client.files)
517
+ self.models = models.AsyncModelsResourceWithRawResponse(client.models)
518
+
519
+
520
+ class SGPClientWithStreamedResponse:
521
+ def __init__(self, client: SGPClient) -> None:
522
+ self.completions = completions.CompletionsResourceWithStreamingResponse(client.completions)
523
+ self.chat = chat.ChatResourceWithStreamingResponse(client.chat)
524
+ self.inference = inference.InferenceResourceWithStreamingResponse(client.inference)
525
+ self.questions = questions.QuestionsResourceWithStreamingResponse(client.questions)
526
+ self.question_sets = question_sets.QuestionSetsResourceWithStreamingResponse(client.question_sets)
527
+ self.files = files.FilesResourceWithStreamingResponse(client.files)
528
+ self.models = models.ModelsResourceWithStreamingResponse(client.models)
529
+
530
+
531
+ class AsyncSGPClientWithStreamedResponse:
532
+ def __init__(self, client: AsyncSGPClient) -> None:
533
+ self.completions = completions.AsyncCompletionsResourceWithStreamingResponse(client.completions)
534
+ self.chat = chat.AsyncChatResourceWithStreamingResponse(client.chat)
535
+ self.inference = inference.AsyncInferenceResourceWithStreamingResponse(client.inference)
536
+ self.questions = questions.AsyncQuestionsResourceWithStreamingResponse(client.questions)
537
+ self.question_sets = question_sets.AsyncQuestionSetsResourceWithStreamingResponse(client.question_sets)
538
+ self.files = files.AsyncFilesResourceWithStreamingResponse(client.files)
539
+ self.models = models.AsyncModelsResourceWithStreamingResponse(client.models)
540
+
541
+
542
+ Client = SGPClient
543
+
544
+ AsyncClient = AsyncSGPClient