Spaces:
Running
Running
Update start_services.sh
Browse files- start_services.sh +2 -20
start_services.sh
CHANGED
|
@@ -34,6 +34,8 @@ fi
|
|
| 34 |
# Step-Audio-R1 的 chat template
|
| 35 |
CHAT_TEMPLATE='{%- macro render_content(content) -%}{%- if content is string -%}{{- content.replace("<audio_patch>\\n", "<audio_patch>") -}}{%- elif content is mapping -%}{{- content["'"'"'value'"'"'] if '"'"'value'"'"' in content else content["'"'"'text'"'"'] -}}{%- elif content is iterable -%}{%- for item in content -%}{%- if item.type == '"'"'text'"'"' -%}{{- item["'"'"'value'"'"'] if '"'"'value'"'"' in item else item["'"'"'text'"'"'] -}}{%- elif item.type == '"'"'audio'"'"' -%}<audio_patch>{%- endif -%}{%- endfor -%}{%- endif -%}{%- endmacro -%}{%- if tools -%}{{- '"'"'<|BOT|>system\\n'"'"' -}}{%- if messages[0]["'"'"'role'"'"'] == '"'"'system'"'"' -%}{{- render_content(messages[0]["'"'"'content'"'"']) + '"'"'<|EOT|>'"'"' -}}{%- endif -%}{{- '"'"'<|BOT|>tool_json_schemas\\n'"'"' + tools|tojson + '"'"'<|EOT|>'"'"' -}}{%- else -%}{%- if messages[0]["'"'"'role'"'"'] == '"'"'system'"'"' -%}{{- '"'"'<|BOT|>system\\n'"'"' + render_content(messages[0]["'"'"'content'"'"']) + '"'"'<|EOT|>'"'"' -}}{%- endif -%}{%- endif -%}{%- for message in messages -%}{%- if message["role"] == "user" -%}{{- '"'"'<|BOT|>human\\n'"'"' + render_content(message["content"]) + '"'"'<|EOT|>'"'"' -}}{%- elif message["role"] == "assistant" -%}{{- '"'"'<|BOT|>assistant\\n'"'"' + (render_content(message["content"]) if message["content"] else '"'"''"'"') -}}{%- set is_last_assistant = true -%}{%- for m in messages[loop.index:] -%}{%- if m["role"] == "assistant" -%}{%- set is_last_assistant = false -%}{%- endif -%}{%- endfor -%}{%- if not is_last_assistant -%}{{- '"'"'<|EOT|>'"'"' -}}{%- endif -%}{%- elif message["role"] == "function_output" -%}{%- else -%}{%- if not (loop.first and message["role"] == "system") -%}{{- '"'"'<|BOT|>'"'"' + message["role"] + '"'"'\\n'"'"' + render_content(message["content"]) + '"'"'<|EOT|>'"'"' -}}{%- endif -%}{%- endif -%}{%- endfor -%}{%- if add_generation_prompt -%}{{- '"'"'<|BOT|>assistant\\n'"'"' -}}{%- endif -%}'
|
| 36 |
|
|
|
|
|
|
|
| 37 |
# 后台启动 vLLM API
|
| 38 |
python3 -m vllm.entrypoints.openai.api_server \
|
| 39 |
--model "$MODEL_DIR" \
|
|
@@ -50,26 +52,6 @@ python3 -m vllm.entrypoints.openai.api_server \
|
|
| 50 |
VLLM_PID=$!
|
| 51 |
echo "vLLM started (PID: $VLLM_PID)"
|
| 52 |
|
| 53 |
-
# 等待 vLLM 就绪
|
| 54 |
-
echo "Waiting for vLLM to be ready..."
|
| 55 |
-
for i in {1..30}; do
|
| 56 |
-
if curl -s "http://localhost:$API_PORT/v1/models" > /dev/null 2>&1; then
|
| 57 |
-
echo "✓ vLLM is ready (checked $i/30 times)"
|
| 58 |
-
break
|
| 59 |
-
fi
|
| 60 |
-
|
| 61 |
-
if [ $i -eq 30 ]; then
|
| 62 |
-
echo "❌ vLLM startup timeout after 60 seconds"
|
| 63 |
-
echo "Checking vLLM process:"
|
| 64 |
-
ps aux | grep "vllm.entrypoints.openai.api_server" || echo "vLLM process not found"
|
| 65 |
-
echo "Port $API_PORT status:"
|
| 66 |
-
netstat -tlnp | grep ":$API_PORT " || echo "Port $API_PORT not listening"
|
| 67 |
-
exit 1
|
| 68 |
-
fi
|
| 69 |
-
|
| 70 |
-
echo "Waiting for vLLM... ($i/30)"
|
| 71 |
-
sleep 2
|
| 72 |
-
done
|
| 73 |
|
| 74 |
# 启动 Gradio (前台运行)
|
| 75 |
export API_BASE_URL="http://localhost:$API_PORT/v1"
|
|
|
|
| 34 |
# Step-Audio-R1 的 chat template
|
| 35 |
CHAT_TEMPLATE='{%- macro render_content(content) -%}{%- if content is string -%}{{- content.replace("<audio_patch>\\n", "<audio_patch>") -}}{%- elif content is mapping -%}{{- content["'"'"'value'"'"'] if '"'"'value'"'"' in content else content["'"'"'text'"'"'] -}}{%- elif content is iterable -%}{%- for item in content -%}{%- if item.type == '"'"'text'"'"' -%}{{- item["'"'"'value'"'"'] if '"'"'value'"'"' in item else item["'"'"'text'"'"'] -}}{%- elif item.type == '"'"'audio'"'"' -%}<audio_patch>{%- endif -%}{%- endfor -%}{%- endif -%}{%- endmacro -%}{%- if tools -%}{{- '"'"'<|BOT|>system\\n'"'"' -}}{%- if messages[0]["'"'"'role'"'"'] == '"'"'system'"'"' -%}{{- render_content(messages[0]["'"'"'content'"'"']) + '"'"'<|EOT|>'"'"' -}}{%- endif -%}{{- '"'"'<|BOT|>tool_json_schemas\\n'"'"' + tools|tojson + '"'"'<|EOT|>'"'"' -}}{%- else -%}{%- if messages[0]["'"'"'role'"'"'] == '"'"'system'"'"' -%}{{- '"'"'<|BOT|>system\\n'"'"' + render_content(messages[0]["'"'"'content'"'"']) + '"'"'<|EOT|>'"'"' -}}{%- endif -%}{%- endif -%}{%- for message in messages -%}{%- if message["role"] == "user" -%}{{- '"'"'<|BOT|>human\\n'"'"' + render_content(message["content"]) + '"'"'<|EOT|>'"'"' -}}{%- elif message["role"] == "assistant" -%}{{- '"'"'<|BOT|>assistant\\n'"'"' + (render_content(message["content"]) if message["content"] else '"'"''"'"') -}}{%- set is_last_assistant = true -%}{%- for m in messages[loop.index:] -%}{%- if m["role"] == "assistant" -%}{%- set is_last_assistant = false -%}{%- endif -%}{%- endfor -%}{%- if not is_last_assistant -%}{{- '"'"'<|EOT|>'"'"' -}}{%- endif -%}{%- elif message["role"] == "function_output" -%}{%- else -%}{%- if not (loop.first and message["role"] == "system") -%}{{- '"'"'<|BOT|>'"'"' + message["role"] + '"'"'\\n'"'"' + render_content(message["content"]) + '"'"'<|EOT|>'"'"' -}}{%- endif -%}{%- endif -%}{%- endfor -%}{%- if add_generation_prompt -%}{{- '"'"'<|BOT|>assistant\\n'"'"' -}}{%- endif -%}'
|
| 36 |
|
| 37 |
+
echo "starting vllm server"
|
| 38 |
+
|
| 39 |
# 后台启动 vLLM API
|
| 40 |
python3 -m vllm.entrypoints.openai.api_server \
|
| 41 |
--model "$MODEL_DIR" \
|
|
|
|
| 52 |
VLLM_PID=$!
|
| 53 |
echo "vLLM started (PID: $VLLM_PID)"
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
# 启动 Gradio (前台运行)
|
| 57 |
export API_BASE_URL="http://localhost:$API_PORT/v1"
|