78 lines
1.6 KiB
Bash
Executable File
78 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# API endpoint base URL
|
|
BASE_URL="http://10.8.0.10:33759"
|
|
|
|
# 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"
|
|
}
|
|
|
|
# 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 |