studyfetch-sdk 0.1.0a19__py3-none-any.whl → 0.1.0a21__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.
- studyfetch_sdk/_models.py +23 -2
- studyfetch_sdk/_version.py +1 -1
- studyfetch_sdk/resources/v1/__init__.py +6 -104
- studyfetch_sdk/resources/v1/chat.py +246 -0
- studyfetch_sdk/resources/v1/materials/materials.py +304 -0
- studyfetch_sdk/resources/v1/materials/upload.py +30 -14
- studyfetch_sdk/resources/v1/v1.py +20 -244
- studyfetch_sdk/types/v1/__init__.py +3 -22
- studyfetch_sdk/types/v1/chat_stream_params.py +39 -7
- studyfetch_sdk/types/v1/component_create_params.py +24 -0
- studyfetch_sdk/types/v1/component_generate_embed_params.py +7 -1
- studyfetch_sdk/types/v1/generated_material.py +65 -0
- studyfetch_sdk/types/v1/material_generate_and_process_params.py +38 -0
- studyfetch_sdk/types/v1/material_generate_params.py +32 -0
- studyfetch_sdk/types/v1/materials/upload_complete_upload_params.py +2 -5
- studyfetch_sdk/types/v1/materials/upload_create_presigned_url_params.py +3 -0
- studyfetch_sdk/types/v1/materials/upload_upload_file_and_process_params.py +4 -1
- studyfetch_sdk/types/v1/materials/upload_upload_file_params.py +3 -0
- {studyfetch_sdk-0.1.0a19.dist-info → studyfetch_sdk-0.1.0a21.dist-info}/METADATA +1 -1
- {studyfetch_sdk-0.1.0a19.dist-info → studyfetch_sdk-0.1.0a21.dist-info}/RECORD +22 -83
- studyfetch_sdk/resources/v1/audio_recaps/__init__.py +0 -33
- studyfetch_sdk/resources/v1/audio_recaps/audio_recaps.py +0 -328
- studyfetch_sdk/resources/v1/audio_recaps/sections.py +0 -250
- studyfetch_sdk/resources/v1/chat/__init__.py +0 -47
- studyfetch_sdk/resources/v1/chat/chat.py +0 -574
- studyfetch_sdk/resources/v1/chat/sessions.py +0 -222
- studyfetch_sdk/resources/v1/chat/test.py +0 -190
- studyfetch_sdk/resources/v1/data_analyst/__init__.py +0 -47
- studyfetch_sdk/resources/v1/data_analyst/data_analyst.py +0 -582
- studyfetch_sdk/resources/v1/data_analyst/sessions.py +0 -222
- studyfetch_sdk/resources/v1/data_analyst/test.py +0 -190
- studyfetch_sdk/resources/v1/explainers.py +0 -441
- studyfetch_sdk/resources/v1/flashcards.py +0 -783
- studyfetch_sdk/resources/v1/scenarios/__init__.py +0 -61
- studyfetch_sdk/resources/v1/scenarios/component.py +0 -426
- studyfetch_sdk/resources/v1/scenarios/scenarios.py +0 -936
- studyfetch_sdk/resources/v1/scenarios/sessions.py +0 -236
- studyfetch_sdk/resources/v1/scenarios/submissions/__init__.py +0 -33
- studyfetch_sdk/resources/v1/scenarios/submissions/submissions.py +0 -102
- studyfetch_sdk/resources/v1/scenarios/submissions/user.py +0 -210
- studyfetch_sdk/resources/v1/tests/__init__.py +0 -33
- studyfetch_sdk/resources/v1/tests/component.py +0 -160
- studyfetch_sdk/resources/v1/tests/tests.py +0 -682
- studyfetch_sdk/resources/v1/upload/__init__.py +0 -33
- studyfetch_sdk/resources/v1/upload/component.py +0 -572
- studyfetch_sdk/resources/v1/upload/upload.py +0 -102
- studyfetch_sdk/types/v1/audio_recaps/__init__.py +0 -3
- studyfetch_sdk/types/v1/chat/__init__.py +0 -5
- studyfetch_sdk/types/v1/chat/session_retrieve_params.py +0 -11
- studyfetch_sdk/types/v1/chat_get_session_params.py +0 -13
- studyfetch_sdk/types/v1/chat_send_message_params.py +0 -54
- studyfetch_sdk/types/v1/data_analyst/__init__.py +0 -5
- studyfetch_sdk/types/v1/data_analyst/session_retrieve_params.py +0 -11
- studyfetch_sdk/types/v1/data_analyst_retrieve_session_params.py +0 -13
- studyfetch_sdk/types/v1/data_analyst_send_message_params.py +0 -54
- studyfetch_sdk/types/v1/data_analyst_stream_params.py +0 -28
- studyfetch_sdk/types/v1/explainer_create_params.py +0 -45
- studyfetch_sdk/types/v1/explainer_handle_webhook_params.py +0 -53
- studyfetch_sdk/types/v1/flashcard_batch_process_params.py +0 -36
- studyfetch_sdk/types/v1/flashcard_batch_process_response.py +0 -39
- studyfetch_sdk/types/v1/flashcard_get_algorithm_response.py +0 -37
- studyfetch_sdk/types/v1/flashcard_get_all_params.py +0 -23
- studyfetch_sdk/types/v1/flashcard_get_due_params.py +0 -19
- studyfetch_sdk/types/v1/flashcard_get_stats_params.py +0 -17
- studyfetch_sdk/types/v1/flashcard_get_types_response.py +0 -14
- studyfetch_sdk/types/v1/flashcard_rate_params.py +0 -23
- studyfetch_sdk/types/v1/scenario_create_params.py +0 -48
- studyfetch_sdk/types/v1/scenario_submit_answer_params.py +0 -18
- studyfetch_sdk/types/v1/scenario_update_params.py +0 -45
- studyfetch_sdk/types/v1/scenarios/__init__.py +0 -5
- studyfetch_sdk/types/v1/scenarios/component_update_params.py +0 -45
- studyfetch_sdk/types/v1/scenarios/submissions/__init__.py +0 -3
- studyfetch_sdk/types/v1/test_create_params.py +0 -20
- studyfetch_sdk/types/v1/test_retake_params.py +0 -14
- studyfetch_sdk/types/v1/test_submit_answer_params.py +0 -20
- studyfetch_sdk/types/v1/test_submit_params.py +0 -14
- studyfetch_sdk/types/v1/tests/__init__.py +0 -3
- studyfetch_sdk/types/v1/upload/__init__.py +0 -11
- studyfetch_sdk/types/v1/upload/component_complete_upload_params.py +0 -20
- studyfetch_sdk/types/v1/upload/component_complete_upload_response.py +0 -16
- studyfetch_sdk/types/v1/upload/component_get_presigned_url_params.py +0 -23
- studyfetch_sdk/types/v1/upload/component_get_presigned_url_response.py +0 -15
- studyfetch_sdk/types/v1/upload/component_upload_file_params.py +0 -21
- studyfetch_sdk/types/v1/upload/component_upload_url_params.py +0 -23
- studyfetch_sdk/types/v1/upload/file_upload_response.py +0 -24
- {studyfetch_sdk-0.1.0a19.dist-info → studyfetch_sdk-0.1.0a21.dist-info}/WHEEL +0 -0
- {studyfetch_sdk-0.1.0a19.dist-info → studyfetch_sdk-0.1.0a21.dist-info}/licenses/LICENSE +0 -0
studyfetch_sdk/_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] =
|
219
|
+
_extra[key] = parsed
|
216
220
|
else:
|
217
221
|
_fields_set.add(key)
|
218
|
-
fields_values[key] =
|
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_):
|
studyfetch_sdk/_version.py
CHANGED
@@ -24,14 +24,6 @@ from .embed import (
|
|
24
24
|
EmbedResourceWithStreamingResponse,
|
25
25
|
AsyncEmbedResourceWithStreamingResponse,
|
26
26
|
)
|
27
|
-
from .tests import (
|
28
|
-
TestsResource,
|
29
|
-
AsyncTestsResource,
|
30
|
-
TestsResourceWithRawResponse,
|
31
|
-
AsyncTestsResourceWithRawResponse,
|
32
|
-
TestsResourceWithStreamingResponse,
|
33
|
-
AsyncTestsResourceWithStreamingResponse,
|
34
|
-
)
|
35
27
|
from .usage import (
|
36
28
|
UsageResource,
|
37
29
|
AsyncUsageResource,
|
@@ -40,14 +32,6 @@ from .usage import (
|
|
40
32
|
UsageResourceWithStreamingResponse,
|
41
33
|
AsyncUsageResourceWithStreamingResponse,
|
42
34
|
)
|
43
|
-
from .upload import (
|
44
|
-
UploadResource,
|
45
|
-
AsyncUploadResource,
|
46
|
-
UploadResourceWithRawResponse,
|
47
|
-
AsyncUploadResourceWithRawResponse,
|
48
|
-
UploadResourceWithStreamingResponse,
|
49
|
-
AsyncUploadResourceWithStreamingResponse,
|
50
|
-
)
|
51
35
|
from .folders import (
|
52
36
|
FoldersResource,
|
53
37
|
AsyncFoldersResource,
|
@@ -64,14 +48,6 @@ from .materials import (
|
|
64
48
|
MaterialsResourceWithStreamingResponse,
|
65
49
|
AsyncMaterialsResourceWithStreamingResponse,
|
66
50
|
)
|
67
|
-
from .scenarios import (
|
68
|
-
ScenariosResource,
|
69
|
-
AsyncScenariosResource,
|
70
|
-
ScenariosResourceWithRawResponse,
|
71
|
-
AsyncScenariosResourceWithRawResponse,
|
72
|
-
ScenariosResourceWithStreamingResponse,
|
73
|
-
AsyncScenariosResourceWithStreamingResponse,
|
74
|
-
)
|
75
51
|
from .components import (
|
76
52
|
ComponentsResource,
|
77
53
|
AsyncComponentsResource,
|
@@ -80,38 +56,6 @@ from .components import (
|
|
80
56
|
ComponentsResourceWithStreamingResponse,
|
81
57
|
AsyncComponentsResourceWithStreamingResponse,
|
82
58
|
)
|
83
|
-
from .explainers import (
|
84
|
-
ExplainersResource,
|
85
|
-
AsyncExplainersResource,
|
86
|
-
ExplainersResourceWithRawResponse,
|
87
|
-
AsyncExplainersResourceWithRawResponse,
|
88
|
-
ExplainersResourceWithStreamingResponse,
|
89
|
-
AsyncExplainersResourceWithStreamingResponse,
|
90
|
-
)
|
91
|
-
from .flashcards import (
|
92
|
-
FlashcardsResource,
|
93
|
-
AsyncFlashcardsResource,
|
94
|
-
FlashcardsResourceWithRawResponse,
|
95
|
-
AsyncFlashcardsResourceWithRawResponse,
|
96
|
-
FlashcardsResourceWithStreamingResponse,
|
97
|
-
AsyncFlashcardsResourceWithStreamingResponse,
|
98
|
-
)
|
99
|
-
from .audio_recaps import (
|
100
|
-
AudioRecapsResource,
|
101
|
-
AsyncAudioRecapsResource,
|
102
|
-
AudioRecapsResourceWithRawResponse,
|
103
|
-
AsyncAudioRecapsResourceWithRawResponse,
|
104
|
-
AudioRecapsResourceWithStreamingResponse,
|
105
|
-
AsyncAudioRecapsResourceWithStreamingResponse,
|
106
|
-
)
|
107
|
-
from .data_analyst import (
|
108
|
-
DataAnalystResource,
|
109
|
-
AsyncDataAnalystResource,
|
110
|
-
DataAnalystResourceWithRawResponse,
|
111
|
-
AsyncDataAnalystResourceWithRawResponse,
|
112
|
-
DataAnalystResourceWithStreamingResponse,
|
113
|
-
AsyncDataAnalystResourceWithStreamingResponse,
|
114
|
-
)
|
115
59
|
from .assignment_grader import (
|
116
60
|
AssignmentGraderResource,
|
117
61
|
AsyncAssignmentGraderResource,
|
@@ -152,60 +96,18 @@ __all__ = [
|
|
152
96
|
"AsyncEmbedResourceWithRawResponse",
|
153
97
|
"EmbedResourceWithStreamingResponse",
|
154
98
|
"AsyncEmbedResourceWithStreamingResponse",
|
155
|
-
"ChatResource",
|
156
|
-
"AsyncChatResource",
|
157
|
-
"ChatResourceWithRawResponse",
|
158
|
-
"AsyncChatResourceWithRawResponse",
|
159
|
-
"ChatResourceWithStreamingResponse",
|
160
|
-
"AsyncChatResourceWithStreamingResponse",
|
161
|
-
"TestsResource",
|
162
|
-
"AsyncTestsResource",
|
163
|
-
"TestsResourceWithRawResponse",
|
164
|
-
"AsyncTestsResourceWithRawResponse",
|
165
|
-
"TestsResourceWithStreamingResponse",
|
166
|
-
"AsyncTestsResourceWithStreamingResponse",
|
167
|
-
"AudioRecapsResource",
|
168
|
-
"AsyncAudioRecapsResource",
|
169
|
-
"AudioRecapsResourceWithRawResponse",
|
170
|
-
"AsyncAudioRecapsResourceWithRawResponse",
|
171
|
-
"AudioRecapsResourceWithStreamingResponse",
|
172
|
-
"AsyncAudioRecapsResourceWithStreamingResponse",
|
173
|
-
"FlashcardsResource",
|
174
|
-
"AsyncFlashcardsResource",
|
175
|
-
"FlashcardsResourceWithRawResponse",
|
176
|
-
"AsyncFlashcardsResourceWithRawResponse",
|
177
|
-
"FlashcardsResourceWithStreamingResponse",
|
178
|
-
"AsyncFlashcardsResourceWithStreamingResponse",
|
179
|
-
"ScenariosResource",
|
180
|
-
"AsyncScenariosResource",
|
181
|
-
"ScenariosResourceWithRawResponse",
|
182
|
-
"AsyncScenariosResourceWithRawResponse",
|
183
|
-
"ScenariosResourceWithStreamingResponse",
|
184
|
-
"AsyncScenariosResourceWithStreamingResponse",
|
185
|
-
"ExplainersResource",
|
186
|
-
"AsyncExplainersResource",
|
187
|
-
"ExplainersResourceWithRawResponse",
|
188
|
-
"AsyncExplainersResourceWithRawResponse",
|
189
|
-
"ExplainersResourceWithStreamingResponse",
|
190
|
-
"AsyncExplainersResourceWithStreamingResponse",
|
191
|
-
"UploadResource",
|
192
|
-
"AsyncUploadResource",
|
193
|
-
"UploadResourceWithRawResponse",
|
194
|
-
"AsyncUploadResourceWithRawResponse",
|
195
|
-
"UploadResourceWithStreamingResponse",
|
196
|
-
"AsyncUploadResourceWithStreamingResponse",
|
197
99
|
"AssignmentGraderResource",
|
198
100
|
"AsyncAssignmentGraderResource",
|
199
101
|
"AssignmentGraderResourceWithRawResponse",
|
200
102
|
"AsyncAssignmentGraderResourceWithRawResponse",
|
201
103
|
"AssignmentGraderResourceWithStreamingResponse",
|
202
104
|
"AsyncAssignmentGraderResourceWithStreamingResponse",
|
203
|
-
"
|
204
|
-
"
|
205
|
-
"
|
206
|
-
"
|
207
|
-
"
|
208
|
-
"
|
105
|
+
"ChatResource",
|
106
|
+
"AsyncChatResource",
|
107
|
+
"ChatResourceWithRawResponse",
|
108
|
+
"AsyncChatResourceWithRawResponse",
|
109
|
+
"ChatResourceWithStreamingResponse",
|
110
|
+
"AsyncChatResourceWithStreamingResponse",
|
209
111
|
"V1Resource",
|
210
112
|
"AsyncV1Resource",
|
211
113
|
"V1ResourceWithRawResponse",
|
@@ -0,0 +1,246 @@
|
|
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 List
|
6
|
+
|
7
|
+
import httpx
|
8
|
+
|
9
|
+
from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
|
10
|
+
from ..._utils import maybe_transform, strip_not_given, async_maybe_transform
|
11
|
+
from ..._compat import cached_property
|
12
|
+
from ...types.v1 import chat_stream_params
|
13
|
+
from ..._resource import SyncAPIResource, AsyncAPIResource
|
14
|
+
from ..._response import (
|
15
|
+
to_raw_response_wrapper,
|
16
|
+
to_streamed_response_wrapper,
|
17
|
+
async_to_raw_response_wrapper,
|
18
|
+
async_to_streamed_response_wrapper,
|
19
|
+
)
|
20
|
+
from ..._base_client import make_request_options
|
21
|
+
|
22
|
+
__all__ = ["ChatResource", "AsyncChatResource"]
|
23
|
+
|
24
|
+
|
25
|
+
class ChatResource(SyncAPIResource):
|
26
|
+
@cached_property
|
27
|
+
def with_raw_response(self) -> ChatResourceWithRawResponse:
|
28
|
+
"""
|
29
|
+
This property can be used as a prefix for any HTTP method call to return
|
30
|
+
the raw response object instead of the parsed content.
|
31
|
+
|
32
|
+
For more information, see https://www.github.com/GoStudyFetchGo/studyfetch-sdk-python#accessing-raw-response-data-eg-headers
|
33
|
+
"""
|
34
|
+
return ChatResourceWithRawResponse(self)
|
35
|
+
|
36
|
+
@cached_property
|
37
|
+
def with_streaming_response(self) -> ChatResourceWithStreamingResponse:
|
38
|
+
"""
|
39
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
40
|
+
|
41
|
+
For more information, see https://www.github.com/GoStudyFetchGo/studyfetch-sdk-python#with_streaming_response
|
42
|
+
"""
|
43
|
+
return ChatResourceWithStreamingResponse(self)
|
44
|
+
|
45
|
+
def stream(
|
46
|
+
self,
|
47
|
+
*,
|
48
|
+
id: str | NotGiven = NOT_GIVEN,
|
49
|
+
component_id: str | NotGiven = NOT_GIVEN,
|
50
|
+
context: object | NotGiven = NOT_GIVEN,
|
51
|
+
group_ids: List[str] | NotGiven = NOT_GIVEN,
|
52
|
+
message: chat_stream_params.Message | NotGiven = NOT_GIVEN,
|
53
|
+
messages: List[str] | NotGiven = NOT_GIVEN,
|
54
|
+
session_id: str | NotGiven = NOT_GIVEN,
|
55
|
+
user_id: str | NotGiven = NOT_GIVEN,
|
56
|
+
x_component_id: str | NotGiven = NOT_GIVEN,
|
57
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
58
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
59
|
+
extra_headers: Headers | None = None,
|
60
|
+
extra_query: Query | None = None,
|
61
|
+
extra_body: Body | None = None,
|
62
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
63
|
+
) -> None:
|
64
|
+
"""Streams a chat response in real-time using server-sent events (SSE).
|
65
|
+
|
66
|
+
Supports
|
67
|
+
both AI SDK format (with messages array) and custom format (with message
|
68
|
+
object).
|
69
|
+
|
70
|
+
Args:
|
71
|
+
id: Session ID (AI SDK uses "id")
|
72
|
+
|
73
|
+
component_id: Component ID
|
74
|
+
|
75
|
+
context: Additional context
|
76
|
+
|
77
|
+
group_ids: Group IDs for access control
|
78
|
+
|
79
|
+
message: Single message for custom format - contains text and optional images
|
80
|
+
|
81
|
+
messages: Messages array for AI SDK format - list of conversation messages with roles
|
82
|
+
|
83
|
+
session_id: Session ID
|
84
|
+
|
85
|
+
user_id: User ID
|
86
|
+
|
87
|
+
extra_headers: Send extra headers
|
88
|
+
|
89
|
+
extra_query: Add additional query parameters to the request
|
90
|
+
|
91
|
+
extra_body: Add additional JSON properties to the request
|
92
|
+
|
93
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
94
|
+
"""
|
95
|
+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
96
|
+
extra_headers = {**strip_not_given({"x-component-id": x_component_id}), **(extra_headers or {})}
|
97
|
+
return self._post(
|
98
|
+
"/api/v1/chat/stream",
|
99
|
+
body=maybe_transform(
|
100
|
+
{
|
101
|
+
"id": id,
|
102
|
+
"component_id": component_id,
|
103
|
+
"context": context,
|
104
|
+
"group_ids": group_ids,
|
105
|
+
"message": message,
|
106
|
+
"messages": messages,
|
107
|
+
"session_id": session_id,
|
108
|
+
"user_id": user_id,
|
109
|
+
},
|
110
|
+
chat_stream_params.ChatStreamParams,
|
111
|
+
),
|
112
|
+
options=make_request_options(
|
113
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
114
|
+
),
|
115
|
+
cast_to=NoneType,
|
116
|
+
)
|
117
|
+
|
118
|
+
|
119
|
+
class AsyncChatResource(AsyncAPIResource):
|
120
|
+
@cached_property
|
121
|
+
def with_raw_response(self) -> AsyncChatResourceWithRawResponse:
|
122
|
+
"""
|
123
|
+
This property can be used as a prefix for any HTTP method call to return
|
124
|
+
the raw response object instead of the parsed content.
|
125
|
+
|
126
|
+
For more information, see https://www.github.com/GoStudyFetchGo/studyfetch-sdk-python#accessing-raw-response-data-eg-headers
|
127
|
+
"""
|
128
|
+
return AsyncChatResourceWithRawResponse(self)
|
129
|
+
|
130
|
+
@cached_property
|
131
|
+
def with_streaming_response(self) -> AsyncChatResourceWithStreamingResponse:
|
132
|
+
"""
|
133
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
134
|
+
|
135
|
+
For more information, see https://www.github.com/GoStudyFetchGo/studyfetch-sdk-python#with_streaming_response
|
136
|
+
"""
|
137
|
+
return AsyncChatResourceWithStreamingResponse(self)
|
138
|
+
|
139
|
+
async def stream(
|
140
|
+
self,
|
141
|
+
*,
|
142
|
+
id: str | NotGiven = NOT_GIVEN,
|
143
|
+
component_id: str | NotGiven = NOT_GIVEN,
|
144
|
+
context: object | NotGiven = NOT_GIVEN,
|
145
|
+
group_ids: List[str] | NotGiven = NOT_GIVEN,
|
146
|
+
message: chat_stream_params.Message | NotGiven = NOT_GIVEN,
|
147
|
+
messages: List[str] | NotGiven = NOT_GIVEN,
|
148
|
+
session_id: str | NotGiven = NOT_GIVEN,
|
149
|
+
user_id: str | NotGiven = NOT_GIVEN,
|
150
|
+
x_component_id: str | NotGiven = NOT_GIVEN,
|
151
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
152
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
153
|
+
extra_headers: Headers | None = None,
|
154
|
+
extra_query: Query | None = None,
|
155
|
+
extra_body: Body | None = None,
|
156
|
+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
157
|
+
) -> None:
|
158
|
+
"""Streams a chat response in real-time using server-sent events (SSE).
|
159
|
+
|
160
|
+
Supports
|
161
|
+
both AI SDK format (with messages array) and custom format (with message
|
162
|
+
object).
|
163
|
+
|
164
|
+
Args:
|
165
|
+
id: Session ID (AI SDK uses "id")
|
166
|
+
|
167
|
+
component_id: Component ID
|
168
|
+
|
169
|
+
context: Additional context
|
170
|
+
|
171
|
+
group_ids: Group IDs for access control
|
172
|
+
|
173
|
+
message: Single message for custom format - contains text and optional images
|
174
|
+
|
175
|
+
messages: Messages array for AI SDK format - list of conversation messages with roles
|
176
|
+
|
177
|
+
session_id: Session ID
|
178
|
+
|
179
|
+
user_id: User ID
|
180
|
+
|
181
|
+
extra_headers: Send extra headers
|
182
|
+
|
183
|
+
extra_query: Add additional query parameters to the request
|
184
|
+
|
185
|
+
extra_body: Add additional JSON properties to the request
|
186
|
+
|
187
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
188
|
+
"""
|
189
|
+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
190
|
+
extra_headers = {**strip_not_given({"x-component-id": x_component_id}), **(extra_headers or {})}
|
191
|
+
return await self._post(
|
192
|
+
"/api/v1/chat/stream",
|
193
|
+
body=await async_maybe_transform(
|
194
|
+
{
|
195
|
+
"id": id,
|
196
|
+
"component_id": component_id,
|
197
|
+
"context": context,
|
198
|
+
"group_ids": group_ids,
|
199
|
+
"message": message,
|
200
|
+
"messages": messages,
|
201
|
+
"session_id": session_id,
|
202
|
+
"user_id": user_id,
|
203
|
+
},
|
204
|
+
chat_stream_params.ChatStreamParams,
|
205
|
+
),
|
206
|
+
options=make_request_options(
|
207
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
208
|
+
),
|
209
|
+
cast_to=NoneType,
|
210
|
+
)
|
211
|
+
|
212
|
+
|
213
|
+
class ChatResourceWithRawResponse:
|
214
|
+
def __init__(self, chat: ChatResource) -> None:
|
215
|
+
self._chat = chat
|
216
|
+
|
217
|
+
self.stream = to_raw_response_wrapper(
|
218
|
+
chat.stream,
|
219
|
+
)
|
220
|
+
|
221
|
+
|
222
|
+
class AsyncChatResourceWithRawResponse:
|
223
|
+
def __init__(self, chat: AsyncChatResource) -> None:
|
224
|
+
self._chat = chat
|
225
|
+
|
226
|
+
self.stream = async_to_raw_response_wrapper(
|
227
|
+
chat.stream,
|
228
|
+
)
|
229
|
+
|
230
|
+
|
231
|
+
class ChatResourceWithStreamingResponse:
|
232
|
+
def __init__(self, chat: ChatResource) -> None:
|
233
|
+
self._chat = chat
|
234
|
+
|
235
|
+
self.stream = to_streamed_response_wrapper(
|
236
|
+
chat.stream,
|
237
|
+
)
|
238
|
+
|
239
|
+
|
240
|
+
class AsyncChatResourceWithStreamingResponse:
|
241
|
+
def __init__(self, chat: AsyncChatResource) -> None:
|
242
|
+
self._chat = chat
|
243
|
+
|
244
|
+
self.stream = async_to_streamed_response_wrapper(
|
245
|
+
chat.stream,
|
246
|
+
)
|