Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -12,6 +12,12 @@ from io import BytesIO
|
|
12 |
from huggingface_hub import InferenceClient
|
13 |
from transformers import AutoProcessor, AutoTokenizer
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
api_id = os.getenv('api_id')
|
16 |
api_hash = os.getenv('api_hash')
|
17 |
bot_token = os.getenv('bot_token')
|
@@ -104,7 +110,7 @@ history = CircularBuffer(99)
|
|
104 |
|
105 |
async def get_completion(prompt: str) -> str:
|
106 |
messages = [
|
107 |
-
{"role": "system", "content":
|
108 |
*history.get_history(),
|
109 |
{"role": "user", "content": prompt},
|
110 |
]
|
@@ -184,6 +190,10 @@ def keep_alive():
|
|
184 |
while True:
|
185 |
try:
|
186 |
requests.get("https://rbn2008k-Scarlett.hf.space")
|
|
|
|
|
|
|
|
|
187 |
except Exception as e:
|
188 |
print(f"Keep-alive request failed: {e}")
|
189 |
time.sleep(1800)
|
|
|
12 |
from huggingface_hub import InferenceClient
|
13 |
from transformers import AutoProcessor, AutoTokenizer
|
14 |
|
15 |
+
def load_system_prompt():
|
16 |
+
with open('prompt.txt', 'r') as file:
|
17 |
+
return file.read()
|
18 |
+
|
19 |
+
system_prompt = load_system_prompt()
|
20 |
+
|
21 |
api_id = os.getenv('api_id')
|
22 |
api_hash = os.getenv('api_hash')
|
23 |
bot_token = os.getenv('bot_token')
|
|
|
110 |
|
111 |
async def get_completion(prompt: str) -> str:
|
112 |
messages = [
|
113 |
+
{"role": "system", "content": system_prompt},
|
114 |
*history.get_history(),
|
115 |
{"role": "user", "content": prompt},
|
116 |
]
|
|
|
190 |
while True:
|
191 |
try:
|
192 |
requests.get("https://rbn2008k-Scarlett.hf.space")
|
193 |
+
messages = [
|
194 |
+
{"role": "system", "content": "Be a helpful assistant."},
|
195 |
+
{"role": "user", "content": "Hello"}
|
196 |
+
]
|
197 |
except Exception as e:
|
198 |
print(f"Keep-alive request failed: {e}")
|
199 |
time.sleep(1800)
|