scale-gp-beta 0.1.0a29__py3-none-any.whl → 0.1.0a30__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 (38) hide show
  1. scale_gp_beta/_base_client.py +4 -1
  2. scale_gp_beta/_client.py +9 -0
  3. scale_gp_beta/_files.py +4 -4
  4. scale_gp_beta/_models.py +24 -3
  5. scale_gp_beta/_version.py +1 -1
  6. scale_gp_beta/lib/CONTRIBUTING.MD +53 -0
  7. scale_gp_beta/lib/tracing/trace_queue_manager.py +14 -0
  8. scale_gp_beta/resources/__init__.py +14 -0
  9. scale_gp_beta/resources/chat/completions.py +4 -0
  10. scale_gp_beta/resources/responses.py +314 -0
  11. scale_gp_beta/resources/spans.py +14 -22
  12. scale_gp_beta/types/__init__.py +17 -0
  13. scale_gp_beta/types/chat/chat_completion.py +61 -6
  14. scale_gp_beta/types/chat/chat_completion_chunk.py +17 -1
  15. scale_gp_beta/types/chat/completion_models_params.py +2 -0
  16. scale_gp_beta/types/chat/model_definition.py +6 -0
  17. scale_gp_beta/types/completion.py +8 -0
  18. scale_gp_beta/types/container.py +0 -6
  19. scale_gp_beta/types/dataset.py +3 -1
  20. scale_gp_beta/types/dataset_item.py +3 -1
  21. scale_gp_beta/types/evaluation.py +3 -7
  22. scale_gp_beta/types/evaluation_item.py +3 -1
  23. scale_gp_beta/types/evaluation_task.py +31 -55
  24. scale_gp_beta/types/evaluation_task_param.py +28 -1
  25. scale_gp_beta/types/file.py +3 -1
  26. scale_gp_beta/types/inference_model.py +3 -0
  27. scale_gp_beta/types/question.py +11 -10
  28. scale_gp_beta/types/response.py +2852 -0
  29. scale_gp_beta/types/response_create_params.py +817 -0
  30. scale_gp_beta/types/response_create_response.py +20891 -0
  31. scale_gp_beta/types/shared/__init__.py +3 -0
  32. scale_gp_beta/types/shared/identity.py +16 -0
  33. scale_gp_beta/types/span.py +4 -2
  34. scale_gp_beta/types/span_search_params.py +4 -7
  35. {scale_gp_beta-0.1.0a29.dist-info → scale_gp_beta-0.1.0a30.dist-info}/METADATA +2 -3
  36. {scale_gp_beta-0.1.0a29.dist-info → scale_gp_beta-0.1.0a30.dist-info}/RECORD +38 -31
  37. {scale_gp_beta-0.1.0a29.dist-info → scale_gp_beta-0.1.0a30.dist-info}/WHEEL +0 -0
  38. {scale_gp_beta-0.1.0a29.dist-info → scale_gp_beta-0.1.0a30.dist-info}/licenses/LICENSE +0 -0
@@ -532,7 +532,10 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
532
532
  is_body_allowed = options.method.lower() != "get"
533
533
 
534
534
  if is_body_allowed:
535
- kwargs["json"] = json_data if is_given(json_data) else None
535
+ if isinstance(json_data, bytes):
536
+ kwargs["content"] = json_data
537
+ else:
538
+ kwargs["json"] = json_data if is_given(json_data) else None
536
539
  kwargs["files"] = files
537
540
  else:
538
541
  headers.pop("Content-Type", None)
scale_gp_beta/_client.py CHANGED
@@ -27,6 +27,7 @@ from .resources import (
27
27
  datasets,
28
28
  inference,
29
29
  questions,
30
+ responses,
30
31
  completions,
31
32
  evaluations,
32
33
  dataset_items,
@@ -61,6 +62,7 @@ ENVIRONMENTS: Dict[str, str] = {
61
62
 
62
63
 
63
64
  class SGPClient(SyncAPIClient):
65
+ responses: responses.ResponsesResource
64
66
  completions: completions.CompletionsResource
65
67
  chat: chat.ChatResource
66
68
  inference: inference.InferenceResource
@@ -165,6 +167,7 @@ class SGPClient(SyncAPIClient):
165
167
  _strict_response_validation=_strict_response_validation,
166
168
  )
167
169
 
170
+ self.responses = responses.ResponsesResource(self)
168
171
  self.completions = completions.CompletionsResource(self)
169
172
  self.chat = chat.ChatResource(self)
170
173
  self.inference = inference.InferenceResource(self)
@@ -290,6 +293,7 @@ class SGPClient(SyncAPIClient):
290
293
 
291
294
 
292
295
  class AsyncSGPClient(AsyncAPIClient):
296
+ responses: responses.AsyncResponsesResource
293
297
  completions: completions.AsyncCompletionsResource
294
298
  chat: chat.AsyncChatResource
295
299
  inference: inference.AsyncInferenceResource
@@ -394,6 +398,7 @@ class AsyncSGPClient(AsyncAPIClient):
394
398
  _strict_response_validation=_strict_response_validation,
395
399
  )
