-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackend-poc.sh
More file actions
executable file
·38 lines (31 loc) · 1015 Bytes
/
backend-poc.sh
File metadata and controls
executable file
·38 lines (31 loc) · 1015 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
# Proof of Concept: AIWB as headless backend
# Usage: ./backend-poc.sh '{"prompt":"test","provider":"gemini","model":"2.5-flash"}'
set -euo pipefail
# Source core modules (no UI dependencies)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/lib/api.sh"
# Parse JSON input
json_input="${1:-}"
if [[ -z "$json_input" ]]; then
echo '{"error": "No input provided"}' >&2
exit 1
fi
# Extract parameters
prompt=$(echo "$json_input" | jq -r '.prompt // empty')
provider=$(echo "$json_input" | jq -r '.provider // "gemini"')
model=$(echo "$json_input" | jq -r '.model // "2.5-flash"')
if [[ -z "$prompt" ]]; then
echo '{"error": "Missing prompt"}' >&2
exit 1
fi
# Call API (no UI!)
result=$(call_api "$prompt" "$provider" "$model" 2>&1)
exit_code=$?
# Return JSON response
if [[ $exit_code -eq 0 ]]; then
echo "{\"result\": $(echo "$result" | jq -Rs .)}" | jq -c
else
echo "{\"error\": $(echo "$result" | jq -Rs .)}" | jq -c >&2
exit 1
fi