rbn2008k commited on
Commit
8b4a19c
·
verified ·
1 Parent(s): 304b01e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py CHANGED
@@ -3,6 +3,8 @@ import time
3
  import threading
4
  import base64
5
  from io import BytesIO
 
 
6
  from collections import OrderedDict
7
  from datetime import datetime
8
 
@@ -144,6 +146,7 @@ async def get_bot_id():
144
  # Async function to get OpenAI completion
145
  async def get_completion(event, user_id, prompt):
146
  async with client.action(event.chat_id, 'typing'):
 
147
  history = get_chat_history(user_id)
148
  messages = [
149
  {"role": "system", "content": system_prompt},
@@ -216,6 +219,20 @@ async def handle_message(event):
216
  print(f"An error occurred: {e}")
217
  await event.respond("Whoopsie!")
218
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
  # Keep-alive function to keep the bot running
220
  def keep_alive():
221
  ping_client = OpenAI(api_key=ping_key, base_url=api_url)
@@ -239,4 +256,5 @@ def keep_alive():
239
 
240
  if __name__ == "__main__":
241
  threading.Thread(target=keep_alive).start()
 
242
  client.run_until_disconnected()
 
3
  import threading
4
  import base64
5
  from io import BytesIO
6
+ import gradio as gr
7
+ import asyncio
8
  from collections import OrderedDict
9
  from datetime import datetime
10
 
 
146
  # Async function to get OpenAI completion
147
  async def get_completion(event, user_id, prompt):
148
  async with client.action(event.chat_id, 'typing'):
149
+ await asyncio.sleep(3)
150
  history = get_chat_history(user_id)
151
  messages = [
152
  {"role": "system", "content": system_prompt},
 
219
  print(f"An error occurred: {e}")
220
  await event.respond("Whoopsie!")
221
 
222
+ def launch_gradio():
223
+ welcome_message = """
224
+ # Meet Scarlett!
225
+ - Scarlett is a girl residing in Telegram
226
+ - She can chat with you without any censorship.
227
+ - Head over to https://t.me/Scarlett_Rogue_isNotBot
228
+ """
229
+ with gr.Blocks() as demo:
230
+ gr.Markdown(f"""
231
+ # Follow me: https://example.com
232
+ {welcome_message}
233
+ """)
234
+ demo.launch(show_api=False)
235
+
236
  # Keep-alive function to keep the bot running
237
  def keep_alive():
238
  ping_client = OpenAI(api_key=ping_key, base_url=api_url)
 
256
 
257
  if __name__ == "__main__":
258
  threading.Thread(target=keep_alive).start()
259
+ threading.Thread(target=launch_gradio).start()
260
  client.run_until_disconnected()