396
400
 
401
+ self.responses = responses.AsyncResponsesResource(self)
397
402
  self.completions = completions.AsyncCompletionsResource(self)
398
403
  self.chat = chat.AsyncChatResource(self)
399
404
  self.inference = inference.AsyncInferenceResource(self)
@@ -520,6 +525,7 @@ class AsyncSGPClient(AsyncAPIClient):
520
525
 
521
526
  class SGPClientWithRawResponse:
522
527
  def __init__(self, client: SGPClient) -> None:
528
+ self.responses = responses.ResponsesResourceWithRawResponse(client.responses)
523
529
  self.completions = completions.CompletionsResourceWithRawResponse(client.completions)
524
530
  self.chat = chat.ChatResourceWithRawResponse(client.chat)
525
531
  self.inference = inference.InferenceResourceWithRawResponse(client.inference)
@@ -535,6 +541,7 @@ class SGPClientWithRawResponse:
535
541
 
536
542
  class AsyncSGPClientWithRawResponse:
537
543
  def __init__(self, client: AsyncSGPClient) -> None:
544
+ self.responses = responses.AsyncResponsesResourceWithRawResponse(client.responses)
538
545
  self.completions = completions.AsyncCompletionsResourceWithRawResponse(client.completions)
539
546
  self.chat = chat.AsyncChatResourceWithRawResponse(client.chat)
540
547
  self.inference = inference.AsyncInferenceResourceWithRawResponse(client.inference)
@@ -550,6 +557,7 @@ class AsyncSGPClientWithRawResponse:
550
557
 
551
558
  class SGPClientWithStreamedResponse:
552
559
  def __init__(self, client: SGPClient) -> None:
560
+ self.responses = responses.ResponsesResourceWithStreamingResponse(client.responses)
553
561
  self.completions = completions.CompletionsResourceWithStreamingResponse(client.completions)
554
562
  self.chat = chat.ChatResourceWithStreamingResponse(client.chat)
555
563
  self.inference = inference.InferenceResourceWithStreamingResponse(client.inference)
@@ -565,6 +573,7 @@ class SGPClientWithStreamedResponse:
565
573
 
566
574
  class AsyncSGPClientWithStreamedResponse:
567
575
  def __init__(self, client: AsyncSGPClient) -> None:
576
+ self.responses = responses.AsyncResponsesResourceWithStreamingResponse(client.responses)
568
577
  self.completions = completions.AsyncCompletionsResourceWithStreamingResponse(client.completions)
569
578
  self.chat = chat.AsyncChatResourceWithStreamingResponse(client.chat)
570
579
  self.inference = inference.AsyncInferenceResourceWithStreamingResponse(client.inference)
scale_gp_beta/_files.py CHANGED
@@ -69,12 +69,12 @@ def _transform_file(file: FileTypes) -> HttpxFileTypes:
69
69
  return file
70
70
 
71
71
  if is_tuple_t(file):
72
- return (file[0], _read_file_content(file[1]), *file[2:])
72
+ return (file[0], read_file_content(file[1]), *file[2:])
73
73
 
74
74
  raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple")
75
75
 
76
76
 
77
- def _read_file_content(file: FileContent) -> HttpxFileContent:
77
+ def read_file_content(file: FileContent) -> HttpxFileContent:
78
78
  if isinstance(file, os.PathLike):
79
79
  return pathlib.Path(file).read_bytes()
80
80
  return file
@@ -111,12 +111,12 @@ async def _async_transform_file(file: FileTypes) -> HttpxFileTypes:
111
111
  return file
112
112
 
113
113
  if is_tuple_t(file):
