uncloseai.com/languages/bash/examples.sh

74 lines
2.2 KiB
Bash
Executable file

#!/bin/bash
# uncloseai.com API Examples in Bash
# Demonstrates Hermes AI, Qwen Coder, and TTS endpoints
echo "=== uncloseai.com Bash Examples ==="
echo ""
# Example 1: Hermes AI Chat (Non-Streaming)
echo "1. Hermes AI - General Purpose Chat"
echo " Asking: 'Give a Python Fizzbuzz solution in one line of code?'"
echo ""
hermes_response=$(curl -s -X POST "https://hermes.ai.unturf.com/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer dummy-key" \
-d '{
"model": "adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic",
"messages": [{"role": "user", "content": "Give a Python Fizzbuzz solution in one line of code?"}],
"temperature": 0.5,
"max_tokens": 150
}')
echo "Response:"
echo "$hermes_response" | jq -r '.choices[0].message.content' 2>/dev/null || echo "$hermes_response"
echo ""
echo "---"
echo ""
# Example 2: Qwen 3 Coder - Specialized Coding Model
echo "2. Qwen 3 Coder - Specialized for Code"
echo " Asking: 'Write a bash function to check if a port is open'"
echo ""
qwen_response=$(curl -s -X POST "https://qwen.ai.unturf.com/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer dummy-key" \
-d '{
"model": "hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M",
"messages": [{"role": "user", "content": "Write a bash function to check if a port is open"}],
"temperature": 0.5,
"max_tokens": 200
}')
echo "Response:"
echo "$qwen_response" | jq -r '.choices[0].message.content' 2>/dev/null || echo "$qwen_response"
echo ""
echo "---"
echo ""
# Example 3: Text-to-Speech
echo "3. Text-to-Speech Generation"
echo " Converting text to speech and saving to speech.mp3"
echo ""
curl -s -X POST "https://speech.ai.unturf.com/v1/audio/speech" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOLO" \
-d '{
"model": "tts-1",
"voice": "alloy",
"input": "Hello from Bash! Today is a wonderful day to build something people love!"
}' \
--output speech.mp3
if [ -f speech.mp3 ]; then
file_size=$(stat -f%z speech.mp3 2>/dev/null || stat -c%s speech.mp3 2>/dev/null)
echo "✓ Speech file created: speech.mp3 (${file_size} bytes)"
else
echo "✗ Failed to create speech file"
fi
echo ""
echo "=== Examples Complete ==="