scale-gp-beta 0.1.0a41__py3-none-any.whl → 0.1.0a42__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_beta/_client.py +4 -0
- scale_gp_beta/_streaming.py +4 -2
- scale_gp_beta/_version.py +1 -1
- scale_gp_beta/resources/build.py +10 -4
- scale_gp_beta/types/__init__.py +1 -0
- scale_gp_beta/types/stream_chunk.py +12 -0
- {scale_gp_beta-0.1.0a41.dist-info → scale_gp_beta-0.1.0a42.dist-info}/METADATA +39 -1
- {scale_gp_beta-0.1.0a41.dist-info → scale_gp_beta-0.1.0a42.dist-info}/RECORD +10 -9
- {scale_gp_beta-0.1.0a41.dist-info → scale_gp_beta-0.1.0a42.dist-info}/WHEEL +0 -0
- {scale_gp_beta-0.1.0a41.dist-info → scale_gp_beta-0.1.0a42.dist-info}/licenses/LICENSE +0 -0
scale_gp_beta/_client.py
CHANGED
|
@@ -173,6 +173,8 @@ class SGPClient(SyncAPIClient):
|
|
|
173
173
|
_strict_response_validation=_strict_response_validation,
|
|
174
174
|
)
|
|
175
175
|
|
|
176
|
+
self._default_stream_cls = Stream
|
|
177
|
+
|
|
176
178
|
@cached_property
|
|
177
179
|
def responses(self) -> ResponsesResource:
|
|
178
180
|
from .resources.responses import ResponsesResource
|
|
@@ -472,6 +474,8 @@ class AsyncSGPClient(AsyncAPIClient):
|
|
|
472
474
|
_strict_response_validation=_strict_response_validation,
|
|
473
475
|
)
|
|
474
476
|
|
|
477
|
+
self._default_stream_cls = AsyncStream
|
|
478
|
+
|
|
475
479
|
@cached_property
|
|
476
480
|
def responses(self) -> AsyncResponsesResource:
|
|
477
481
|
from .resources.responses import AsyncResponsesResource
|
scale_gp_beta/_streaming.py
CHANGED
|
@@ -56,7 +56,8 @@ class Stream(Generic[_T]):
|
|
|
56
56
|
|
|
57
57
|
try:
|
|
58
58
|
for sse in iterator:
|
|
59
|
-
|
|
59
|
+
if sse.event is None:
|
|
60
|
+
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
|
|
60
61
|
finally:
|
|
61
62
|
# Ensure the response is closed even if the consumer doesn't read all data
|
|
62
63
|
response.close()
|
|
@@ -120,7 +121,8 @@ class AsyncStream(Generic[_T]):
|
|
|
120
121
|
|
|
121
122
|
try:
|
|
122
123
|
async for sse in iterator:
|
|
123
|
-
|
|
124
|
+
if sse.event is None:
|
|
125
|
+
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
|
|
124
126
|
finally:
|
|
125
127
|
# Ensure the response is closed even if the consumer doesn't read all data
|
|
126
128
|
await response.aclose()
|
scale_gp_beta/_version.py
CHANGED
scale_gp_beta/resources/build.py
CHANGED
|
@@ -18,8 +18,10 @@ from .._response import (
|
|
|
18
18
|
async_to_raw_response_wrapper,
|
|
19
19
|
async_to_streamed_response_wrapper,
|
|
20
20
|
)
|
|
21
|
+
from .._streaming import Stream, AsyncStream
|
|
21
22
|
from ..pagination import SyncCursorPage, AsyncCursorPage
|
|
22
23
|
from .._base_client import AsyncPaginator, make_request_options
|
|
24
|
+
from ..types.stream_chunk import StreamChunk
|
|
23
25
|
from ..types.build_list_response import BuildListResponse
|
|
24
26
|
from ..types.build_cancel_response import BuildCancelResponse
|
|
25
27
|
from ..types.build_create_response import BuildCreateResponse
|
|
@@ -236,7 +238,7 @@ class BuildResource(SyncAPIResource):
|
|
|
236
238
|
extra_query: Query | None = None,
|
|
237
239
|
extra_body: Body | None = None,
|
|
238
240
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
239
|
-
) ->
|
|
241
|
+
) -> Stream[StreamChunk]:
|
|
240
242
|
"""
|
|
241
243
|
Stream build logs via Server-Sent Events (SSE).
|
|
242
244
|
|
|
@@ -259,7 +261,9 @@ class BuildResource(SyncAPIResource):
|
|
|
259
261
|
options=make_request_options(
|
|
260
262
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
261
263
|
),
|
|
262
|
-
cast_to=
|
|
264
|
+
cast_to=StreamChunk,
|
|
265
|
+
stream=True,
|
|
266
|
+
stream_cls=Stream[StreamChunk],
|
|
263
267
|
)
|
|
264
268
|
|
|
265
269
|
|
|
@@ -471,7 +475,7 @@ class AsyncBuildResource(AsyncAPIResource):
|
|
|
471
475
|
extra_query: Query | None = None,
|
|
472
476
|
extra_body: Body | None = None,
|
|
473
477
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
474
|
-
) ->
|
|
478
|
+
) -> AsyncStream[StreamChunk]:
|
|
475
479
|
"""
|
|
476
480
|
Stream build logs via Server-Sent Events (SSE).
|
|
477
481
|
|
|
@@ -494,7 +498,9 @@ class AsyncBuildResource(AsyncAPIResource):
|
|
|
494
498
|
options=make_request_options(
|
|
495
499
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
496
500
|
),
|
|
497
|
-
cast_to=
|
|
501
|
+
cast_to=StreamChunk,
|
|
502
|
+
stream=True,
|
|
503
|
+
stream_cls=AsyncStream[StreamChunk],
|
|
498
504
|
)
|
|
499
505
|
|
|
500
506
|
|
scale_gp_beta/types/__init__.py
CHANGED
|
@@ -19,6 +19,7 @@ from .evaluation import Evaluation as Evaluation
|
|
|
19
19
|
from .span_status import SpanStatus as SpanStatus
|
|
20
20
|
from .dataset_item import DatasetItem as DatasetItem
|
|
21
21
|
from .item_locator import ItemLocator as ItemLocator
|
|
22
|
+
from .stream_chunk import StreamChunk as StreamChunk
|
|
22
23
|
from .approval_status import ApprovalStatus as ApprovalStatus
|
|
23
24
|
from .assessment_type import AssessmentType as AssessmentType
|
|
24
25
|
from .component_param import ComponentParam as ComponentParam
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from .._models import BaseModel
|
|
4
|
+
|
|
5
|
+
__all__ = ["StreamChunk"]
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class StreamChunk(BaseModel):
|
|
9
|
+
"""A single log line from the build process."""
|
|
10
|
+
|
|
11
|
+
line: str
|
|
12
|
+
"""The log line content"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: scale-gp-beta
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.0a42
|
|
4
4
|
Summary: The official Python library for the Scale GP API
|
|
5
5
|
Project-URL: Homepage, https://github.com/scaleapi/sgp-python-beta
|
|
6
6
|
Project-URL: Repository, https://github.com/scaleapi/sgp-python-beta
|
|
@@ -395,6 +395,44 @@ async def main() -> None:
|
|
|
395
395
|
asyncio.run(main())
|
|
396
396
|
```
|
|
397
397
|
|
|
398
|
+
## Streaming responses
|
|
399
|
+
|
|
400
|
+
We provide support for streaming responses using Server Side Events (SSE).
|
|
401
|
+
|
|
402
|
+
```python
|
|
403
|
+
from scale_gp_beta import SGPClient
|
|
404
|
+
|
|
405
|
+
client = SGPClient(
|
|
406
|
+
account_id="My Account ID",
|
|
407
|
+
)
|
|
408
|
+
|
|
409
|
+
stream = client.chat.completions.create(
|
|
410
|
+
messages=[{"foo": "bar"}],
|
|
411
|
+
model="model",
|
|
412
|
+
stream=True,
|
|
413
|
+
)
|
|
414
|
+
for completion in stream:
|
|
415
|
+
print(completion)
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
The async client uses the exact same interface.
|
|
419
|
+
|
|
420
|
+
```python
|
|
421
|
+
from scale_gp_beta import AsyncSGPClient
|
|
422
|
+
|
|
423
|
+
client = AsyncSGPClient(
|
|
424
|
+
account_id="My Account ID",
|
|
425
|
+
)
|
|
426
|
+
|
|
427
|
+
stream = await client.chat.completions.create(
|
|
428
|
+
messages=[{"foo": "bar"}],
|
|
429
|
+
model="model",
|
|
430
|
+
stream=True,
|
|
431
|
+
)
|
|
432
|
+
async for completion in stream:
|
|
433
|
+
print(completion)
|
|
434
|
+
```
|
|
435
|
+
|
|
398
436
|
## Using types
|
|
399
437
|
|
|
400
438
|
Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
scale_gp_beta/__init__.py,sha256=MFsKxnaLkZ-Rqv127bA2T0OpHD3me1OnwIom-0I2gB0,2742
|
|
2
2
|
scale_gp_beta/_base_client.py,sha256=J1u-5BLJ_gL10TknCyP420e8kRngnTzGh6bY5AcZez8,73416
|
|
3
|
-
scale_gp_beta/_client.py,sha256=
|
|
3
|
+
scale_gp_beta/_client.py,sha256=dzyLzPqwlvAjC0Z3rdSAl7clxuRv0EOyr4hRGrak3vU,41188
|
|
4
4
|
scale_gp_beta/_compat.py,sha256=DQBVORjFb33zch24jzkhM14msvnzY7mmSmgDLaVFUM8,6562
|
|
5
5
|
scale_gp_beta/_constants.py,sha256=S14PFzyN9-I31wiV7SmIlL5Ga0MLHxdvegInGdXH7tM,462
|
|
6
6
|
scale_gp_beta/_exceptions.py,sha256=95GM5CLFtP-QMjjmzsr5ajjZOyEZvyaETfGmqNPR8YM,3226
|
|
@@ -9,9 +9,9 @@ scale_gp_beta/_models.py,sha256=R3MpO2z4XhTAnD3ObEks32suRXleF1g7BEgQTOLIxTs,3211
|
|
|
9
9
|
scale_gp_beta/_qs.py,sha256=craIKyvPktJ94cvf9zn8j8ekG9dWJzhWv0ob34lIOv4,4828
|
|
10
10
|
scale_gp_beta/_resource.py,sha256=siZly_U6D0AOVLAzaOsqUdEFFzVMbWRj-ml30nvRp7E,1118
|
|
11
11
|
scale_gp_beta/_response.py,sha256=GemuybPk0uemovTlGHyHkj-ScYTTDJA0jqH5FQqIPwQ,28852
|
|
12
|
-
scale_gp_beta/_streaming.py,sha256
|
|
12
|
+
scale_gp_beta/_streaming.py,sha256=xX-SwwToqjKjZCpAuUixrO5qTWgdHzOMErAadnKk4Yw,10317
|
|
13
13
|
scale_gp_beta/_types.py,sha256=91u4yp566AoT5VoDhNGZbmJ213XzpSbyPHgZLCBqAs8,7601
|
|
14
|
-
scale_gp_beta/_version.py,sha256=
|
|
14
|
+
scale_gp_beta/_version.py,sha256=ld1qdiUAH4VxEkLUUYjrZLQwiOJh-ooM2jdekXQG_mA,174
|
|
15
15
|
scale_gp_beta/pagination.py,sha256=t-U86PYxl20VRsz8VXOMJJDe7HxkX7ISFMvRNbBNy9s,4054
|
|
16
16
|
scale_gp_beta/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
17
|
scale_gp_beta/_utils/__init__.py,sha256=7fch0GT9zpNnErbciSpUNa-SjTxxjY6kxHxKMOM4AGs,2305
|
|
@@ -44,7 +44,7 @@ scale_gp_beta/lib/tracing/integrations/openai/openai_span_type_map.py,sha256=WIP
|
|
|
44
44
|
scale_gp_beta/lib/tracing/integrations/openai/openai_tracing_sgp_processor.py,sha256=o-Fp_V7U9cC1kKP0_750GQInKGlF7KAdpIbGTmyu2tg,5270
|
|
45
45
|
scale_gp_beta/lib/tracing/integrations/openai/utils.py,sha256=DqCb7_QX-OT4y34K9wtoXIv7-Yk_IOvSbQvC96Sgpy8,2183
|
|
46
46
|
scale_gp_beta/resources/__init__.py,sha256=7OBbTu19SH3ZS6kO0VWCPIOUk66prBJpLy6PVP4W8ZA,7440
|
|
47
|
-
scale_gp_beta/resources/build.py,sha256=
|
|
47
|
+
scale_gp_beta/resources/build.py,sha256=1LNowzczQYRXKN0xqquhsAqqQh78Jxa_Njab1hoXsGs,22276
|
|
48
48
|
scale_gp_beta/resources/completions.py,sha256=wtVhUh5LMwXolICQhpeCZUlzRM-ChLSvLiQm92sO-EQ,30934
|
|
49
49
|
scale_gp_beta/resources/credentials.py,sha256=Eax7ouhJQ61CHy-mQlmBiylBKiNfGhBFoWlBiuHHQH4,32903
|
|
50
50
|
scale_gp_beta/resources/dataset_items.py,sha256=-cJJ1ikJ5mDUGIRkhqTuY652h0EAP5Wa-lmH2gA782w,23278
|
|
@@ -63,7 +63,7 @@ scale_gp_beta/resources/chat/completions.py,sha256=yOnyGK2QBaFNL0el5aL1A5T6JmBKo
|
|
|
63
63
|
scale_gp_beta/resources/files/__init__.py,sha256=VgAtqUimN5Kf_-lmEaNBnu_ApGegKsJQ1zNf-42MXFA,1002
|
|
64
64
|
scale_gp_beta/resources/files/content.py,sha256=QDtcnsK2my4-ndmwyaR6zyQnV1fEjIJ7CSDoyXUcYxg,5762
|
|
65
65
|
scale_gp_beta/resources/files/files.py,sha256=dowTYD-xKhCI17zINYZywUtzv7VwofjV1tY6AfncHjE,24603
|
|
66
|
-
scale_gp_beta/types/__init__.py,sha256=
|
|
66
|
+
scale_gp_beta/types/__init__.py,sha256=DWbXOTnI7vqsLfOJnKHVotfq4PxIJdO5K_fxicy3-I0,6952
|
|
67
67
|
scale_gp_beta/types/approval_status.py,sha256=rI70l7e2ey2ax8tR_sBkziVSirq_QaDDV1bHgNrfCWQ,227
|
|
68
68
|
scale_gp_beta/types/assessment_type.py,sha256=_4V6RZ5wUyU0UYrDjCoIRdaiiZtZVpY6DMsW1QClq-c,271
|
|
69
69
|
scale_gp_beta/types/build_cancel_response.py,sha256=ghlldFT3BpPZbbDa0Ag0Jj4gJKXXe9rDxX9BPN9j29Q,867
|
|
@@ -146,6 +146,7 @@ scale_gp_beta/types/span_type.py,sha256=Y4cFVO66V_KJQ2stokdspyBunh4kxgSDt2EZg960
|
|
|
146
146
|
scale_gp_beta/types/span_update_params.py,sha256=xpk0NKNsw_RAXIZN1U1ddqUHpPE--W9_Y3i1tTZKLZg,574
|
|
147
147
|
scale_gp_beta/types/span_upsert_batch_params.py,sha256=JdXDZapv7kRYYgU5Stltyagtw4PPuCZLUy7Qo8019bQ,1329
|
|
148
148
|
scale_gp_beta/types/span_upsert_batch_response.py,sha256=Gkndmd_cyfodeGaCJu4sF4TsgB22hgHVlmoek3e_Kkc,366
|
|
149
|
+
scale_gp_beta/types/stream_chunk.py,sha256=3D9ElvLwGCPwvymBiLClUs3fhGXIoNTXx0TiS7C91iI,276
|
|
149
150
|
scale_gp_beta/types/chat/__init__.py,sha256=YmEJo3C_C7aRkImUaKB5BG97oOGkV0q3sHimL8cMa4g,688
|
|
150
151
|
scale_gp_beta/types/chat/chat_completion.py,sha256=JM1meIbWU2ImWkSO2m78666ltpUgDzgj1RpN5y3EaZM,16335
|
|
151
152
|
scale_gp_beta/types/chat/chat_completion_chunk.py,sha256=w7kGJcwoGuj_wl9kEACNspEvy8RV-h1wlwMW3dhC-xY,12025
|
|
@@ -157,7 +158,7 @@ scale_gp_beta/types/chat/model_definition.py,sha256=OWcZ4StZ4K2wfL7FqHNK-HqxLjy9
|
|
|
157
158
|
scale_gp_beta/types/files/__init__.py,sha256=OKfJYcKb4NObdiRObqJV_dOyDQ8feXekDUge2o_4pXQ,122
|
|
158
159
|
scale_gp_beta/types/shared/__init__.py,sha256=6-walu4YgOTaOj7wsidywTj67PyBJaNYFqasfiTP9-4,130
|
|
159
160
|
scale_gp_beta/types/shared/identity.py,sha256=4XDoJjsPI4lkwyaYyNstw7OunIzJjVWujPoZPrNdoQA,348
|
|
160
|
-
scale_gp_beta-0.1.
|
|
161
|
-
scale_gp_beta-0.1.
|
|
162
|
-
scale_gp_beta-0.1.
|
|
163
|
-
scale_gp_beta-0.1.
|
|
161
|
+
scale_gp_beta-0.1.0a42.dist-info/METADATA,sha256=r3OH5p8Riqmmud4qooNUGofX-AGyFBEcEVWPt0_sbok,30328
|
|
162
|
+
scale_gp_beta-0.1.0a42.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
163
|
+
scale_gp_beta-0.1.0a42.dist-info/licenses/LICENSE,sha256=LvNy55OMOsNOGUqjHCwQ6uYO0IuU9LJp1CJRpoz0abY,11338
|
|
164
|
+
scale_gp_beta-0.1.0a42.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|