randydev commited on
Commit
c8fe717
·
verified ·
1 Parent(s): fa790ea

Update chatbot/plugins/chat.py

Browse files
Files changed (1) hide show
  1. chatbot/plugins/chat.py +4 -5
chatbot/plugins/chat.py CHANGED
@@ -945,7 +945,7 @@ async def chatbot_talk(client: Client, message: Message):
945
  "You can't type (error 404: creativity not found)"
946
  )
947
 
948
- stream_image_now = re.sub(r"--stream-images", "", caption).strip()
949
  if stream_image_now:
950
  STREAM_IMAGE_PATH = await message.download()
951
  try:
@@ -956,7 +956,7 @@ async def chatbot_talk(client: Client, message: Message):
956
  async for chunk in await gen.aio.models.generate_content_stream(
957
  model='gemini-2.0-flash-001',
958
  contents=[
959
- str(stream_image_now),
960
  ty.Part.from_bytes(data=image_bytes, mime_type="image/jpeg")
961
  ]
962
  ):
@@ -990,16 +990,15 @@ async def chatbot_talk(client: Client, message: Message):
990
  except:
991
  pass
992
 
993
- edit_image_now = re.sub(r"--edit-images", "", caption).strip()
994
  if edit_image_now:
995
- LOGS.info(f"This Enabled cleared: {edit_image_now}")
996
  try:
997
  backup_chat = await db._get_chatbot_chat_from_db(message.from_user.id)
998
  backup_chat.append({"role": "user", "parts": [{"text": caption}]})
999
  images = Image.open(await message.download())
1000
  response = await gen.aio.models.generate_content(
1001
  model="gemini-2.0-flash-exp-image-generation",
1002
- contents=[str(edit_image_now), images],
1003
  config=ty.GenerateContentConfig(
1004
  response_modalities=['TEXT', 'IMAGE']
1005
  )
 
945
  "You can't type (error 404: creativity not found)"
946
  )
947
 
948
+ stream_image_now = re.match(r"--stream-images\s*(.*)", caption, re.IGNORECASE)
949
  if stream_image_now:
950
  STREAM_IMAGE_PATH = await message.download()
951
  try:
 
956
  async for chunk in await gen.aio.models.generate_content_stream(
957
  model='gemini-2.0-flash-001',
958
  contents=[
959
+ str(stream_image_now.group(1)),
960
  ty.Part.from_bytes(data=image_bytes, mime_type="image/jpeg")
961
  ]
962
  ):
 
990
  except:
991
  pass
992
 
993
+ edit_image_now = re.match(r"--edit-images\s*(.*)", caption, re.IGNORECASE)
994
  if edit_image_now:
 
995
  try:
996
  backup_chat = await db._get_chatbot_chat_from_db(message.from_user.id)
997
  backup_chat.append({"role": "user", "parts": [{"text": caption}]})
998
  images = Image.open(await message.download())
999
  response = await gen.aio.models.generate_content(
1000
  model="gemini-2.0-flash-exp-image-generation",
1001
+ contents=[str(edit_image_now.group(1)), images],
1002
  config=ty.GenerateContentConfig(
1003
  response_modalities=['TEXT', 'IMAGE']
1004
  )