tchbcb commited on
Commit
12b2f89
·
verified ·
1 Parent(s): 85708e3

200k ctx (rope_scaling hook) + openai-compatible api (key 1234) + bootstrap v2 (chat 7861 / api 7862) + model card

Browse files
Files changed (1) hide show
  1. bootstrap.py +14 -3
bootstrap.py CHANGED
@@ -36,13 +36,14 @@ if v and not v.startswith("5.16"):
36
  log("pinned transformers==5.16.1 (modeling 代码按此版本修补)")
37
 
38
  log("pull servers from HF ...")
39
- for f in ["chat_server.py", "openai_api.py"]:
40
  subprocess.run(
41
  f"curl -sL https://huggingface.co/{REPO}/resolve/main/{f} -o /content/{f}",
42
  shell=True, check=True)
43
  import py_compile # noqa: E402
44
  py_compile.compile("/content/chat_server.py", doraise=True)
45
  py_compile.compile("/content/openai_api.py", doraise=True)
 
46
  log("server scripts OK")
47
 
48
  log("download model (~8.3GB, 首次约3-6分钟) ...")
@@ -62,7 +63,9 @@ if not os.path.exists("/content/samai-4b-sft"):
62
  log("model ready: " + model_dir)
63
 
64
  subprocess.run("pkill -f chat_server.py; pkill -f openai_api.py; "
65
- "pkill -f 'aitun -p 7861'; pkill -f 'aitun -p 7862'", shell=True)
 
 
66
  time.sleep(2)
67
  env = f"S4_MODEL_DIR=/content/samai-4b-sft S4_API_KEY={API_KEY}"
68
  subprocess.Popen(f"setsid nohup env {env} python3 /content/chat_server.py"
@@ -71,17 +74,24 @@ subprocess.Popen(f"setsid nohup env {env} python3 /content/chat_server.py"
71
  subprocess.Popen(f"setsid nohup env {env} python3 /content/openai_api.py"
72
  f" > /content/api_run.log 2>&1 &",
73
  shell=True, start_new_session=True)
 
 
 
74
  log("services starting (模型加载约2分钟) ...")
75
 
76
  subprocess.Popen("setsid nohup aitun -p 7861 > /content/aitun7861.log 2>&1 &",
77
  shell=True, start_new_session=True)
78
  subprocess.Popen("setsid nohup aitun -p 7862 > /content/aitun7862.log 2>&1 &",
79
  shell=True, start_new_session=True)
 
 
80
  time.sleep(12)
81
  log("=== 隧道 7861 (聊天页) ===")
82
  print(sh("tail -4 /content/aitun7861.log"))
83
  log("=== 隧道 7862 (OpenAI API) ===")
84
  print(sh("tail -4 /content/aitun7862.log"))
 
 
85
 
86
  for name, port in [("chat", 7861), ("api", 7862)]:
87
  for i in range(30):
@@ -95,8 +105,9 @@ for name, port in [("chat", 7861), ("api", 7862)]:
95
 
96
  log("=" * 60)
97
  log("BOOTSTRAP_DONE")
98
- log(f"聊天页 (UI) : 见 aitun7861.log 的公网地址")
99
  log(f"OpenAI 兼容 API : 见 aitun7862.log 的公网地址 (key={API_KEY})")
 
100
  log("API 测试: curl <API地址>/v1/chat/completions -H 'Authorization: Bearer 1234' "
101
  "-H 'Content-Type: application/json' "
102
  "-d '{\"model\":\"samai-4b\",\"messages\":[{\"role\":\"user\",\"content\":\"你好\"}]}'")
 
36
  log("pinned transformers==5.16.1 (modeling 代码按此版本修补)")
37
 
38
  log("pull servers from HF ...")
39
+ for f in ["chat_server.py", "openai_api.py", "control_server.py"]:
40
  subprocess.run(
41
  f"curl -sL https://huggingface.co/{REPO}/resolve/main/{f} -o /content/{f}",
42
  shell=True, check=True)
43
  import py_compile # noqa: E402
44
  py_compile.compile("/content/chat_server.py", doraise=True)
45
  py_compile.compile("/content/openai_api.py", doraise=True)
46
+ py_compile.compile("/content/control_server.py", doraise=True)
47
  log("server scripts OK")
48
 
49
  log("download model (~8.3GB, 首次约3-6分钟) ...")
 
63
  log("model ready: " + model_dir)
64
 
65
  subprocess.run("pkill -f chat_server.py; pkill -f openai_api.py; "
66
+ "pkill -f control_server.py; "
67
+ "pkill -f 'aitun -p 7861'; pkill -f 'aitun -p 7862'; "
68
+ "pkill -f 'aitun -p 5000'", shell=True)
69
  time.sleep(2)
70
  env = f"S4_MODEL_DIR=/content/samai-4b-sft S4_API_KEY={API_KEY}"
71
  subprocess.Popen(f"setsid nohup env {env} python3 /content/chat_server.py"
 
74
  subprocess.Popen(f"setsid nohup env {env} python3 /content/openai_api.py"
75
  f" > /content/api_run.log 2>&1 &",
76
  shell=True, start_new_session=True)
77
+ subprocess.Popen("setsid nohup python3 /content/control_server.py"
78
+ " > /content/control_run.log 2>&1 &",
79
+ shell=True, start_new_session=True)
80
  log("services starting (模型加载约2分钟) ...")
81
 
82
  subprocess.Popen("setsid nohup aitun -p 7861 > /content/aitun7861.log 2>&1 &",
83
  shell=True, start_new_session=True)
84
  subprocess.Popen("setsid nohup aitun -p 7862 > /content/aitun7862.log 2>&1 &",
85
  shell=True, start_new_session=True)
86
+ subprocess.Popen("setsid nohup aitun -p 5000 > /content/aitun5000.log 2>&1 &",
87
+ shell=True, start_new_session=True)
88
  time.sleep(12)
89
  log("=== 隧道 7861 (聊天页) ===")
90
  print(sh("tail -4 /content/aitun7861.log"))
91
  log("=== 隧道 7862 (OpenAI API) ===")
92
  print(sh("tail -4 /content/aitun7862.log"))
93
+ log("=== 隧道 5000 (远程控制) ===")
94
+ print(sh("tail -4 /content/aitun5000.log"))
95
 
96
  for name, port in [("chat", 7861), ("api", 7862)]:
97
  for i in range(30):
 
105
 
106
  log("=" * 60)
107
  log("BOOTSTRAP_DONE")
108
+ log(f"聊天页 (UI) : 见 aitun7861.log 的公网地址")
109
  log(f"OpenAI 兼容 API : 见 aitun7862.log 的公网地址 (key={API_KEY})")
110
+ log(f"远程控制通道 : 见 aitun5000.log 的公网地址 (把三个地址都发给助手)")
111
  log("API 测试: curl <API地址>/v1/chat/completions -H 'Authorization: Bearer 1234' "
112
  "-H 'Content-Type: application/json' "
113
  "-d '{\"model\":\"samai-4b\",\"messages\":[{\"role\":\"user\",\"content\":\"你好\"}]}'")