Skip to content

Commit 2ba92bc

Browse files
committed
docs: improve readability with docstrings
1 parent 9e88bce commit 2ba92bc

3 files changed

Lines changed: 40 additions & 8 deletions

File tree

listeners/actions/actions.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import logging
22

33

4-
# Handle feedback buttons (thumbs up/down)
54
def handle_feedback(ack, body, client, logger: logging.Logger):
5+
"""
6+
Handles user feedback on AI-generated responses via thumbs up/down buttons.
7+
8+
Args:
9+
ack: Function to acknowledge the action request
10+
body: Action payload containing feedback details (message, channel, user, action value)
11+
client: Slack WebClient for making API calls
12+
logger: Logger instance for debugging and error tracking
13+
"""
614
try:
715
ack()
816
message_ts = body["message"]["ts"]

listeners/assistant/assistant.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,22 @@
1414
assistant = Assistant()
1515

1616

17-
# This listener is invoked when a human user opened an assistant thread
1817
@assistant.thread_started
1918
def start_assistant_thread(
2019
say: Say,
2120
get_thread_context: GetThreadContext,
2221
set_suggested_prompts: SetSuggestedPrompts,
2322
logger: logging.Logger,
2423
):
24+
"""
25+
Handle the assistant thread start event by greeting the user and setting suggested prompts.
26+
27+
Args:
28+
say: Function to send messages to the thread from the app
29+
get_thread_context: Function to retrieve thread context information
30+
set_suggested_prompts: Function to configure suggested prompt options
31+
logger: Logger instance for error tracking
32+
"""
2533
try:
2634
say("How can I help you?")
2735

@@ -65,6 +73,18 @@ def respond_in_assistant_thread(
6573
say: Say,
6674
set_status: SetStatus,
6775
):
76+
"""
77+
Handles when users send messages or select a prompt in an assistant thread and generate AI responses:
78+
79+
Args:
80+
client: Slack WebClient for making API calls
81+
context: Bolt context containing channel and thread information
82+
get_thread_context: Function to retrieve thread context (e.g., referred channel)
83+
logger: Logger instance for error tracking
84+
payload: Event payload with message details (channel, user, text, etc.)
85+
say: Function to send messages to the thread
86+
set_status: Function to update the assistant's status
87+
"""
6888
try:
6989
channel_id = payload["channel"]
7090
team_id = payload["team"]
@@ -84,8 +104,6 @@ def respond_in_assistant_thread(
84104
)
85105

86106
if user_message == "Can you generate a brief summary of the referred channel?":
87-
# the logic here requires the additional bot scopes:
88-
# channels:join, channels:history, groups:history
89107
thread_context = get_thread_context()
90108
referred_channel_id = thread_context.get("channel_id")
91109
try:

listeners/events/app_mentioned.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@
55
from ..llm_caller import call_llm
66
from ..views.feedback_block import create_feedback_block
77

8-
"""
9-
Handles the event when the app is mentioned in a Slack conversation
10-
and generates an AI response.
11-
"""
128

139

1410
def app_mentioned_callback(client: WebClient, event: dict, logger: Logger, say: Say):
11+
"""
12+
Handles the event when the app is mentioned in a Slack conversation
13+
and generates an AI response.
14+
15+
Args:
16+
client: Slack WebClient for making API calls
17+
event: Event payload containing mention details (channel, user, text, etc.)
18+
logger: Logger instance for error tracking
19+
say: Function to send messages to the thread from the app
20+
"""
1521
try:
1622
channel_id = event.get("channel")
1723
team_id = event.get("team")

0 commit comments

Comments
 (0)