This commit is contained in:
TCUDIKEL
2025-05-11 19:49:33 +03:00
parent 4e1970dd85
commit 87d384fd26
2 changed files with 77 additions and 23 deletions

View File

@@ -139,9 +139,10 @@ async def restart_service():
stdout, stderr = await result.communicate()
if result.returncode != 0:
logger.error(f"Failed to restart service: {stderr.decode()}")
logger.error(
f"Failed to restart service: return_code={result.returncode}, stderr={stderr.decode()}, stdout={stdout.decode()}")
else:
logger.info("Successfully restarted llm-api-mcphost service")
logger.info(f"Successfully restarted service: {stdout.decode()}")
except Exception as e:
logger.error(f"Error restarting service: {str(e)}")

95
test.sh
View File

@@ -1,25 +1,78 @@
#!/bin/bash
# API endpoint base URL
BASE_URL="http://10.8.0.10:33759"
#clear
#curl -X POST \
# -H "Content-Type: plain/text" \
# -d "When is your knowledge cut off? /no_think" \
# http://localhost:8000
# Function to display help
show_help() {
echo "Usage: $0 <command> [args]"
echo ""
echo "Commands:"
echo " query [message] Send a query (default: hackernews summary)"
echo " restart Restart the service"
echo ""
echo "Examples:"
echo " $0 query"
echo " $0 query \"What is the weather?\""
echo " $0 restart"
}
curl -X 'POST' \
'http://10.8.0.10:33759/v1/chat/completions' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"model": "mcphost-model",
"messages": [
{
"role": "user",
"content": "fetch hackernews headlines and provide me a summary of the top 10"
}
],
"temperature": 0.7,
"stream": false,
"max_tokens": 4096
}'
# Function to send a query
send_query() {
local message="${1:-fetch hackernews headlines and provide me a summary of the top 10}"
echo "Sending query: $message"
echo ""
curl -X 'POST' \
"${BASE_URL}/v1/chat/completions" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d "{
\"model\": \"mcphost-model\",
\"messages\": [
{
\"role\": \"user\",
\"content\": \"$message\"
}
],
\"temperature\": 0.7,
\"stream\": false,
\"max_tokens\": 4096
}"
}
# Function to restart the service
restart_service() {
echo "Restarting service..."
echo ""
curl -X 'GET' \
"${BASE_URL}/restart" \
-H 'accept: application/json'
}
# Main script logic
if [ $# -eq 0 ]; then
show_help
exit 1
fi
case "$1" in
"query")
shift
send_query "$*"
;;
"restart")
restart_service
;;
"-h"|"--help"|"help")
show_help
;;
*)
echo "Error: Unknown command '$1'"
echo ""
show_help
exit 1
;;
esac