diff --git a/languages/bash/Dockerfile b/languages/bash/Dockerfile new file mode 100644 index 0000000..ea38d59 --- /dev/null +++ b/languages/bash/Dockerfile @@ -0,0 +1,9 @@ +FROM alpine:latest + +RUN apk add --no-cache bash curl jq ca-certificates + +WORKDIR /app +COPY examples.sh . +RUN chmod +x examples.sh + +CMD ["./examples.sh"] diff --git a/languages/bash/examples.sh b/languages/bash/examples.sh new file mode 100755 index 0000000..b29a1fb --- /dev/null +++ b/languages/bash/examples.sh @@ -0,0 +1,74 @@ +#!/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 ===" diff --git a/languages/bash/index.html b/languages/bash/index.html new file mode 100644 index 0000000..4f00619 --- /dev/null +++ b/languages/bash/index.html @@ -0,0 +1,166 @@ + + + + + + Bash - uncloseai.com API Examples + + + + + +

Bash - uncloseai.com API Examples

+ +

This directory contains Bash examples for interacting with uncloseai.com's AI services using curl. Bash is perfect for quick scripts and command-line automation.

+ +

Prerequisites

+ + +

Files in This Directory

+ + +

Running with Docker

+
# Build the Docker image
+docker build -t ai-unturf-bash languages/bash/
+
+# Run the examples
+docker run --rm ai-unturf-bash
+ +

Running Directly

+
# Make script executable
+chmod +x examples.sh
+
+# Run the examples
+./examples.sh
+ +

Code Example: Hermes AI Chat

+

Using curl to call the Hermes AI endpoint for general purpose conversation:

+
#!/bin/bash
+
+# Hermes AI Chat - Non-Streaming
+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
+  }')
+
+# Parse response with jq (optional)
+echo "$hermes_response" | jq -r '.choices[0].message.content'
+ +

Code Example: Qwen 3 Coder

+

Qwen is specialized for coding tasks:

+
#!/bin/bash
+
+# Qwen 3 Coder - Specialized for Code
+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 "$qwen_response" | jq -r '.choices[0].message.content'
+ +

Code Example: Text-to-Speech

+

Generate speech from text and save to a file:

+
#!/bin/bash
+
+# Text-to-Speech - Save to file
+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
+
+# Check if file was created
+if [ -f speech.mp3 ]; then
+  echo "✓ Speech file created successfully"
+fi
+ +

Understanding the Code

+ +

1. Using curl for HTTP Requests

+

The curl command makes HTTP POST requests to the API endpoints:

+ + +

2. Command Substitution

+

The $(command) syntax captures command output into a variable:

+
response=$(curl -s "https://api.example.com")
+echo "$response"
+ +

3. JSON Parsing with jq

+

The jq tool extracts data from JSON responses:

+
echo "$response" | jq -r '.choices[0].message.content'
+# -r flag removes quotes from string output
+ +

Common Issues

+ +
+ Issue: "jq: command not found"
+ Solution: Install jq: apk add jq (Alpine) or apt-get install jq (Debian/Ubuntu) +
+ +
+ Issue: "curl: (60) SSL certificate problem"
+ Solution: Install ca-certificates: apk add ca-certificates +
+ +
+ Issue: Empty or error response
+ Solution: Remove -s flag from curl to see error messages +
+ +

API Endpoints

+ + +

Next Steps

+

Try modifying the examples:

+ + +

← Back to Main Page

+ + + + diff --git a/languages/bash/speech.mp3 b/languages/bash/speech.mp3 new file mode 100644 index 0000000..0fc8796 Binary files /dev/null and b/languages/bash/speech.mp3 differ