scale-gp-beta 0.1.0a2__py3-none-any.whl → 0.1.0a4__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.
- {scale_gp → scale_gp_beta}/__init__.py +2 -2
- {scale_gp → scale_gp_beta}/_base_client.py +10 -99
- {scale_gp → scale_gp_beta}/_client.py +1 -1
- {scale_gp → scale_gp_beta}/_files.py +1 -1
- {scale_gp → scale_gp_beta}/_models.py +5 -2
- {scale_gp → scale_gp_beta}/_response.py +6 -4
- {scale_gp → scale_gp_beta}/_types.py +1 -1
- {scale_gp → scale_gp_beta}/_utils/_logs.py +2 -2
- {scale_gp → scale_gp_beta}/_version.py +2 -2
- {scale_gp → scale_gp_beta}/resources/chat/completions.py +86 -92
- {scale_gp → scale_gp_beta}/resources/models.py +26 -2
- {scale_gp → scale_gp_beta}/types/inference_model.py +18 -4
- {scale_gp → scale_gp_beta}/types/model_list_params.py +15 -1
- {scale_gp_beta-0.1.0a2.dist-info → scale_gp_beta-0.1.0a4.dist-info}/METADATA +144 -30
- scale_gp_beta-0.1.0a4.dist-info/RECORD +78 -0
- {scale_gp_beta-0.1.0a2.dist-info → scale_gp_beta-0.1.0a4.dist-info}/WHEEL +1 -1
- {scale_gp_beta-0.1.0a2.dist-info → scale_gp_beta-0.1.0a4.dist-info}/licenses/LICENSE +1 -1
- scale_gp_beta-0.1.0a2.dist-info/RECORD +0 -78
- {scale_gp → scale_gp_beta}/_compat.py +0 -0
- {scale_gp → scale_gp_beta}/_constants.py +0 -0
- {scale_gp → scale_gp_beta}/_exceptions.py +0 -0
- {scale_gp → scale_gp_beta}/_qs.py +0 -0
- {scale_gp → scale_gp_beta}/_resource.py +0 -0
- {scale_gp → scale_gp_beta}/_streaming.py +0 -0
- {scale_gp → scale_gp_beta}/_utils/__init__.py +0 -0
- {scale_gp → scale_gp_beta}/_utils/_proxy.py +0 -0
- {scale_gp → scale_gp_beta}/_utils/_reflection.py +0 -0
- {scale_gp → scale_gp_beta}/_utils/_streams.py +0 -0
- {scale_gp → scale_gp_beta}/_utils/_sync.py +0 -0
- {scale_gp → scale_gp_beta}/_utils/_transform.py +0 -0
- {scale_gp → scale_gp_beta}/_utils/_typing.py +0 -0
- {scale_gp → scale_gp_beta}/_utils/_utils.py +0 -0
- {scale_gp → scale_gp_beta}/lib/.keep +0 -0
- {scale_gp → scale_gp_beta}/pagination.py +0 -0
- {scale_gp → scale_gp_beta}/py.typed +0 -0
- {scale_gp → scale_gp_beta}/resources/__init__.py +0 -0
- {scale_gp → scale_gp_beta}/resources/chat/__init__.py +0 -0
- {scale_gp → scale_gp_beta}/resources/chat/chat.py +0 -0
- {scale_gp → scale_gp_beta}/resources/completions.py +0 -0
- {scale_gp → scale_gp_beta}/resources/files/__init__.py +0 -0
- {scale_gp → scale_gp_beta}/resources/files/content.py +0 -0
- {scale_gp → scale_gp_beta}/resources/files/files.py +0 -0
- {scale_gp → scale_gp_beta}/resources/inference.py +0 -0
- {scale_gp → scale_gp_beta}/resources/question_sets.py +0 -0
- {scale_gp → scale_gp_beta}/resources/questions.py +0 -0
- {scale_gp → scale_gp_beta}/types/__init__.py +0 -0
- {scale_gp → scale_gp_beta}/types/chat/__init__.py +0 -0
- {scale_gp → scale_gp_beta}/types/chat/chat_completion.py +0 -0
- {scale_gp → scale_gp_beta}/types/chat/chat_completion_chunk.py +0 -0
- {scale_gp → scale_gp_beta}/types/chat/completion_create_params.py +0 -0
- {scale_gp → scale_gp_beta}/types/chat/completion_create_response.py +0 -0
- {scale_gp → scale_gp_beta}/types/completion.py +0 -0
- {scale_gp → scale_gp_beta}/types/completion_create_params.py +0 -0
- {scale_gp → scale_gp_beta}/types/file.py +0 -0
- {scale_gp → scale_gp_beta}/types/file_create_params.py +0 -0
- {scale_gp → scale_gp_beta}/types/file_delete_response.py +0 -0
- {scale_gp → scale_gp_beta}/types/file_list.py +0 -0
- {scale_gp → scale_gp_beta}/types/file_list_params.py +0 -0
- {scale_gp → scale_gp_beta}/types/file_update_params.py +0 -0
- {scale_gp → scale_gp_beta}/types/files/__init__.py +0 -0
- {scale_gp → scale_gp_beta}/types/inference_create_params.py +0 -0
- {scale_gp → scale_gp_beta}/types/inference_create_response.py +0 -0
- {scale_gp → scale_gp_beta}/types/inference_model_list.py +0 -0
- {scale_gp → scale_gp_beta}/types/inference_response.py +0 -0
- {scale_gp → scale_gp_beta}/types/inference_response_chunk.py +0 -0
- {scale_gp → scale_gp_beta}/types/model_create_params.py +0 -0
- {scale_gp → scale_gp_beta}/types/model_delete_response.py +0 -0
- {scale_gp → scale_gp_beta}/types/model_update_params.py +0 -0
- {scale_gp → scale_gp_beta}/types/question.py +0 -0
- {scale_gp → scale_gp_beta}/types/question_create_params.py +0 -0
- {scale_gp → scale_gp_beta}/types/question_list.py +0 -0
- {scale_gp → scale_gp_beta}/types/question_list_params.py +0 -0
- {scale_gp → scale_gp_beta}/types/question_set.py +0 -0
- {scale_gp → scale_gp_beta}/types/question_set_create_params.py +0 -0
- {scale_gp → scale_gp_beta}/types/question_set_delete_response.py +0 -0
- {scale_gp → scale_gp_beta}/types/question_set_list.py +0 -0
- {scale_gp → scale_gp_beta}/types/question_set_list_params.py +0 -0
- {scale_gp → scale_gp_beta}/types/question_set_retrieve_params.py +0 -0
- {scale_gp → scale_gp_beta}/types/question_set_update_params.py +0 -0
|
@@ -85,12 +85,12 @@ _setup_logging()
|
|
|
85
85
|
# Update the __module__ attribute for exported symbols so that
|
|
86
86
|
# error messages point to this module instead of the module
|
|
87
87
|
# it was originally defined in, e.g.
|
|
88
|
-
#
|
|
88
|
+
# scale_gp_beta._exceptions.NotFoundError -> scale_gp_beta.NotFoundError
|
|
89
89
|
__locals = locals()
|
|
90
90
|
for __name in __all__:
|
|
91
91
|
if not __name.startswith("__"):
|
|
92
92
|
try:
|
|
93
|
-
__locals[__name].__module__ = "
|
|
93
|
+
__locals[__name].__module__ = "scale_gp_beta"
|
|
94
94
|
except (TypeError, AttributeError):
|
|
95
95
|
# Some of our exported symbols are builtins which we can't set attributes for.
|
|
96
96
|
pass
|
|
@@ -9,7 +9,6 @@ import asyncio
|
|
|
9
9
|
import inspect
|
|
10
10
|
import logging
|
|
11
11
|
import platform
|
|
12
|
-
import warnings
|
|
13
12
|
import email.utils
|
|
14
13
|
from types import TracebackType
|
|
15
14
|
from random import random
|
|
@@ -36,7 +35,7 @@ import anyio
|
|
|
36
35
|
import httpx
|
|
37
36
|
import distro
|
|
38
37
|
import pydantic
|
|
39
|
-
from httpx import URL
|
|
38
|
+
from httpx import URL
|
|
40
39
|
from pydantic import PrivateAttr
|
|
41
40
|
|
|
42
41
|
from . import _exceptions
|
|
@@ -51,19 +50,16 @@ from ._types import (
|
|
|
51
50
|
Timeout,
|
|
52
51
|
NotGiven,
|
|
53
52
|
ResponseT,
|
|
54
|
-
Transport,
|
|
55
53
|
AnyMapping,
|
|
56
54
|
PostParser,
|
|
57
|
-
ProxiesTypes,
|
|
58
55
|
RequestFiles,
|
|
59
56
|
HttpxSendArgs,
|
|
60
|
-
AsyncTransport,
|
|
61
57
|
RequestOptions,
|
|
62
58
|
HttpxRequestFiles,
|
|
63
59
|
ModelBuilderProtocol,
|
|
64
60
|
)
|
|
65
61
|
from ._utils import is_dict, is_list, asyncify, is_given, lru_cache, is_mapping
|
|
66
|
-
from ._compat import model_copy, model_dump
|
|
62
|
+
from ._compat import PYDANTIC_V2, model_copy, model_dump
|
|
67
63
|
from ._models import GenericModel, FinalRequestOptions, validate_type, construct_type
|
|
68
64
|
from ._response import (
|
|
69
65
|
APIResponse,
|
|
@@ -207,6 +203,9 @@ class BaseSyncPage(BasePage[_T], Generic[_T]):
|
|
|
207
203
|
model: Type[_T],
|
|
208
204
|
options: FinalRequestOptions,
|
|
209
205
|
) -> None:
|
|
206
|
+
if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None:
|
|
207
|
+
self.__pydantic_private__ = {}
|
|
208
|
+
|
|
210
209
|
self._model = model
|
|
211
210
|
self._client = client
|
|
212
211
|
self._options = options
|
|
@@ -292,6 +291,9 @@ class BaseAsyncPage(BasePage[_T], Generic[_T]):
|
|
|
292
291
|
client: AsyncAPIClient,
|
|
293
292
|
options: FinalRequestOptions,
|
|
294
293
|
) -> None:
|
|
294
|
+
if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None:
|
|
295
|
+
self.__pydantic_private__ = {}
|
|
296
|
+
|
|
295
297
|
self._model = model
|
|
296
298
|
self._client = client
|
|
297
299
|
self._options = options
|
|
@@ -331,9 +333,6 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
|
|
|
331
333
|
_base_url: URL
|
|
332
334
|
max_retries: int
|
|
333
335
|
timeout: Union[float, Timeout, None]
|
|
334
|
-
_limits: httpx.Limits
|
|
335
|
-
_proxies: ProxiesTypes | None
|
|
336
|
-
_transport: Transport | AsyncTransport | None
|
|
337
336
|
_strict_response_validation: bool
|
|
338
337
|
_idempotency_header: str | None
|
|
339
338
|
_default_stream_cls: type[_DefaultStreamT] | None = None
|
|
@@ -346,9 +345,6 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
|
|
|
346
345
|
_strict_response_validation: bool,
|
|
347
346
|
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
348
347
|
timeout: float | Timeout | None = DEFAULT_TIMEOUT,
|
|
349
|
-
limits: httpx.Limits,
|
|
350
|
-
transport: Transport | AsyncTransport | None,
|
|
351
|
-
proxies: ProxiesTypes | None,
|
|
352
348
|
custom_headers: Mapping[str, str] | None = None,
|
|
353
349
|
custom_query: Mapping[str, object] | None = None,
|
|
354
350
|
) -> None:
|
|
@@ -356,9 +352,6 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
|
|
|
356
352
|
self._base_url = self._enforce_trailing_slash(URL(base_url))
|
|
357
353
|
self.max_retries = max_retries
|
|
358
354
|
self.timeout = timeout
|
|
359
|
-
self._limits = limits
|
|
360
|
-
self._proxies = proxies
|
|
361
|
-
self._transport = transport
|
|
362
355
|
self._custom_headers = custom_headers or {}
|
|
363
356
|
self._custom_query = custom_query or {}
|
|
364
357
|
self._strict_response_validation = _strict_response_validation
|
|
@@ -367,7 +360,7 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
|
|
|
367
360
|
|
|
368
361
|
if max_retries is None: # pyright: ignore[reportUnnecessaryComparison]
|
|
369
362
|
raise TypeError(
|
|
370
|
-
"max_retries cannot be None. If you want to disable retries, pass `0`; if you want unlimited retries, pass `math.inf` or a very high number; if you want the default behavior, pass `
|
|
363
|
+
"max_retries cannot be None. If you want to disable retries, pass `0`; if you want unlimited retries, pass `math.inf` or a very high number; if you want the default behavior, pass `scale_gp_beta.DEFAULT_MAX_RETRIES`"
|
|
371
364
|
)
|
|
372
365
|
|
|
373
366
|
def _enforce_trailing_slash(self, url: URL) -> URL:
|
|
@@ -518,7 +511,7 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
|
|
|
518
511
|
# so that passing a `TypedDict` doesn't cause an error.
|
|
519
512
|
# https://github.com/microsoft/pyright/issues/3526#event-6715453066
|
|
520
513
|
params=self.qs.stringify(cast(Mapping[str, Any], params)) if params else None,
|
|
521
|
-
json=json_data,
|
|
514
|
+
json=json_data if is_given(json_data) else None,
|
|
522
515
|
files=files,
|
|
523
516
|
**kwargs,
|
|
524
517
|
)
|
|
@@ -794,46 +787,11 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
|
|
|
794
787
|
base_url: str | URL,
|
|
795
788
|
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
796
789
|
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
|
|
797
|
-
transport: Transport | None = None,
|
|
798
|
-
proxies: ProxiesTypes | None = None,
|
|
799
|
-
limits: Limits | None = None,
|
|
800
790
|
http_client: httpx.Client | None = None,
|
|
801
791
|
custom_headers: Mapping[str, str] | None = None,
|
|
802
792
|
custom_query: Mapping[str, object] | None = None,
|
|
803
793
|
_strict_response_validation: bool,
|
|
804
794
|
) -> None:
|
|
805
|
-
kwargs: dict[str, Any] = {}
|
|
806
|
-
if limits is not None:
|
|
807
|
-
warnings.warn(
|
|
808
|
-
"The `connection_pool_limits` argument is deprecated. The `http_client` argument should be passed instead",
|
|
809
|
-
category=DeprecationWarning,
|
|
810
|
-
stacklevel=3,
|
|
811
|
-
)
|
|
812
|
-
if http_client is not None:
|
|
813
|
-
raise ValueError("The `http_client` argument is mutually exclusive with `connection_pool_limits`")
|
|
814
|
-
else:
|
|
815
|
-
limits = DEFAULT_CONNECTION_LIMITS
|
|
816
|
-
|
|
817
|
-
if transport is not None:
|
|
818
|
-
kwargs["transport"] = transport
|
|
819
|
-
warnings.warn(
|
|
820
|
-
"The `transport` argument is deprecated. The `http_client` argument should be passed instead",
|
|
821
|
-
category=DeprecationWarning,
|
|
822
|
-
stacklevel=3,
|
|
823
|
-
)
|
|
824
|
-
if http_client is not None:
|
|
825
|
-
raise ValueError("The `http_client` argument is mutually exclusive with `transport`")
|
|
826
|
-
|
|
827
|
-
if proxies is not None:
|
|
828
|
-
kwargs["proxies"] = proxies
|
|
829
|
-
warnings.warn(
|
|
830
|
-
"The `proxies` argument is deprecated. The `http_client` argument should be passed instead",
|
|
831
|
-
category=DeprecationWarning,
|
|
832
|
-
stacklevel=3,
|
|
833
|
-
)
|
|
834
|
-
if http_client is not None:
|
|
835
|
-
raise ValueError("The `http_client` argument is mutually exclusive with `proxies`")
|
|
836
|
-
|
|
837
795
|
if not is_given(timeout):
|
|
838
796
|
# if the user passed in a custom http client with a non-default
|
|
839
797
|
# timeout set then we use that timeout.
|
|
@@ -854,12 +812,9 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
|
|
|
854
812
|
|
|
855
813
|
super().__init__(
|
|
856
814
|
version=version,
|
|
857
|
-
limits=limits,
|
|
858
815
|
# cast to a valid type because mypy doesn't understand our type narrowing
|
|
859
816
|
timeout=cast(Timeout, timeout),
|
|
860
|
-
proxies=proxies,
|
|
861
817
|
base_url=base_url,
|
|
862
|
-
transport=transport,
|
|
863
818
|
max_retries=max_retries,
|
|
864
819
|
custom_query=custom_query,
|
|
865
820
|
custom_headers=custom_headers,
|
|
@@ -869,9 +824,6 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
|
|
|
869
824
|
base_url=base_url,
|
|
870
825
|
# cast to a valid type because mypy doesn't understand our type narrowing
|
|
871
826
|
timeout=cast(Timeout, timeout),
|
|
872
|
-
limits=limits,
|
|
873
|
-
follow_redirects=True,
|
|
874
|
-
**kwargs, # type: ignore
|
|
875
827
|
)
|
|
876
828
|
|
|
877
829
|
def is_closed(self) -> bool:
|
|
@@ -1366,45 +1318,10 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
|
|
|
1366
1318
|
_strict_response_validation: bool,
|
|
1367
1319
|
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
1368
1320
|
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
|
|
1369
|
-
transport: AsyncTransport | None = None,
|
|
1370
|
-
proxies: ProxiesTypes | None = None,
|
|
1371
|
-
limits: Limits | None = None,
|
|
1372
1321
|
http_client: httpx.AsyncClient | None = None,
|
|
1373
1322
|
custom_headers: Mapping[str, str] | None = None,
|
|
1374
1323
|
custom_query: Mapping[str, object] | None = None,
|
|
1375
1324
|
) -> None:
|
|
1376
|
-
kwargs: dict[str, Any] = {}
|
|
1377
|
-
if limits is not None:
|
|
1378
|
-
warnings.warn(
|
|
1379
|
-
"The `connection_pool_limits` argument is deprecated. The `http_client` argument should be passed instead",
|
|
1380
|
-
category=DeprecationWarning,
|
|
1381
|
-
stacklevel=3,
|
|
1382
|
-
)
|
|
1383
|
-
if http_client is not None:
|
|
1384
|
-
raise ValueError("The `http_client` argument is mutually exclusive with `connection_pool_limits`")
|
|
1385
|
-
else:
|
|
1386
|
-
limits = DEFAULT_CONNECTION_LIMITS
|
|
1387
|
-
|
|
1388
|
-
if transport is not None:
|
|
1389
|
-
kwargs["transport"] = transport
|
|
1390
|
-
warnings.warn(
|
|
1391
|
-
"The `transport` argument is deprecated. The `http_client` argument should be passed instead",
|
|
1392
|
-
category=DeprecationWarning,
|
|
1393
|
-
stacklevel=3,
|
|
1394
|
-
)
|
|
1395
|
-
if http_client is not None:
|
|
1396
|
-
raise ValueError("The `http_client` argument is mutually exclusive with `transport`")
|
|
1397
|
-
|
|
1398
|
-
if proxies is not None:
|
|
1399
|
-
kwargs["proxies"] = proxies
|
|
1400
|
-
warnings.warn(
|
|
1401
|
-
"The `proxies` argument is deprecated. The `http_client` argument should be passed instead",
|
|
1402
|
-
category=DeprecationWarning,
|
|
1403
|
-
stacklevel=3,
|
|
1404
|
-
)
|
|
1405
|
-
if http_client is not None:
|
|
1406
|
-
raise ValueError("The `http_client` argument is mutually exclusive with `proxies`")
|
|
1407
|
-
|
|
1408
1325
|
if not is_given(timeout):
|
|
1409
1326
|
# if the user passed in a custom http client with a non-default
|
|
1410
1327
|
# timeout set then we use that timeout.
|
|
@@ -1426,11 +1343,8 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
|
|
|
1426
1343
|
super().__init__(
|
|
1427
1344
|
version=version,
|
|
1428
1345
|
base_url=base_url,
|
|
1429
|
-
limits=limits,
|
|
1430
1346
|
# cast to a valid type because mypy doesn't understand our type narrowing
|
|
1431
1347
|
timeout=cast(Timeout, timeout),
|
|
1432
|
-
proxies=proxies,
|
|
1433
|
-
transport=transport,
|
|
1434
1348
|
max_retries=max_retries,
|
|
1435
1349
|
custom_query=custom_query,
|
|
1436
1350
|
custom_headers=custom_headers,
|
|
@@ -1440,9 +1354,6 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
|
|
|
1440
1354
|
base_url=base_url,
|
|
1441
1355
|
# cast to a valid type because mypy doesn't understand our type narrowing
|
|
1442
1356
|
timeout=cast(Timeout, timeout),
|
|
1443
|
-
limits=limits,
|
|
1444
|
-
follow_redirects=True,
|
|
1445
|
-
**kwargs, # type: ignore
|
|
1446
1357
|
)
|
|
1447
1358
|
|
|
1448
1359
|
def is_closed(self) -> bool:
|
|
@@ -316,7 +316,7 @@ class AsyncSGPClient(AsyncAPIClient):
|
|
|
316
316
|
# part of our public interface in the future.
|
|
317
317
|
_strict_response_validation: bool = False,
|
|
318
318
|
) -> None:
|
|
319
|
-
"""Construct a new async
|
|
319
|
+
"""Construct a new async AsyncSGPClient client instance.
|
|
320
320
|
|
|
321
321
|
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
|
|
322
322
|
- `api_key` from `SGP_API_KEY`
|
|
@@ -34,7 +34,7 @@ def assert_is_file_content(obj: object, *, key: str | None = None) -> None:
|
|
|
34
34
|
if not is_file_content(obj):
|
|
35
35
|
prefix = f"Expected entry at `{key}`" if key is not None else f"Expected file input `{obj!r}`"
|
|
36
36
|
raise RuntimeError(
|
|
37
|
-
f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead."
|
|
37
|
+
f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead. See https://github.com/scaleapi/sgp-python-beta/tree/main#file-uploads"
|
|
38
38
|
) from None
|
|
39
39
|
|
|
40
40
|
|
|
@@ -65,7 +65,7 @@ from ._compat import (
|
|
|
65
65
|
from ._constants import RAW_RESPONSE_HEADER
|
|
66
66
|
|
|
67
67
|
if TYPE_CHECKING:
|
|
68
|
-
from pydantic_core.core_schema import ModelField, LiteralSchema, ModelFieldsSchema
|
|
68
|
+
from pydantic_core.core_schema import ModelField, ModelSchema, LiteralSchema, ModelFieldsSchema
|
|
69
69
|
|
|
70
70
|
__all__ = ["BaseModel", "GenericModel"]
|
|
71
71
|
|
|
@@ -646,15 +646,18 @@ def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any,
|
|
|
646
646
|
|
|
647
647
|
def _extract_field_schema_pv2(model: type[BaseModel], field_name: str) -> ModelField | None:
|
|
648
648
|
schema = model.__pydantic_core_schema__
|
|
649
|
+
if schema["type"] == "definitions":
|
|
650
|
+
schema = schema["schema"]
|
|
651
|
+
|
|
649
652
|
if schema["type"] != "model":
|
|
650
653
|
return None
|
|
651
654
|
|
|
655
|
+
schema = cast("ModelSchema", schema)
|
|
652
656
|
fields_schema = schema["schema"]
|
|
653
657
|
if fields_schema["type"] != "model-fields":
|
|
654
658
|
return None
|
|
655
659
|
|
|
656
660
|
fields_schema = cast("ModelFieldsSchema", fields_schema)
|
|
657
|
-
|
|
658
661
|
field = fields_schema["fields"].get(field_name)
|
|
659
662
|
if not field:
|
|
660
663
|
return None
|
|
@@ -217,7 +217,9 @@ class BaseAPIResponse(Generic[R]):
|
|
|
217
217
|
and not issubclass(origin, BaseModel)
|
|
218
218
|
and issubclass(origin, pydantic.BaseModel)
|
|
219
219
|
):
|
|
220
|
-
raise TypeError(
|
|
220
|
+
raise TypeError(
|
|
221
|
+
"Pydantic models must subclass our base model type, e.g. `from scale_gp_beta import BaseModel`"
|
|
222
|
+
)
|
|
221
223
|
|
|
222
224
|
if (
|
|
223
225
|
cast_to is not object
|
|
@@ -283,7 +285,7 @@ class APIResponse(BaseAPIResponse[R]):
|
|
|
283
285
|
the `to` argument, e.g.
|
|
284
286
|
|
|
285
287
|
```py
|
|
286
|
-
from
|
|
288
|
+
from scale_gp_beta import BaseModel
|
|
287
289
|
|
|
288
290
|
|
|
289
291
|
class MyModel(BaseModel):
|
|
@@ -385,7 +387,7 @@ class AsyncAPIResponse(BaseAPIResponse[R]):
|
|
|
385
387
|
the `to` argument, e.g.
|
|
386
388
|
|
|
387
389
|
```py
|
|
388
|
-
from
|
|
390
|
+
from scale_gp_beta import BaseModel
|
|
389
391
|
|
|
390
392
|
|
|
391
393
|
class MyModel(BaseModel):
|
|
@@ -556,7 +558,7 @@ class AsyncStreamedBinaryAPIResponse(AsyncAPIResponse[bytes]):
|
|
|
556
558
|
class MissingStreamClassError(TypeError):
|
|
557
559
|
def __init__(self) -> None:
|
|
558
560
|
super().__init__(
|
|
559
|
-
"The `stream` argument was set to `True` but the `stream_cls` argument was not given. See `
|
|
561
|
+
"The `stream` argument was set to `True` but the `stream_cls` argument was not given. See `scale_gp_beta._streaming` for reference",
|
|
560
562
|
)
|
|
561
563
|
|
|
562
564
|
|
|
@@ -81,7 +81,7 @@ HttpxRequestFiles = Union[Mapping[str, HttpxFileTypes], Sequence[Tuple[str, Http
|
|
|
81
81
|
# This unfortunately means that you will either have
|
|
82
82
|
# to import this type and pass it explicitly:
|
|
83
83
|
#
|
|
84
|
-
# from
|
|
84
|
+
# from scale_gp_beta import NoneType
|
|
85
85
|
# client.get('/foo', cast_to=NoneType)
|
|
86
86
|
#
|
|
87
87
|
# or build it yourself:
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import logging
|
|
3
3
|
|
|
4
|
-
logger: logging.Logger = logging.getLogger("
|
|
4
|
+
logger: logging.Logger = logging.getLogger("scale_gp_beta")
|
|
5
5
|
httpx_logger: logging.Logger = logging.getLogger("httpx")
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
def _basic_config() -> None:
|
|
9
|
-
# e.g. [2023-10-05 14:12:26 -
|
|
9
|
+
# e.g. [2023-10-05 14:12:26 - scale_gp_beta._base_client:818 - DEBUG] HTTP Request: POST http://127.0.0.1:4010/foo/bar "200 OK"
|
|
10
10
|
logging.basicConfig(
|
|
11
11
|
format="[%(asctime)s - %(name)s:%(lineno)d - %(levelname)s] %(message)s",
|
|
12
12
|
datefmt="%Y-%m-%d %H:%M:%S",
|
|
@@ -474,53 +474,50 @@ class CompletionsResource(SyncAPIResource):
|
|
|
474
474
|
extra_body: Body | None = None,
|
|
475
475
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
476
476
|
) -> CompletionCreateResponse | Stream[ChatCompletionChunk]:
|
|
477
|
-
return
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
},
|
|
513
|
-
completion_create_params.CompletionCreateParams,
|
|
514
|
-
),
|
|
515
|
-
options=make_request_options(
|
|
516
|
-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
517
|
-
),
|
|
518
|
-
cast_to=cast(
|
|
519
|
-
Any, CompletionCreateResponse
|
|
520
|
-
), # Union types cannot be passed in as arguments in the type system
|
|
521
|
-
stream=stream or False,
|
|
522
|
-
stream_cls=Stream[ChatCompletionChunk],
|
|
477
|
+
return self._post(
|
|
478
|
+
"/v5/chat/completions",
|
|
479
|
+
body=maybe_transform(
|
|
480
|
+
{
|
|
481
|
+
"messages": messages,
|
|
482
|
+
"model": model,
|
|
483
|
+
"audio": audio,
|
|
484
|
+
"frequency_penalty": frequency_penalty,
|
|
485
|
+
"function_call": function_call,
|
|
486
|
+
"functions": functions,
|
|
487
|
+
"logit_bias": logit_bias,
|
|
488
|
+
"logprobs": logprobs,
|
|
489
|
+
"max_completion_tokens": max_completion_tokens,
|
|
490
|
+
"max_tokens": max_tokens,
|
|
491
|
+
"metadata": metadata,
|
|
492
|
+
"modalities": modalities,
|
|
493
|
+
"n": n,
|
|
494
|
+
"parallel_tool_calls": parallel_tool_calls,
|
|
495
|
+
"prediction": prediction,
|
|
496
|
+
"presence_penalty": presence_penalty,
|
|
497
|
+
"reasoning_effort": reasoning_effort,
|
|
498
|
+
"response_format": response_format,
|
|
499
|
+
"seed": seed,
|
|
500
|
+
"stop": stop,
|
|
501
|
+
"store": store,
|
|
502
|
+
"stream": stream,
|
|
503
|
+
"stream_options": stream_options,
|
|
504
|
+
"temperature": temperature,
|
|
505
|
+
"tool_choice": tool_choice,
|
|
506
|
+
"tools": tools,
|
|
507
|
+
"top_k": top_k,
|
|
508
|
+
"top_logprobs": top_logprobs,
|
|
509
|
+
"top_p": top_p,
|
|
510
|
+
},
|
|
511
|
+
completion_create_params.CompletionCreateParams,
|
|
523
512
|
),
|
|
513
|
+
options=make_request_options(
|
|
514
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
515
|
+
),
|
|
516
|
+
cast_to=cast(
|
|
517
|
+
Any, CompletionCreateResponse
|
|
518
|
+
), # Union types cannot be passed in as arguments in the type system
|
|
519
|
+
stream=stream or False,
|
|
520
|
+
stream_cls=Stream[ChatCompletionChunk],
|
|
524
521
|
)
|
|
525
522
|
|
|
526
523
|
|
|
@@ -968,53 +965,50 @@ class AsyncCompletionsResource(AsyncAPIResource):
|
|
|
968
965
|
extra_body: Body | None = None,
|
|
969
966
|
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
|
970
967
|
) -> CompletionCreateResponse | AsyncStream[ChatCompletionChunk]:
|
|
971
|
-
return
|
|
972
|
-
|
|
973
|
-
await
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
options=make_request_options(
|
|
1010
|
-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
1011
|
-
),
|
|
1012
|
-
cast_to=cast(
|
|
1013
|
-
Any, CompletionCreateResponse
|
|
1014
|
-
), # Union types cannot be passed in as arguments in the type system
|
|
1015
|
-
stream=stream or False,
|
|
1016
|
-
stream_cls=AsyncStream[ChatCompletionChunk],
|
|
968
|
+
return await self._post(
|
|
969
|
+
"/v5/chat/completions",
|
|
970
|
+
body=await async_maybe_transform(
|
|
971
|
+
{
|
|
972
|
+
"messages": messages,
|
|
973
|
+
"model": model,
|
|
974
|
+
"audio": audio,
|
|
975
|
+
"frequency_penalty": frequency_penalty,
|
|
976
|
+
"function_call": function_call,
|
|
977
|
+
"functions": functions,
|
|
978
|
+
"logit_bias": logit_bias,
|
|
979
|
+
"logprobs": logprobs,
|
|
980
|
+
"max_completion_tokens": max_completion_tokens,
|
|
981
|
+
"max_tokens": max_tokens,
|
|
982
|
+
"metadata": metadata,
|
|
983
|
+
"modalities": modalities,
|
|
984
|
+
"n": n,
|
|
985
|
+
"parallel_tool_calls": parallel_tool_calls,
|
|
986
|
+
"prediction": prediction,
|
|
987
|
+
"presence_penalty": presence_penalty,
|
|
988
|
+
"reasoning_effort": reasoning_effort,
|
|
989
|
+
"response_format": response_format,
|
|
990
|
+
"seed": seed,
|
|
991
|
+
"stop": stop,
|
|
992
|
+
"store": store,
|
|
993
|
+
"stream": stream,
|
|
994
|
+
"stream_options": stream_options,
|
|
995
|
+
"temperature": temperature,
|
|
996
|
+
"tool_choice": tool_choice,
|
|
997
|
+
"tools": tools,
|
|
998
|
+
"top_k": top_k,
|
|
999
|
+
"top_logprobs": top_logprobs,
|
|
1000
|
+
"top_p": top_p,
|
|
1001
|
+
},
|
|
1002
|
+
completion_create_params.CompletionCreateParams,
|
|
1003
|
+
),
|
|
1004
|
+
options=make_request_options(
|
|
1005
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
1017
1006
|
),
|
|
1007
|
+
cast_to=cast(
|
|
1008
|
+
Any, CompletionCreateResponse
|
|
1009
|
+
), # Union types cannot be passed in as arguments in the type system
|
|
1010
|
+
stream=stream or False,
|
|
1011
|
+
stream_cls=AsyncStream[ChatCompletionChunk],
|
|
1018
1012
|
)
|
|
1019
1013
|
|
|
1020
1014
|
|
|
@@ -310,7 +310,19 @@ class ModelsResource(SyncAPIResource):
|
|
|
310
310
|
ending_before: Optional[str] | NotGiven = NOT_GIVEN,
|
|
311
311
|
limit: int | NotGiven = NOT_GIVEN,
|
|
312
312
|
model_vendor: Optional[
|
|
313
|
-
Literal[
|
|
313
|
+
Literal[
|
|
314
|
+
"openai",
|
|
315
|
+
"cohere",
|
|
316
|
+
"vertex_ai",
|
|
317
|
+
"anthropic",
|
|
318
|
+
"azure",
|
|
319
|
+
"gemini",
|
|
320
|
+
"launch",
|
|
321
|
+
"llmengine",
|
|
322
|
+
"model_zoo",
|
|
323
|
+
"bedrock",
|
|
324
|
+
"xai",
|
|
325
|
+
]
|
|
314
326
|
]
|
|
315
327
|
| NotGiven = NOT_GIVEN,
|
|
316
328
|
name: Optional[str] | NotGiven = NOT_GIVEN,
|
|
@@ -670,7 +682,19 @@ class AsyncModelsResource(AsyncAPIResource):
|
|
|
670
682
|
ending_before: Optional[str] | NotGiven = NOT_GIVEN,
|
|
671
683
|
limit: int | NotGiven = NOT_GIVEN,
|
|
672
684
|
model_vendor: Optional[
|
|
673
|
-
Literal[
|
|
685
|
+
Literal[
|
|
686
|
+
"openai",
|
|
687
|
+
"cohere",
|
|
688
|
+
"vertex_ai",
|
|
689
|
+
"anthropic",
|
|
690
|
+
"azure",
|
|
691
|
+
"gemini",
|
|
692
|
+
"launch",
|
|
693
|
+
"llmengine",
|
|
694
|
+
"model_zoo",
|
|
695
|
+
"bedrock",
|
|
696
|
+
"xai",
|
|
697
|
+
]
|
|
674
698
|
]
|
|
675
699
|
| NotGiven = NOT_GIVEN,
|
|
676
700
|
name: Optional[str] | NotGiven = NOT_GIVEN,
|
|
@@ -152,16 +152,30 @@ class InferenceModel(BaseModel):
|
|
|
152
152
|
|
|
153
153
|
api_model_type: Literal["generic", "completion", "chat_completion"] = FieldInfo(alias="model_type")
|
|
154
154
|
|
|
155
|
-
api_model_vendor: Literal[
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
api_model_vendor: Literal[
|
|
156
|
+
"openai",
|
|
157
|
+
"cohere",
|
|
158
|
+
"vertex_ai",
|
|
159
|
+
"anthropic",
|
|
160
|
+
"azure",
|
|
161
|
+
"gemini",
|
|
162
|
+
"launch",
|
|
163
|
+
"llmengine",
|
|
164
|
+
"model_zoo",
|
|
165
|
+
"bedrock",
|
|
166
|
+
"xai",
|
|
167
|
+
] = FieldInfo(alias="model_vendor")
|
|
158
168
|
|
|
159
169
|
name: str
|
|
160
170
|
|
|
161
171
|
status: Literal["failed", "ready", "deploying"]
|
|
162
172
|
|
|
163
|
-
|
|
173
|
+
description: Optional[str] = None
|
|
174
|
+
|
|
175
|
+
display_name: Optional[str] = None
|
|
164
176
|
|
|
165
177
|
api_model_metadata: Optional[Dict[str, object]] = FieldInfo(alias="model_metadata", default=None)
|
|
166
178
|
|
|
167
179
|
object: Optional[Literal["model"]] = None
|
|
180
|
+
|
|
181
|
+
vendor_configuration: Optional[VendorConfiguration] = None
|