-
Notifications
You must be signed in to change notification settings - Fork 0
/
curltest.sh
executable file
·66 lines (55 loc) · 1.44 KB
/
curltest.sh
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
set -euo pipefail
# Force unbuffered output
exec 1>/dev/stdout
baseurl=https://yatti.id.local/v1
kb=appliedanthropology
query="Create a detailed summary of Christopher Boehm’s Hierarchy in the Forest: The Evolution of Egalitarian Behavior."
reference="&reference=$(urlencode 'the quick brown fox jumped over the lazy dog.')"
context_only='' #'&context_only'
tmpfile="/tmp/$$-$RANDOM"
#---
echo "+++ TEST kb-query"
declare -p baseurl kb query reference context_only
#---
printline
echo -e "+++ TEST GET KB CONFIG"
curl -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-s "$baseurl/$kb/?q=/config" \
>"$tmpfile"
jq -r .response "$tmpfile"
#---
printline
echo "+++ TEST GET KB LIST"
curl -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-s "$baseurl/list" \
>"$tmpfile"
jq -r .response "$tmpfile"
#---
printline
echo "+++ TEST QUERY kb-query"
curl -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-s "$baseurl/$kb/?q=$(urlencode "$query")${context_only}${reference}" \
>"$tmpfile"
jq . "$tmpfile"
#---
printline
echo "+++ TEST kb-query PRINT .response ONLY"
jq -r .response "$tmpfile"
#---
printline
echo "+++ TEST GET HELP kb-query"
curl -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-s "$baseurl/help" \
>"$tmpfile"
jq -r .response "$tmpfile"
rm -f "$tmpfile"
#fin