randydev commited on
Commit
199a0e2
·
verified ·
1 Parent(s): 835be34
Files changed (1) hide show
  1. chatbot/plugins/chat.py +28 -11
chatbot/plugins/chat.py CHANGED
@@ -515,7 +515,7 @@ async def geminigen_prompt(client, callback):
515
  response_modalities=['TEXT', 'IMAGE']
516
  )
517
  )
518
-
519
  for part in response.candidates[0].content.parts:
520
  if part.text is not None:
521
  captions += part.text
@@ -526,7 +526,8 @@ async def geminigen_prompt(client, callback):
526
  keyboard = create_keyboard(
527
  user_id=user_id,
528
  chat=data.get("channel_username", "RendyProjects"),
529
- is_menu=data.get("is_channel_photo", False)
 
530
  )
531
  view_button_user = anonymous_user(user_id=user_id)
532
  await callback.message.edit_media(
@@ -545,10 +546,17 @@ async def geminigen_prompt(client, callback):
545
  )
546
  await db.backup_chatbot.update_one(
547
  {"user_id": user_id},
548
- {"$set": {
549
- "translate_text": response.text,
550
- "file_id": photo.photo.file_id
551
- }},
 
 
 
 
 
 
 
552
  upsert=True
553
  )
554
  backup_chat.append({"role": "model", "parts": [{"text": captions}]})
@@ -612,6 +620,7 @@ async def flux_prompt(client, callback):
612
  file_photo = await gen.aio.files.get(name=file_photo.name)
613
  if file_photo.state.name == "FAILED":
614
  return await callback.message.reply_text(f"Error: {file_photo.state.name}")
 
615
  response = await gen.aio.models.generate_content(
616
  model="gemini-2.0-flash",
617
  contents=[
@@ -622,7 +631,8 @@ async def flux_prompt(client, callback):
622
  keyboard = create_keyboard(
623
  user_id=user_id,
624
  chat=data.get("channel_username", "RendyProjects"),
625
- is_menu=data.get("is_channel_photo", False)
 
626
  )
627
  view_button_user = anonymous_user(user_id=user_id)
628
  await callback.message.edit_media(
@@ -641,10 +651,17 @@ async def flux_prompt(client, callback):
641
  )
642
  await db.backup_chatbot.update_one(
643
  {"user_id": user_id},
644
- {"$set": {
645
- "translate_text": response.text,
646
- "file_id": photo.photo.file_id
647
- }},
 
 
 
 
 
 
 
648
  upsert=True
649
  )
650
  backup_chat.append({"role": "model", "parts": [{"text": response.text}]})
 
515
  response_modalities=['TEXT', 'IMAGE']
516
  )
517
  )
518
+ uuid_code = str(uuid.uuid4())[:8]
519
  for part in response.candidates[0].content.parts:
520
  if part.text is not None:
521
  captions += part.text
 
526
  keyboard = create_keyboard(
527
  user_id=user_id,
528
  chat=data.get("channel_username", "RendyProjects"),
529
+ is_menu=data.get("is_channel_photo", False),
530
+ uuid_str=uuid_code
531
  )
532
  view_button_user = anonymous_user(user_id=user_id)
533
  await callback.message.edit_media(
 
546
  )
547
  await db.backup_chatbot.update_one(
548
  {"user_id": user_id},
549
+ {"$set": {"file_id": photo.photo.file_id}},
550
+ upsert=True
551
+ )
552
+ translation_entry = {
553
+ "uuid": uuid_code,
554
+ "text": captions,
555
+ "timestamp": dt.now().isoformat()
556
+ }
557
+ await db.backup_chatbot.update_one(
558
+ {"user_id": user_id},
559
+ {"$push": {"translate_history": translation_entry}},
560
  upsert=True
561
  )
562
  backup_chat.append({"role": "model", "parts": [{"text": captions}]})
 
620
  file_photo = await gen.aio.files.get(name=file_photo.name)
621
  if file_photo.state.name == "FAILED":
622
  return await callback.message.reply_text(f"Error: {file_photo.state.name}")
623
+ uuid_code = str(uuid.uuid4())[:8]
624
  response = await gen.aio.models.generate_content(
625
  model="gemini-2.0-flash",
626
  contents=[
 
631
  keyboard = create_keyboard(
632
  user_id=user_id,
633
  chat=data.get("channel_username", "RendyProjects"),
634
+ is_menu=data.get("is_channel_photo", False),
635
+ uuid_str=uuid_code
636
  )
637
  view_button_user = anonymous_user(user_id=user_id)
638
  await callback.message.edit_media(
 
651
  )
652
  await db.backup_chatbot.update_one(
653
  {"user_id": user_id},
654
+ {"$set": {"file_id": photo.photo.file_id}},
655
+ upsert=True
656
+ )
657
+ translation_entry = {
658
+ "uuid": uuid_code,
659
+ "text": response.text,
660
+ "timestamp": dt.now().isoformat()
661
+ }
662
+ await db.backup_chatbot.update_one(
663
+ {"user_id": user_id},
664
+ {"$push": {"translate_history": translation_entry}},
665
  upsert=True
666
  )
667
  backup_chat.append({"role": "model", "parts": [{"text": response.text}]})