Skip to content

Commit

Permalink
Merge pull request #30 from nalbam/main
Browse files Browse the repository at this point in the history
Refactor chat_update function to add consistent delay before sending …
  • Loading branch information
nalbam authored Sep 5, 2024
2 parents 4f23f54 + c8a6dd4 commit 927b988
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ env:
MODEL_ID_TEXT: ${{ vars.MODEL_ID_TEXT }}
PERSONAL_MESSAGE: ${{ vars.PERSONAL_MESSAGE }}
SYSTEM_MESSAGE: ${{ vars.SYSTEM_MESSAGE }}
SLACK_SAY_INTERVAL: ${{ vars.SLACK_SAY_INTERVAL }}

AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand Down Expand Up @@ -61,6 +62,7 @@ jobs:
echo "SLACK_SIGNING_SECRET=${SLACK_SIGNING_SECRET}" >> .env
echo "PERSONAL_MESSAGE=${PERSONAL_MESSAGE}" >> .env
echo "SYSTEM_MESSAGE=${SYSTEM_MESSAGE}" >> .env
echo "SLACK_SAY_INTERVAL=${SLACK_SAY_INTERVAL}" >> .env
- name: Deploy to AWS Lambda 🚀
run: npx serverless deploy --region us-east-1
5 changes: 4 additions & 1 deletion handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
MAX_LEN_SLACK = int(os.environ.get("MAX_LEN_SLACK", 2500))
MAX_LEN_BEDROCK = int(os.environ.get("MAX_LEN_BEDROCK", 4000))

SLACK_SAY_INTERVAL = float(os.environ.get("SLACK_SAY_INTERVAL", 0))

BOT_CURSOR = os.environ.get("BOT_CURSOR", ":robot_face:")

MSG_KNOWLEDGE = "지식 기반 검색 중... " + BOT_CURSOR
Expand Down Expand Up @@ -212,7 +214,8 @@ def chat_update(say, channel, thread_ts, latest_ts, message="", continue_thread=
# Update the message
app.client.chat_update(channel=channel, ts=latest_ts, text=text)
else:
time.sleep(1)
if SLACK_SAY_INTERVAL > 0:
time.sleep(SLACK_SAY_INTERVAL)

try:
# Send a new message
Expand Down

0 comments on commit 927b988

Please sign in to comment.