Skip to content

Commit 3827d72

Browse files
zimegsrtaalejmwbrooks
authored
refactor: replace assistant_threads_setStatus method with assistant class set_status (#12)
Co-authored-by: Ale Mercado <maria.mercado@slack-corp.com> Co-authored-by: Michael Brooks <mbrooks@slack-corp.com>
1 parent c4ba883 commit 3827d72

2 files changed

Lines changed: 20 additions & 19 deletions

File tree

listeners/assistant/assistant.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
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
6-
from slack_sdk.models.blocks import Block, ContextActionsBlock, FeedbackButtonsElement, FeedbackButtonObject
7+
from slack_sdk.models.blocks import Block, ContextActionsBlock, FeedbackButtonObject, FeedbackButtonsElement
78

89
from ..llm_caller import call_llm
910

@@ -83,23 +84,27 @@ def start_assistant_thread(
8384
# This listener is invoked when the human user sends a reply in the assistant thread
8485
@assistant.user_message
8586
def respond_in_assistant_thread(
86-
payload: dict,
87-
logger: logging.Logger,
88-
context: BoltContext,
8987
client: WebClient,
88+
context: BoltContext,
89+
logger: logging.Logger,
90+
payload: dict,
9091
say: Say,
92+
set_status: SetStatus,
9193
):
9294
try:
9395
channel_id = payload["channel"]
9496
thread_ts = payload["thread_ts"]
9597

96-
loading_messages = [
97-
"Teaching the hamsters to type faster…",
98-
"Untangling the internet cables…",
99-
"Consulting the office goldfish…",
100-
"Polishing up the response just for you…",
101-
"Convincing the AI to stop overthinking…",
102-
]
98+
set_status(
99+
status="Drafting...",
100+
loading_messages=[
101+
"Teaching the hamsters to type faster…",
102+
"Untangling the internet cables…",
103+
"Consulting the office goldfish…",
104+
"Polishing up the response just for you…",
105+
"Convincing the AI to stop overthinking…",
106+
],
107+
)
103108

104109
replies = client.conversations_replies(
105110
channel=context.channel_id,
@@ -114,10 +119,6 @@ def respond_in_assistant_thread(
114119

115120
returned_message = call_llm(messages_in_thread)
116121

117-
client.assistant_threads_setStatus(
118-
channel_id=channel_id, thread_ts=thread_ts, status="Bolt is typing", loading_messages=loading_messages
119-
)
120-
121122
stream_response = client.chat_startStream(
122123
channel=channel_id,
123124
thread_ts=thread_ts,

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)