From 197ae8fe3c748052fa9618b2e2ce4c72600e7fef Mon Sep 17 00:00:00 2001 From: ekzyis Date: Sat, 9 Sep 2023 17:52:03 +0200 Subject: [PATCH] Combine scripts into pipeline First successful run from TG to ChatGPT back to TG! --- telegram_poll.sh | 12 +++++------- telegram_sender.sh | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/telegram_poll.sh b/telegram_poll.sh index 5f117ba..e2ea7ad 100644 --- a/telegram_poll.sh +++ b/telegram_poll.sh @@ -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)) diff --git a/telegram_sender.sh b/telegram_sender.sh index 37b893d..3268831 100644 --- a/telegram_sender.sh +++ b/telegram_sender.sh @@ -6,10 +6,10 @@ # exit if any command fails usage() { - echo "Usage: $(basename $0) " + echo "Usage: $(basename $0) " } -if [ ! $# -eq 2 ]; then +if [ ! $# -eq 1 ]; then usage exit 1 fi