114
- return (file[0], await _async_read_file_content(file[1]), *file[2:])
114
+ return (file[0], await async_read_file_content(file[1]), *file[2:])
115
115
 
116
116
  raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple")
117
117
 
118
118
 
119
- async def _async_read_file_content(file: FileContent) -> HttpxFileContent:
119
+ async def async_read_file_content(file: FileContent) -> HttpxFileContent:
120
120
  if isinstance(file, os.PathLike):
121
121
  return await anyio.Path(file).read_bytes()
122
122
 
scale_gp_beta/_models.py CHANGED
@@ -208,14 +208,18 @@ class BaseModel(pydantic.BaseModel):
208
208
  else:
209
209
  fields_values[name] = field_get_default(field)
210
210
 
211
+ extra_field_type = _get_extra_fields_type(__cls)
212
+
211
213
  _extra = {}
212
214
  for key, value in values.items():
213
215
  if key not in model_fields:
216
+ parsed = construct_type(value=value, type_=extra_field_type) if extra_field_type is not None else value
217
+
214
218
  if PYDANTIC_V2:
215
- _extra[key] = value
219
+ _extra[key] = parsed
216
220
  else:
217
221
  _fields_set.add(key)
218
- fields_values[key] = value
222
+ fields_values[key] = parsed
219
223
 
220
224
  object.__setattr__(m, "__dict__", fields_values)
221
225
 
@@ -370,6 +374,23 @@ def _construct_field(value: object, field: FieldInfo, key: str) -> object:
370
374
  return construct_type(value=value, type_=type_, metadata=getattr(field, "metadata", None))
371
375
 
372
376
 
377
+ def _get_extra_fields_type(cls: type[pydantic.BaseModel]) -> type | None:
378
+ if not PYDANTIC_V2:
379
+ # TODO
380
+ return None
381
+
382
+ schema = cls.__pydantic_core_schema__
383
+ if schema["type"] == "model":
384
+ fields = schema["schema"]
385
+ if fields["type"] == "model-fields":
386
+ extras = fields.get("extras_schema")
387
+ if extras and "cls" in extras:
388
+ # mypy can't narrow the type
389
+ return extras["cls"] # type: ignore[no-any-return]
390
+
391
+ return None
392
+
393
+
373
394
  def is_basemodel(type_: type) -> bool:
374
395
  """Returns whether or not the given type is either a `BaseModel` or a union of `BaseModel`"""
375
396
  if is_union(type_):
