Combine scripts into pipeline

First successful run from TG to ChatGPT back to TG!
This commit is contained in:
ekzyis 2023-09-09 17:52:03 +02:00
parent 672d66d6d9
commit 197ae8fe3c
2 changed files with 7 additions and 9 deletions

View File

@ -1,14 +1,9 @@
#!/usr/bin/env bash
usage() {
echo "Usage: $(basename $0) offset"
echo "Usage: $(basename $0) [offset]"
}
if [ ! $# -eq 1 ]; then
usage
exit 1
fi
OFFSET=$1
if [ -z $TELEGRAM_BOT_TOKEN ]; then
@ -35,7 +30,10 @@ do
prompt="${text:8}"
chat_id="$(echo "$R" | jq -e '.result[0].message.chat.id')"
echo "Received prompt "$prompt" in chat $chat_id"
# TODO: send prompt to OpenAI and stream response back to chat
# TODO: update parent message id such that GPT knows context of previous requests
gpt2tg_prompt 9e76b8fc-e37e-4dcb-8d8d-d074e5480047 60b11ad6-25c1-4209-b6b4-84482dd774fa "$prompt" | \
gpt2tg_prompt_streamparser | \
gpt2tg_telegram_sender $chat_id
fi
fi
OFFSET=$(( update_id + 1))

View File

@ -6,10 +6,10 @@
# exit if any command fails
usage() {
echo "Usage: $(basename $0) <chat_id> <file>"
echo "Usage: $(basename $0) <chat_id>"
}
if [ ! $# -eq 2 ]; then
if [ ! $# -eq 1 ]; then
usage
exit 1
fi