T145 commited on
Commit
01a1967
·
1 Parent(s): 4e536d0

Keep the space running

Browse files
Files changed (2) hide show
  1. README.md +2 -2
  2. app.py +14 -0
README.md CHANGED
@@ -1,12 +1,12 @@
1
  ---
2
  title: ZEUS 8B V2 CHAT
3
- emoji: ⛈️
4
  colorFrom: gray
5
  colorTo: yellow
6
  sdk: gradio
7
  sdk_version: 5.0.1
8
  app_file: app.py
9
- pinned: false
10
  license: apache-2.0
11
  short_description: Chat with ZEUS!
12
  ---
 
1
  ---
2
  title: ZEUS 8B V2 CHAT
3
+ emoji: ⚡👈
4
  colorFrom: gray
5
  colorTo: yellow
6
  sdk: gradio
7
  sdk_version: 5.0.1
8
  app_file: app.py
9
+ pinned: true
10
  license: apache-2.0
11
  short_description: Chat with ZEUS!
12
  ---
app.py CHANGED
@@ -1,6 +1,10 @@
1
  import gradio as gr
2
  from llama_cpp import Llama
 
 
 
3
 
 
4
  LLM = Llama.from_pretrained(
5
  repo_id="mradermacher/ZEUS-8B-V2-i1-GGUF",
6
  filename="*Q4_K_M.gguf",
@@ -9,6 +13,15 @@ LLM = Llama.from_pretrained(
9
  )
10
 
11
 
 
 
 
 
 
 
 
 
 
12
  def respond(
13
  message,
14
  history: list[tuple[str, str]],
@@ -71,4 +84,5 @@ if __name__ == "__main__":
71
  ],
72
  )
73
 
 
74
  demo.launch()
 
1
  import gradio as gr
2
  from llama_cpp import Llama
3
+ import threading
4
+ from huggingface_hub import HfApi
5
+ import time
6
 
7
+ API = HfApi()
8
  LLM = Llama.from_pretrained(
9
  repo_id="mradermacher/ZEUS-8B-V2-i1-GGUF",
10
  filename="*Q4_K_M.gguf",
 
13
  )
14
 
15
 
16
+ def refresh(how_much=43200): # default to 12 hour
17
+ time.sleep(how_much)
18
+ try:
19
+ API.restart_space(repo_id="T145/ZEUS-8B-V2-CHAT")
20
+ except Exception as e:
21
+ print(f"Error while rebooting, trying again... {e}")
22
+ refresh(600) # 10 minutes if any error happens
23
+
24
+
25
  def respond(
26
  message,
27
  history: list[tuple[str, str]],
 
84
  ],
85
  )
86
 
87
+ threading.Thread(target=refresh).start()
88
  demo.launch()