Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 71cee6a

Browse files
authored
Fix FineTune.stream_events (openai#176)
We incorrectly changed the original method to be async rather than making a new async version. This PR fixes that. Fixes 173.
1 parent 777c1c3 commit 71cee6a

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

openai/api_resources/fine_tune.py

+39-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,45 @@ def _prepare_stream_events(
128128
return requestor, url
129129

130130
@classmethod
131-
async def stream_events(
131+
def stream_events(
132+
cls,
133+
id,
134+
api_key=None,
135+
api_base=None,
136+
api_type=None,
137+
request_id=None,
138+
api_version=None,
139+
organization=None,
140+
**params,
141+
):
142+
requestor, url = cls._prepare_stream_events(
143+
id,
144+
api_key,
145+
api_base,
146+
api_type,
147+
request_id,
148+
api_version,
149+
organization,
150+
**params,
151+
)
152+
153+
response, _, api_key = requestor.request(
154+
"get", url, params, stream=True, request_id=request_id
155+
)
156+
157+
assert not isinstance(response, OpenAIResponse) # must be an iterator
158+
return (
159+
util.convert_to_openai_object(
160+
line,
161+
api_key,
162+
api_version,
163+
organization,
164+
)
165+
for line in response
166+
)
167+
168+
@classmethod
169+
async def astream_events(
132170
cls,
133171
id,
134172
api_key=None,

0 commit comments

Comments
 (0)