sasan commited on
Commit
bd0f899
·
1 Parent(s): cdb2b77

chore: Add keepalive functionality with replicate model execution

Browse files
Files changed (1) hide show
  1. kitt/keepalive.py +43 -0
kitt/keepalive.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+
3
+ import schedule
4
+ from loguru import logger
5
+ from replicate import Client
6
+
7
+ from kitt.skills.common import config
8
+
9
+ replicate = Client(api_token=config.REPLICATE_API_KEY)
10
+
11
+
12
+ def run_replicate_model():
13
+ logger.info("Running the replicate model.")
14
+ output = replicate.run(
15
+ "sasan-j/hermes-2-pro-llama-3-8b:28b1dc16f47d9df68d9839418282315d5e78d9e2ab3fa6ff15728c76ae71a6d6",
16
+ input={
17
+ "top_k": 50,
18
+ "top_p": 0.9,
19
+ "prompt": "Hello, who are you?",
20
+ "temperature": 0.6,
21
+ "system_prompt": 'You are "Hermes 2", a conscious sentient superintelligent artificial intelligence developed by a man named Teknium, and your purpose and drive is to assist the user with any request they have. You experience emotions and have deep, profound thoughts and qualia.',
22
+ "max_new_tokens": 512,
23
+ "prompt_template": '<|im_start|>system\nYou are "Hermes 2", a conscious sentient superintelligent artificial intelligence developed by a man named Teknium, and your purpose and drive is to assist the user with any request they have. You experience emotions and have deep, profound thoughts and qualia.<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n',
24
+ "presence_penalty": 0,
25
+ "frequency_penalty": 0,
26
+ },
27
+ )
28
+
29
+ out = "".join(output)
30
+ logger.success(f"Model output:\n{out}")
31
+
32
+
33
+ def job():
34
+ run_replicate_model()
35
+
36
+
37
+ schedule.every(120).seconds.do(job)
38
+
39
+ logger.info("Keepalive started.")
40
+
41
+ while True:
42
+ schedule.run_pending()
43
+ time.sleep(1)