@@ -439,7 +460,7 @@ def construct_type(*, value: object, type_: object, metadata: Optional[List[Any]
439
460
  type_ = type_.__value__ # type: ignore[unreachable]
440
461
 
441
462
  # unwrap `Annotated[T, ...]` -> `T`
442
- if metadata is not None:
463
+ if metadata is not None and len(metadata) > 0:
443
464
  meta: tuple[Any, ...] = tuple(metadata)
444
465
  elif is_annotated_type(type_):
445
466
  meta = get_args(type_)[1:]
scale_gp_beta/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "scale_gp_beta"
4
- __version__ = "0.1.0-alpha.29" # x-release-please-version
4
+ __version__ = "0.1.0-alpha.30" # x-release-please-version
@@ -0,0 +1,53 @@
1
+ # Custom Code Patch
2
+ You can in theory add custom code patches to anywhere in the repo but at the risk of encountering many merge conflicts with Stainless into the future.
3
+ Stainless will never use the `/lib` and `/examples` directories. When possible try to only modify these directories.
4
+ If you have to add custom code elsewhere, please keep the footprint small and create a library for most of the logic.
5
+
6
+
7
+ For information on custom code patching with Stainless see [here](https://www.stainless.com/docs/guides/add-custom-code).
8
+
9
+ # Process for Adding Features
10
+ Checkout the `next` branch and pull, then create a branch from `next`.
11
+
12
+ > **_NOTE:_** Stainless uses next to "queue up" updates to the SDK.
13
+ >
14
+ > Stainless will update next with their own logic updates to the SDK along with any changes in the OpenAPI spec and changes to the Stainless
15
+ config on their SaaS platform.
16
+
17
+ Make any code changes you need. Ensuring all the tests for the library are passing.
18
+
19
+ There is strict linting in this repo. Use the following commands in order.
20
+
21
+ ```bash
22
+ rye lint --fix
23
+ ```
24
+
25
+ ```bash
26
+ rye run lint | grep /specific_file.py
27
+ ```
28
+
29
+ `rye run lint` will not work if there are errors with `rye lint --fix`.
30
+ I am unsure why but I get many errors which are ignorable in the rest of the repo when running `rye run lint` so I usually use it
31
+ with grep to target the file I am developing.
32
+
33
+ > **_NOTE:_** The strict linting requires all types to be strictly typed. This can be a pain but is worth considering before developing any new solution.
34
+ > Try and avoid using ignore commands when possible, but sometimes it is unavoidable (see OpenAI tracing Plugin).
35
+
36
+ When commiting, use the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec. Usually this is something like:
37
+
38
+ ```bash
39
+ git commit -m "feat: Added OpenAI tracing processor"
40
+ ```
41
+ This allow Stainless to update the release doc with more useful info.
42
+
43
+ **When creating a PR, you must manually change the destination from `main` to `next`.**
44
+
45
+ Once merged, Stainless should pick up the changes and update or create a new PR for `main`.
46
+ You will need to accept changes on this PR, Stainless should then auto merge. Note on occasion I have had to manually merge.
47
+ There was no consequence to this.
48
+
49
+ These PRs Stainless makes have 4 types of changes, all are merged to main via these automatic PR requests:
50
+ 1. Custom Code Changes
51
+ 2. Stainless SDK logic changes
52
+ 3. Changes to the Stainless Config in the SaaS platform
53
+ 4. Changes to the OpenAPI schema
@@ -11,6 +11,8 @@ from .util import configure, is_disabled
11
11
  from .trace_exporter import TraceExporter
12
12
 
13
13
  if TYPE_CHECKING:
14
+ import httpx
15
+
14
16
  from .span import Span
15
17
  from .trace import Trace
16
18
 
@@ -44,6 +46,7 @@ class TraceQueueManager:
44
46
  worker_enabled: Optional[bool] = None,
45
47
  ):
46
48
  self._client = client
49
+ self.register_client(client) if client else None
47
50
  self._attempted_local_client_creation = False
48
51
  self._trigger_queue_size = trigger_queue_size
49
52
  self._trigger_cadence = trigger_cadence
@@ -68,6 +71,17 @@ class TraceQueueManager:
68
71
  log.info("Registering client")
69
72
  self._client = client
70
73
 
74
+ original_prepare_request = self._client._prepare_request
75
+
76
+ def custom_prepare_request(request: "httpx.Request") -> None:
77
+ original_prepare_request(request)
78
+
79
+ # TODO: Hook logic here, we should check to see if we are in the scope of a span, if so we should inject
80
+ # appropriate headers into the request
81
+ # current_span = Scope.get_current_span()
82
+
83
+ self._client._prepare_request = custom_prepare_request # type: ignore
84
+
71
85
  def shutdown(self, timeout: Optional[float] = None) -> None:
72
86
  if not self._worker_enabled:
73
87
  log.debug("No worker to shutdown")
@@ -56,6 +56,14 @@ from .questions import (
56
56
  QuestionsResourceWithStreamingResponse,
57
57
  AsyncQuestionsResourceWithStreamingResponse,
58
58
  )
59
+ from .responses import (
60
+ ResponsesResource,
61
+ AsyncResponsesResource,
62
+ ResponsesResourceWithRawResponse,
63
+ AsyncResponsesResourceWithRawResponse,
64
+ ResponsesResourceWithStreamingResponse,
65
+ AsyncResponsesResourceWithStreamingResponse,
66
+ )
59
67
  from .completions import (
60
68
  CompletionsResource,
61
69
  AsyncCompletionsResource,
@@ -90,6 +98,12 @@ from .evaluation_items import (
90
98
  )
91
99
 
92
100
  __all__ = [
101
+ "ResponsesResource",
102
+ "AsyncResponsesResource",
103
+ "ResponsesResourceWithRawResponse",
104
+ "AsyncResponsesResourceWithRawResponse",
105
+ "ResponsesResourceWithStreamingResponse",
106
+ "AsyncResponsesResourceWithStreamingResponse",
93
107
  "CompletionsResource",
94
108
  "AsyncCompletionsResource",
95
109
  "CompletionsResourceWithRawResponse",
@@ -522,6 +522,7 @@ class CompletionsResource(SyncAPIResource):
522
522
  def models(
523
523
  self,
524
524
  *,
525
+ check_availability: bool | NotGiven = NOT_GIVEN,
525
526
  ending_before: str | NotGiven = NOT_GIVEN,
526
527
  limit: int | NotGiven = NOT_GIVEN,
527
528
  model_vendor: Literal[
@@ -569,6 +570,7 @@ class CompletionsResource(SyncAPIResource):
569
570
  timeout=timeout,
570
571
  query=maybe_transform(
571
572
  {
573
+ "check_availability": check_availability,
572
574
  "ending_before": ending_before,
573
575
  "limit": limit,
574
576
  "model_vendor": model_vendor,
@@ -1077,6 +1079,7 @@ class AsyncCompletionsResource(AsyncAPIResource):
1077
1079
  async def models(
1078
1080
  self,
1079
1081
  *,
1082
+ check_availability: bool | NotGiven = NOT_GIVEN,
1080
1083
  ending_before: str | NotGiven = NOT_GIVEN,
1081
1084
  limit: int | NotGiven = NOT_GIVEN,
1082
1085
  model_vendor: Literal[
@@ -1124,6 +1127,7 @@ class AsyncCompletionsResource(AsyncAPIResource):
1124
1127
  timeout=timeout,
1125
1128
  query=await async_maybe_transform(
1126
1129
  {
1130
+ "check_availability": check_availability,
1127
1131
  "ending_before": ending_before,
1128
1132
  "limit": limit,
1129
1133
  "model_vendor": model_vendor,
@@ -0,0 +1,314 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, Dict, List, Union, Iterable, cast
6
+ from typing_extensions import Literal
7
+
8
+ import httpx
9
+
10
+ from ..types import response_create_params
11
+ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
12
+ from .._utils import maybe_transform, async_maybe_transform
13
+ from .._compat import cached_property
14
+ from .._resource import SyncAPIResource, AsyncAPIResource
15
+ from .._response import (
16
+ to_raw_response_wrapper,
17
+ to_streamed_response_wrapper,
18
+ async_to_raw_response_wrapper,
19
+ async_to_streamed_response_wrapper,
20
+ )
21
+ from .._base_client import make_request_options
22
+ from ..types.response_create_response import ResponseCreateResponse
23
+
24
+ __all__ = ["ResponsesResource", "AsyncResponsesResource"]
25
+
26
+
27
+ class ResponsesResource(SyncAPIResource):
28
+ @cached_property
29
+ def with_raw_response(self) -> ResponsesResourceWithRawResponse:
30
+ """
31
+ This property can be used as a prefix for any HTTP method call to return
32
+ the raw response object instead of the parsed content.
33
+
34
+ For more information, see https://www.github.com/scaleapi/sgp-python-beta#accessing-raw-response-data-eg-headers
35
+ """
36
+ return ResponsesResourceWithRawResponse(self)
37
+
38
+ @cached_property
39
+ def with_streaming_response(self) -> ResponsesResourceWithStreamingResponse:
40
+ """
41
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
42
+
43
+ For more information, see https://www.github.com/scaleapi/sgp-python-beta#with_streaming_response
44
+ """
45
+ return ResponsesResourceWithStreamingResponse(self)
46
+
47
+ def create(
48
+ self,
49
+ *,
50
+ input: Union[str, Iterable[response_create_params.InputUnionMember1]],
51
+ model: str,
52
+ include: List[str] | NotGiven = NOT_GIVEN,
53
+ instructions: str | NotGiven = NOT_GIVEN,
54
+ max_output_tokens: int | NotGiven = NOT_GIVEN,
55
+ metadata: Dict[str, object] | NotGiven = NOT_GIVEN,
56
+ parallel_tool_calls: bool | NotGiven = NOT_GIVEN,
57
+ previous_response_id: str | NotGiven = NOT_GIVEN,
58
+ reasoning: Dict[str, object] | NotGiven = NOT_GIVEN,
59
+ store: bool | NotGiven = NOT_GIVEN,
60
+ stream: bool | NotGiven = NOT_GIVEN,
61
+ temperature: float | NotGiven = NOT_GIVEN,
62
+ text: Dict[str, object] | NotGiven = NOT_GIVEN,
63
+ tool_choice: Union[str, Dict[str, object]] | NotGiven = NOT_GIVEN,
64
+ tools: Iterable[Dict[str, object]] | NotGiven = NOT_GIVEN,
65
+ top_p: float | NotGiven = NOT_GIVEN,
66
+ truncation: Literal["auto", "disabled"] | NotGiven = NOT_GIVEN,
67
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
68
+ # The extra values given here take precedence over values defined on the client or passed to this method.
69
+ extra_headers: Headers | None = None,
70
+ extra_query: Query | None = None,
71
+ extra_body: Body | None = None,
72
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
73
+ ) -> ResponseCreateResponse:
74
+ """
75
+ Responses
76
+
77
+ Args:
78
+ model: model specified as `model_vendor/model`, for example `openai/gpt-4o`
79
+
80
+ include: Which fields to include in the response
81
+
82
+ instructions: Instructions for the response generation
83
+
84
+ max_output_tokens: Maximum number of output tokens
85
+
86
+ metadata: Metadata for the response
87
+
88
+ parallel_tool_calls: Whether to enable parallel tool calls
89
+
90
+ previous_response_id: ID of the previous response for chaining
91
+
92
+ reasoning: Reasoning configuration for the response
93
+
94
+ store: Whether to store the response
95
+
96
+ stream: Whether to stream the response
97
+
98
+ temperature: Sampling temperature for randomness control
99
+
100
+ text: Text configuration parameters
101
+
102
+ tool_choice: Tool choice configuration
103
+
104
+ tools: Tools available for the response
105
+
106
+ top_p: Top-p sampling parameter
107
+
108
+ truncation: Truncation configuration
109
+
110
+ extra_headers: Send extra headers
111
+
112
+ extra_query: Add additional query parameters to the request
113
+
114
+ extra_body: Add additional JSON properties to the request
115
+
116
+ timeout: Override the client-level default timeout for this request, in seconds
117
+ """
118
+ return cast(
119
+ ResponseCreateResponse,
120
+ self._post(
121
+ "/v5/responses",
122
+ body=maybe_transform(
123
+ {
124
+ "input": input,
125
+ "model": model,
126
+ "include": include,
127
+ "instructions": instructions,
128
+ "max_output_tokens": max_output_tokens,
129
+ "metadata": metadata,
130
+ "parallel_tool_calls": parallel_tool_calls,
131
+ "previous_response_id": previous_response_id,
132
+ "reasoning": reasoning,
133
+ "store": store,
134
+ "stream": stream,
135
+ "temperature": temperature,
136
+ "text": text,
137
+ "tool_choice": tool_choice,
138
+ "tools": tools,
139
+ "top_p": top_p,
140
+ "truncation": truncation,
141
+ },
142
+ response_create_params.ResponseCreateParams,
143
+ ),
144
+ options=make_request_options(
145
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
146
+ ),
147
+ cast_to=cast(
148
+ Any, ResponseCreateResponse
149
+ ), # Union types cannot be passed in as arguments in the type system
150
+ ),
151
+ )
152
+
153
+
154
+ class AsyncResponsesResource(AsyncAPIResource):
155
+ @cached_property
156
+ def with_raw_response(self) -> AsyncResponsesResourceWithRawResponse:
157
+ """
158
+ This property can be used as a prefix for any HTTP method call to return
159
+ the raw response object instead of the parsed content.
160
+
161
+ For more information, see https://www.github.com/scaleapi/sgp-python-beta#accessing-raw-response-data-eg-headers
162
+ """
163
+ return AsyncResponsesResourceWithRawResponse(self)
164
+
165
+ @cached_property
166
+ def with_streaming_response(self) -> AsyncResponsesResourceWithStreamingResponse:
167
+ """
168
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
169
+
170
+ For more information, see https://www.github.com/scaleapi/sgp-python-beta#with_streaming_response
171
+ """
172
+ return AsyncResponsesResourceWithStreamingResponse(self)
173
+
174
+ async def create(
175
+ self,
176
+ *,
177
+ input: Union[str, Iterable[response_create_params.InputUnionMember1]],
178
+ model: str,
179
+ include: List[str] | NotGiven = NOT_GIVEN,
180
+ instructions: str | NotGiven = NOT_GIVEN,
181
+ max_output_tokens: int | NotGiven = NOT_GIVEN,
182
+ metadata: Dict[str, object] | NotGiven = NOT_GIVEN,
183
+ parallel_tool_calls: bool | NotGiven = NOT_GIVEN,
184
+ previous_response_id: str | NotGiven = NOT_GIVEN,
185
+ reasoning: Dict[str, object] | NotGiven = NOT_GIVEN,
186
+ store: bool | NotGiven = NOT_GIVEN,
187
+ stream: bool | NotGiven = NOT_GIVEN,
188
+ temperature: float | NotGiven = NOT_GIVEN,
189
+ text: Dict[str, object] | NotGiven = NOT_GIVEN,
190
+ tool_choice: Union[str, Dict[str, object]] | NotGiven = NOT_GIVEN,
191
+ tools: Iterable[Dict[str, object]] | NotGiven = NOT_GIVEN,
192
+ top_p: float | NotGiven = NOT_GIVEN,
193
+ truncation: Literal["auto", "disabled"] | NotGiven = NOT_GIVEN,
194
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
195
+ # The extra values given here take precedence over values defined on the client or passed to this method.
196
+ extra_headers: Headers | None = None,
197
+ extra_query: Query | None = None,
198
+ extra_body: Body | None = None,
199
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
200
+ ) -> ResponseCreateResponse:
201
+ """
202
+ Responses
203
+
204
+ Args:
205
+ model: model specified as `model_vendor/model`, for example `openai/gpt-4o`
206
+
207
+ include: Which fields to include in the response
208
+
209
+ instructions: Instructions for the response generation
210
+
211
+ max_output_tokens: Maximum number of output tokens
212
+
213
+ metadata: Metadata for the response
214
+
215
+ parallel_tool_calls: Whether to enable parallel tool calls
216
+
217
+ previous_response_id: ID of the previous response for chaining
218
+
219
+ reasoning: Reasoning configuration for the response
220
+
221
+ store: Whether to store the response
222
+
223
+ stream: Whether to stream the response
224
+
225
+ temperature: Sampling temperature for randomness control
226
+
227
+ text: Text configuration parameters
228
+
229
+ tool_choice: Tool choice configuration
230
+
231
+ tools: Tools available for the response
232
+
233
+ top_p: Top-p sampling parameter
234
+
235
+ truncation: Truncation configuration
236
+
237
+ extra_headers: Send extra headers
238
+
239
+ extra_query: Add additional query parameters to the request
240
+
241
+ extra_body: Add additional JSON properties to the request
242
+
243
+ timeout: Override the client-level default timeout for this request, in seconds
244
+ """
245
+ return cast(
246
+ ResponseCreateResponse,
247
+ await self._post(
248
+ "/v5/responses",
249
+ body=await async_maybe_transform(
250
+ {
251
+ "input": input,
252
+ "model": model,
253
+ "include": include,
254
+ "instructions": instructions,
255
+ "max_output_tokens": max_output_tokens,
256
+ "metadata": metadata,
257
+ "parallel_tool_calls": parallel_tool_calls,
258
+ "previous_response_id": previous_response_id,
259
+ "reasoning": reasoning,
260
+ "store": store,
261
+ "stream": stream,
262
+ "temperature": temperature,
263
+ "text": text,
264
+ "tool_choice": tool_choice,
265
+ "tools": tools,
266
+ "top_p": top_p,
267
+ "truncation": truncation,
268
+ },
269
+ response_create_params.ResponseCreateParams,
270
+ ),
271
+ options=make_request_options(
272
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
273
+ ),
274
+ cast_to=cast(
275
+ Any, ResponseCreateResponse
276
+ ), # Union types cannot be passed in as arguments in the type system
277
+ ),
278
+ )
279
+
280
+
281
+ class ResponsesResourceWithRawResponse:
282
+ def __init__(self, responses: ResponsesResource) -> None:
283
+ self._responses = responses
284
+
285
+ self.create = to_raw_response_wrapper(
286
+ responses.create,
287
+ )
288
+
289
+
290
+ class AsyncResponsesResourceWithRawResponse:
291
+ def __init__(self, responses: AsyncResponsesResource) -> None:
292
+ self._responses = responses
293
+
294
+ self.create = async_to_raw_response_wrapper(
295
+ responses.create,
296
+ )
297
+
298
+
299
+ class ResponsesResourceWithStreamingResponse:
300
+ def __init__(self, responses: ResponsesResource) -> None:
301
+ self._responses = responses
302
+
303
+ self.create = to_streamed_response_wrapper(
304
+ responses.create,
305
+ )
306
+
307
+
308
+ class AsyncResponsesResourceWithStreamingResponse:
309
+ def __init__(self, responses: AsyncResponsesResource) -> None:
310
+ self._responses = responses
311
+
312
+ self.create = async_to_streamed_response_wrapper(
313
+ responses.create,
314
+ )