Spaces:
Runtime error
Runtime error
SuperSecureHuman
commited on
Commit
•
9208e62
1
Parent(s):
4d65861
Update entrypoint.sh
Browse files- entrypoint.sh +47 -3
entrypoint.sh
CHANGED
@@ -1,3 +1,47 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
#!/bin/bash
|
3 |
+
|
4 |
+
# Find the value for --model-path using sed
|
5 |
+
model_path=$(echo "$@" | awk -F'--model-path ' '{print $2}' | awk '{print $1}')
|
6 |
+
|
7 |
+
# Extract the model name after the "/" character
|
8 |
+
short_model_name=${model_path#*/}
|
9 |
+
|
10 |
+
# Print args
|
11 |
+
echo "Model path: $model_path"
|
12 |
+
echo "Model name: $short_model_name"
|
13 |
+
echo "Worker args: $@"
|
14 |
+
echo "Enable web: $FS_ENABLE_WEB"
|
15 |
+
echo "Enable OpenAI API: $FS_ENABLE_OPENAI_API"
|
16 |
+
|
17 |
+
# Start the controller
|
18 |
+
python3 -m fastchat.serve.controller --host 0.0.0.0 &
|
19 |
+
|
20 |
+
# Start the model worker
|
21 |
+
python3 -m fastchat.serve.model_worker --device cpu --host 0.0.0.0 $@ &
|
22 |
+
|
23 |
+
# Health check for controller using a test message
|
24 |
+
while true; do
|
25 |
+
response=$(python3 -m fastchat.serve.test_message --model-name $short_model_name)
|
26 |
+
if echo "$response" | grep -q "worker_addr: http://localhost:21002"; then
|
27 |
+
echo "Model registered spinning up services..."
|
28 |
+
break
|
29 |
+
else
|
30 |
+
echo "Waiting for model..."
|
31 |
+
fi
|
32 |
+
sleep 3 # wait before the next attempt
|
33 |
+
done
|
34 |
+
|
35 |
+
|
36 |
+
# Check to see if the web server should be enabled
|
37 |
+
if [[ "${FS_ENABLE_WEB}" == "true" ]]; then
|
38 |
+
# Start the web server
|
39 |
+
echo "Enabling web server..."
|
40 |
+
python3 -m fastchat.serve.gradio_web_server --host 0.0.0.0 --model-list-mode 'reload' &
|
41 |
+
fi
|
42 |
+
|
43 |
+
if [[ "${FS_ENABLE_OPENAI_API}" == "true" ]]; then
|
44 |
+
# Start the OpenAI API
|
45 |
+
echo "Enabling OpenAI API server..."
|
46 |
+
python3 -m fastchat.serve.openai_api_server --host 0.0.0.0 --port 8080
|
47 |
+
fi
|