-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtry.sh
executable file
·72 lines (66 loc) · 1.71 KB
/
try.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
67
68
69
70
71
72
#!/usr/bin/env bash
JSON_SCHEMA='{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"population": {
"type": "integer"
},
"touristic": {
"type": "boolean"
},
"wtf": {
"type": "string",
"nullable": true
},
"mayor": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"hometown": {
"type": "string"
}
}
},
"nicknames": {
"type": "array",
"items": {
"type": "string",
"nullable": true
},
"minItems": 7
},
"weather": {
"type": "string",
"enum": ["sunny", "rainy", "cloudy", "snowy"]
},
"randomFact": {
"type": "string",
"pattern": "[0-9]+ \\w+"
}
}
}'
JSON_SCHEMA="${1:-$JSON_SCHEMA}"
USER="New york city."
USER="${2:-$USER}"
set -xe
GRAMMAR="$(bun run src/index.ts "${JSON_SCHEMA}")"
SYSTEM="You are a very accurate assistant that only writes JSON, strictly following the user instructions."
echo -e "GRAMMAR\n=======\n\n${GRAMMAR}\n\n"
MODEL="${HOME}/.cache/lm-studio/models/TheBloke/OpenHermes-2.5-Mistral-7B-GGUF/openhermes-2.5-mistral-7b.Q4_K_M.gguf"
MODEL="${3:-$MODEL}"
../llama.cpp/main \
-m "${MODEL}" \
--color \
-c 2048 \
--temp 0.7 \
--repeat_penalty 1.1 \
-n \
-1 \
-p "<|im_start|>system\n${SYSTEM}<|im_end|>\n<|im_start|>user\n${USER}<|im_end|>\n<|im_start|>assistant" \
-n 400 \
--grammar "${GRAMMAR}"