You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ifline.startswith("data: "): # Only process lines starting with "data: "
137
151
json_part=line[len("data: "):] # Remove the "data: " prefix
138
-
ifjson_part.strip() =="[DONE]": # Ignore the DONE marker
139
-
continue
140
-
try:
141
-
json_obj=json.loads(json_part) # Convert to dictionary
142
-
if"choices"injson_obj:
143
-
forchoiceinjson_obj["choices"]:
144
-
if"text"inchoice:
145
-
# Yield each token individually
146
-
yieldchoice["text"]
147
-
exceptjson.JSONDecodeError:
148
-
print("Error parsing JSON:", json_part)
152
+
else:
153
+
json_part=line
154
+
ifjson_part.strip() =="[DONE]": # Ignore the DONE marker
155
+
continue
156
+
try:
157
+
json_obj=json.loads(json_part) # Convert to dictionary
158
+
if"choices"injson_obj:
159
+
forchoiceinjson_obj["choices"]:
160
+
if"text"inchoice:
161
+
# Yield each token individually
162
+
yieldchoice["text"]
163
+
exceptjson.JSONDecodeError:
164
+
print("Error parsing JSON:", json_part)
165
+
166
+
ifline_count==0:
167
+
yieldf"Something went wrong, No Response Generated! \nIf you are using an Index, try uploading your media again with a smaller chunk size to avoid exceeding the token max. \
0 commit comments