randydev commited on
Commit
9caed8d
·
verified ·
1 Parent(s): 8401edd

Fix video missing backup

Browse files
Files changed (1) hide show
  1. chatbot/plugins/chat.py +4 -0
chatbot/plugins/chat.py CHANGED
@@ -280,6 +280,8 @@ async def handle_video(client, message, model_):
280
  progress_args=(ai_reply, seconds_time, "Uploading...")
281
  )
282
  caption = message.caption or "What's this?"
 
 
283
  model = genai.GenerativeModel(model_name=model_)
284
  video_file = genai.upload_file(path=video_file_name)
285
  while video_file.state.name == "PROCESSING":
@@ -294,6 +296,8 @@ async def handle_video(client, message, model_):
294
  request_options={"timeout": 600}
295
  )
296
  await ai_reply.edit_text(response.text)
 
 
297
  except asyncio.CancelledError:
298
  await ai_reply.edit_text("⚠️ Video processing was canceled.")
299
  finally:
 
280
  progress_args=(ai_reply, seconds_time, "Uploading...")
281
  )
282
  caption = message.caption or "What's this?"
283
+ backup_chat = await db._get_chatbot_chat_from_db(message.from_user.id)
284
+ backup_chat.append({"role": "user", "parts": [{"text": caption}]})
285
  model = genai.GenerativeModel(model_name=model_)
286
  video_file = genai.upload_file(path=video_file_name)
287
  while video_file.state.name == "PROCESSING":
 
296
  request_options={"timeout": 600}
297
  )
298
  await ai_reply.edit_text(response.text)
299
+ backup_chat.append({"role": "model", "parts": [{"text": response.text}]})
300
+ await db._update_chatbot_chat_in_db(message.from_user.id, backup_chat)
301
  except asyncio.CancelledError:
302
  await ai_reply.edit_text("⚠️ Video processing was canceled.")
303
  finally: