-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscripts.py
More file actions
37 lines (33 loc) · 1.11 KB
/
scripts.py
File metadata and controls
37 lines (33 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import subprocess
import os
import shlex
def get_env(local_port:int, chat_model:str=None, chat_host:str=None, chat_port:str=None):
new_env = os.environ.copy()
new_env["LOCAL_PORT"] = str(local_port)
if chat_model is not None:
new_env["CHAT_MODEL"]=chat_model
if chat_host is not None:
new_env["CHAT_HOST"]=chat_host
if chat_port is not None:
new_env["CHAT_PORT"]=str(chat_port)
return new_env
def run_command(command:str, new_env:dict):
args=shlex.split(command)
try:
subprocess.run(args, env=new_env, check=True)
except subprocess.CalledProcessError as e:
print(f"Error executing command: {e}")
def start_chat():
"""
Start the text chat server on port 8010
"""
my_env = get_env(local_port=8010, chat_model="granite3-moe")
command = f"poetry run python nlip_web/text_chat.py"
run_command(command, my_env)
def start_image():
"""
Start the image chat server on port 8020
"""
my_env = get_env(local_port=8020, chat_model="llava")
command = f"poetry run python nlip_web/image_chat.py"
run_command(command, my_env)