200k ctx (rope_scaling hook) + openai-compatible api (key 1234) + bootstrap v2 (chat 7861 / api 7862) + model card
Browse files35 unmodified lines3637383940414243444546474813 unmodified lines626364656667682 unmodified lines71727374757677787980818283848586877 unmodified lines959697989910010110235 unmodified lineslog("pinned transformers==5.16.1 (modeling 代码按此版本修补)")log("pull servers from HF ...")for f in ["chat_server.py", "openai_api.py"]:subprocess.run(f"curl -sL https://huggingface.co/{REPO}/resolve/main/{f} -o /content/{f}",shell=True, check=True)import py_compile # noqa: E402py_compile.compile("/content/chat_server.py", doraise=True)py_compile.compile("/content/openai_api.py", doraise=True)log("server scripts OK")log("download model (~8.3GB, 首次约3-6分钟) ...")13 unmodified lineslog("model ready: " + model_dir)subprocess.run("pkill -f chat_server.py; pkill -f openai_api.py; ""pkill -f 'aitun -p 7861'; pkill -f 'aitun -p 7862'", shell=True)time.sleep(2)env = f"S4_MODEL_DIR=/content/samai-4b-sft S4_API_KEY={API_KEY}"subprocess.Popen(f"setsid nohup env {env} python3 /content/chat_server.py"2 unmodified linessubprocess.Popen(f"setsid nohup env {env} python3 /content/openai_api.py"f" > /content/api_run.log 2>&1 &",shell=True, start_new_session=True)log("services starting (模型加载约2分钟) ...")subprocess.Popen("setsid nohup aitun -p 7861 > /content/aitun7861.log 2>&1 &",shell=True, start_new_session=True)subprocess.Popen("setsid nohup aitun -p 7862 > /content/aitun7862.log 2>&1 &",shell=True, start_new_session=True)time.sleep(12)log("=== 隧道 7861 (聊天页) ===")print(sh("tail -4 /content/aitun7861.log"))log("=== 隧道 7862 (OpenAI API) ===")print(sh("tail -4 /content/aitun7862.log"))for name, port in [("chat", 7861), ("api", 7862)]:for i in range(30):7 unmodified lineslog("=" * 60)log("BOOTSTRAP_DONE")log(f"聊天页 (UI) : 见 aitun7861.log 的公网地址")log(f"OpenAI 兼容 API : 见 aitun7862.log 的公网地址 (key={API_KEY})")log("API 测试: curl <API地址>/v1/chat/completions -H 'Authorization: Bearer 1234' ""-H 'Content-Type: application/json' ""-d '{\"model\":\"samai-4b\",\"messages\":[{\"role\":\"user\",\"content\":\"你好\"}]}'")35 unmodified lines363738394041424344454647484913 unmodified lines6364656667686970712 unmodified lines7475767778798081828384858687888990919293949596977 unmodified lines10510610710810911011111211335 unmodified lineslog("pinned transformers==5.16.1 (modeling 代码按此版本修补)")log("pull servers from HF ...")for f in ["chat_server.py", "openai_api.py", "control_server.py"]:subprocess.run(f"curl -sL https://huggingface.co/{REPO}/resolve/main/{f} -o /content/{f}",shell=True, check=True)import py_compile # noqa: E402py_compile.compile("/content/chat_server.py", doraise=True)py_compile.compile("/content/openai_api.py", doraise=True)py_compile.compile("/content/control_server.py", doraise=True)log("server scripts OK")log("download model (~8.3GB, 首次约3-6分钟) ...")13 unmodified lineslog("model ready: " + model_dir)subprocess.run("pkill -f chat_server.py; pkill -f openai_api.py; ""pkill -f control_server.py; ""pkill -f 'aitun -p 7861'; pkill -f 'aitun -p 7862'; ""pkill -f 'aitun -p 5000'", shell=True)time.sleep(2)env = f"S4_MODEL_DIR=/content/samai-4b-sft S4_API_KEY={API_KEY}"subprocess.Popen(f"setsid nohup env {env} python3 /content/chat_server.py"2 unmodified linessubprocess.Popen(f"setsid nohup env {env} python3 /content/openai_api.py"f" > /content/api_run.log 2>&1 &",shell=True, start_new_session=True)subprocess.Popen("setsid nohup python3 /content/control_server.py"" > /content/control_run.log 2>&1 &",shell=True, start_new_session=True)log("services starting (模型加载约2分钟) ...")subprocess.Popen("setsid nohup aitun -p 7861 > /content/aitun7861.log 2>&1 &",shell=True, start_new_session=True)subprocess.Popen("setsid nohup aitun -p 7862 > /content/aitun7862.log 2>&1 &",shell=True, start_new_session=True)subprocess.Popen("setsid nohup aitun -p 5000 > /content/aitun5000.log 2>&1 &",shell=True, start_new_session=True)time.sleep(12)log("=== 隧道 7861 (聊天页) ===")print(sh("tail -4 /content/aitun7861.log"))log("=== 隧道 7862 (OpenAI API) ===")print(sh("tail -4 /content/aitun7862.log"))log("=== 隧道 5000 (远程控制) ===")print(sh("tail -4 /content/aitun5000.log"))for name, port in [("chat", 7861), ("api", 7862)]:for i in range(30):7 unmodified lineslog("=" * 60)log("BOOTSTRAP_DONE")log(f"聊天页 (UI) : 见 aitun7861.log 的公网地址")log(f"OpenAI 兼容 API : 见 aitun7862.log 的公网地址 (key={API_KEY})")log(f"远程控制通道 : 见 aitun5000.log 的公网地址 (把三个地址都发给助手)")log("API 测试: curl <API地址>/v1/chat/completions -H 'Authorization: Bearer 1234' ""-H 'Content-Type: application/json' ""-d '{\"model\":\"samai-4b\",\"messages\":[{\"role\":\"user\",\"content\":\"你好\"}]}'")
bootstrap.py+14-3