Hansimov commited on
Commit
b40b5fc
1 Parent(s): 0183ff6

:boom: [Fix] Value of (delta_)content or content_type not assigned

Browse files
networks/huggingchat_streamer.py CHANGED
@@ -224,6 +224,9 @@ class HuggingchatStreamer:
224
  line = line.strip()
225
  if not line:
226
  continue
 
 
 
227
  try:
228
  data = json.loads(line, strict=False)
229
  msg_type = data.get("type")
 
224
  line = line.strip()
225
  if not line:
226
  continue
227
+
228
+ content = ""
229
+ content_type = "Completions"
230
  try:
231
  data = json.loads(line, strict=False)
232
  msg_type = data.get("type")
networks/huggingface_streamer.py CHANGED
@@ -22,6 +22,7 @@ class HuggingfaceStreamer:
22
  line = line.decode("utf-8")
23
  line = re.sub(r"data:\s*", "", line)
24
  data = json.loads(line)
 
25
  try:
26
  content = data["token"]["text"]
27
  except:
 
22
  line = line.decode("utf-8")
23
  line = re.sub(r"data:\s*", "", line)
24
  data = json.loads(line)
25
+ content = ""
26
  try:
27
  content = data["token"]["text"]
28
  except:
networks/openai_streamer.py CHANGED
@@ -203,6 +203,7 @@ class OpenaiStreamer:
203
  is_finished = True
204
  else:
205
  content_type = "Completions"
 
206
  try:
207
  data = json.loads(line, strict=False)
208
  message_role = data["message"]["author"]["role"]
 
203
  is_finished = True
204
  else:
205
  content_type = "Completions"
206
+ delta_content = ""
207
  try:
208
  data = json.loads(line, strict=False)
209
  message_role = data["message"]["author"]["role"]