Skip to content

Commit 97b43a0

Browse files
committed
Merge branch 'ai-apps' into feature/app-mention
2 parents 7db511f + 3827d72 commit 97b43a0

2 files changed

Lines changed: 20 additions & 11 deletions

File tree

listeners/assistant/assistant.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
2-
from typing import List, Dict
3-
from slack_bolt import Assistant, BoltContext, Say, SetSuggestedPrompts
2+
from typing import Dict, List
3+
4+
from slack_bolt import Assistant, BoltContext, Say, SetStatus, SetSuggestedPrompts
45
from slack_bolt.context.get_thread_context import GetThreadContext
56
from slack_sdk import WebClient
67
from slack_sdk.errors import SlackApiError
@@ -57,12 +58,13 @@ def start_assistant_thread(
5758
# This listener is invoked when the human user sends a reply in the assistant thread
5859
@assistant.user_message
5960
def respond_in_assistant_thread(
60-
payload: dict,
61-
logger: logging.Logger,
61+
client: WebClient,
6262
context: BoltContext,
6363
get_thread_context: GetThreadContext,
64-
client: WebClient,
64+
logger: logging.Logger,
65+
payload: dict,
6566
say: Say,
67+
set_status: SetStatus,
6668
):
6769
try:
6870
channel_id = payload["channel"]
@@ -71,6 +73,17 @@ def respond_in_assistant_thread(
7173
user_id = payload["user"]
7274
user_message = payload["text"]
7375

76+
set_status(
77+
status="Drafting...",
78+
loading_messages=[
79+
"Teaching the hamsters to type faster…",
80+
"Untangling the internet cables…",
81+
"Consulting the office goldfish…",
82+
"Polishing up the response just for you…",
83+
"Convincing the AI to stop overthinking…",
84+
],
85+
)
86+
7487
if user_message == "Can you generate a brief summary of the referred channel?":
7588
# the logic here requires the additional bot scopes:
7689
# channels:join, channels:history, groups:history
@@ -106,10 +119,6 @@ def respond_in_assistant_thread(
106119

107120
returned_message = call_llm(messages_in_thread)
108121

109-
client.assistant_threads_setStatus(
110-
channel_id=channel_id, thread_ts=thread_ts, status="Bolt is typing", loading_messages=loading_messages
111-
)
112-
113122
stream_response = client.chat_startStream(
114123
channel=channel_id,
115124
recipient_team_id=team_id,

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
slack-sdk==3.36.0.dev3
2-
slack-bolt>=1.21,<2
1+
slack-sdk==3.36.0.dev5
2+
slack-bolt==1.26.0.dev2
33

44
# If you use a different LLM vendor, replace this dependency
55
openai

0 commit comments

Comments
 (0)