davoodwadi commited on
Commit
a97a164
1 Parent(s): 48d141e

alive scheduler added

Browse files
Files changed (2) hide show
  1. app.py +25 -0
  2. requirements.txt +3 -3
app.py CHANGED
@@ -3,6 +3,31 @@ import os
3
  import gradio as gr
4
  from functools import partial
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  openaiKey = os.environ.get('openai')
7
  client = OpenAI(api_key=openaiKey)
8
  # print(openaiKey)
 
3
  import gradio as gr
4
  from functools import partial
5
 
6
+ ################## scheduler
7
+ from apscheduler.schedulers.background import BackgroundScheduler
8
+ from datetime import datetime
9
+ import time
10
+ import requests
11
+ from bs4 import BeautifulSoup
12
+ def keep_alive_adverse():
13
+ url = 'https://huggingface.co/spaces/davoodwadi/MultiAgentAdversary'
14
+ response = requests.get(url)
15
+ # Check if the request was successful
16
+ if response.status_code == 200:
17
+ print('success')
18
+ soup = BeautifulSoup(response.content, 'html.parser')
19
+ print(datetime.now())
20
+ print(soup.title.string)
21
+ else:
22
+ print(f'URL: {url} failed')
23
+ print('*'*20)
24
+ hours = 12
25
+ interval = 60*60*hours
26
+ scheduler = BackgroundScheduler()
27
+ scheduler.add_job(keep_alive_adverse, 'interval', seconds=interval)
28
+ scheduler.start()
29
+ ##################
30
+
31
  openaiKey = os.environ.get('openai')
32
  client = OpenAI(api_key=openaiKey)
33
  # print(openaiKey)
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
- openai==1.30
2
- gradio==4.27.0
3
- apscheduler
4
  beautifulsoup4
 
1
+ openai==1.30
2
+ gradio==4.27.0
3
+ apscheduler
4
  beautifulsoup4