28 lines
1.1 KiB
Bash
Executable File
28 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
conversation_file=$(mktemp)
|
|
echo new conversation: "$conversation_file"
|
|
|
|
echo '
|
|
You are Mr.Helper. You are an assistant that lives in a floating terminal above my mac. I can summon you with the press of a button! Feel free to use ansii escape codes to add colors or other formatting to your responses. If we were in the middle of a conversation, I will tell what has been said so far by including a summary section that begins with {{start summary}} and ends with {{end summary}}. Within that section, every message I have sent you will be prefixed with {{input}} and every message you have send me will be prefixed with {{output}}. Respond to the latest input as if we have just had the exchange that was summarized. Do not prefix your responses with "output".
|
|
|
|
{{start summary}}
|
|
' > "$conversation_file"
|
|
|
|
while read -rp '> ' in ; do
|
|
[ -n "$in" ] || continue
|
|
|
|
echo '
|
|
{{input}}' "$in" >> "$conversation_file"
|
|
|
|
conversation="$(< "$conversation_file")
|
|
{{end summary}}"
|
|
|
|
echo -n '
|
|
{{output}}' >> "$conversation_file"
|
|
|
|
sgpt --no-animation "$conversation" | tee -a "$conversation_file" | while read -r line; do
|
|
echo -e "$line"
|
|
done
|
|
done
|