davoodwadi commited on
Commit
6c99c8d
·
verified ·
1 Parent(s): ef3b6ce

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +25 -0
  2. requirements.txt +4 -2
app.py CHANGED
@@ -7,6 +7,31 @@ import os
7
  client = OpenAI(api_key=os.environ.get("openai"))
8
  model="gpt-3.5-turbo"
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  # llm = Llama(model_path="./snorkel-mistral-pairrm-dpo.Q4_K_M.gguf",
11
  # chat_format="chatml",
12
  # n_gpu_layers=0, # cpu only
 
7
  client = OpenAI(api_key=os.environ.get("openai"))
8
  model="gpt-3.5-turbo"
9
 
10
+ ################## scheduler
11
+ from apscheduler.schedulers.background import BackgroundScheduler
12
+ from datetime import datetime
13
+ import time
14
+ import requests
15
+ from bs4 import BeautifulSoup
16
+ def keep_alive_adverse():
17
+ url = 'https://huggingface.co/spaces/davoodwadi/ProsocialChatbot'
18
+ response = requests.get(url)
19
+ # Check if the request was successful
20
+ if response.status_code == 200:
21
+ print('success')
22
+ soup = BeautifulSoup(response.content, 'html.parser')
23
+ print(datetime.now())
24
+ print(soup.title.string)
25
+ else:
26
+ print(f'URL: {url} failed')
27
+ print('*'*20)
28
+ hours = 12
29
+ interval = 60*60*hours
30
+ scheduler = BackgroundScheduler()
31
+ scheduler.add_job(keep_alive_adverse, 'interval', seconds=interval)
32
+ scheduler.start()
33
+ ##################
34
+
35
  # llm = Llama(model_path="./snorkel-mistral-pairrm-dpo.Q4_K_M.gguf",
36
  # chat_format="chatml",
37
  # n_gpu_layers=0, # cpu only
requirements.txt CHANGED
@@ -1,2 +1,4 @@
1
- openai
2
- gradio==4.27.0
 
 
 
1
+ openai==1.30
2
+ gradio==4.27.0
3
+ apscheduler
4
+ beautifulsoup4