diff --git a/listeners/assistant/assistant_thread_started.py b/listeners/assistant/assistant_thread_started.py index 0957f0d..72e1fc6 100644 --- a/listeners/assistant/assistant_thread_started.py +++ b/listeners/assistant/assistant_thread_started.py @@ -1,12 +1,12 @@ from logging import Logger -from slack_bolt import Say, SetSuggestedPrompts +from slack_bolt import BoltAgent, Say def assistant_thread_started( - say: Say, - set_suggested_prompts: SetSuggestedPrompts, + agent: BoltAgent, logger: Logger, + say: Say, ): """ Handle the assistant thread start event by greeting the user and setting suggested prompts. @@ -18,7 +18,7 @@ def assistant_thread_started( """ try: say("What would you like to do today?") - set_suggested_prompts( + agent.set_suggested_prompts( prompts=[ { "title": "Prompt a task with thinking steps", diff --git a/listeners/assistant/message.py b/listeners/assistant/message.py index bb78cb8..0cc4e6d 100644 --- a/listeners/assistant/message.py +++ b/listeners/assistant/message.py @@ -2,8 +2,7 @@ from logging import Logger from openai.types.responses import ResponseInputParam -from slack_bolt import BoltAgent, BoltContext, Say, SetStatus -from slack_sdk import WebClient +from slack_bolt import BoltAgent, Say from slack_sdk.models.messages.chunk import ( MarkdownTextChunk, PlanUpdateChunk, @@ -16,36 +15,24 @@ def message( agent: BoltAgent, - client: WebClient, - context: BoltContext, logger: Logger, message: dict, - payload: dict, say: Say, - set_status: SetStatus, ): """ Handles when users send messages or select a prompt in an assistant thread and generate AI responses: Args: agent: BoltAgent for making API calls - client: Slack WebClient for making API calls - context: Bolt context containing channel and thread information logger: Logger instance for error tracking - payload: Event payload with message details (channel, user, text, etc.) + message: Dictionary with message information say: Function to send messages to the thread - set_status: Function to update the assistant's status """ try: - channel_id = payload["channel"] - team_id = context.team_id - thread_ts = payload["thread_ts"] - user_id = context.user_id - # The first example shows a message with thinking steps that has different # chunks to construct and update a plan alongside text outputs. if message["text"] == "Wonder a few deep thoughts.": - set_status( + agent.set_status( status="thinking...", loading_messages=[ "Teaching the hamsters to type faster…", @@ -125,7 +112,7 @@ def message( # This second example shows a generated text response for a provided prompt # displayed as a timeline. else: - set_status( + agent.set_status( status="thinking...", loading_messages=[ "Teaching the hamsters to type faster…", diff --git a/listeners/events/app_mentioned.py b/listeners/events/app_mentioned.py index b51801d..e843075 100644 --- a/listeners/events/app_mentioned.py +++ b/listeners/events/app_mentioned.py @@ -2,34 +2,31 @@ from openai.types.responses import ResponseInputParam from slack_bolt import BoltAgent, Say -from slack_sdk import WebClient from agent.llm_caller import call_llm from listeners.views.feedback_block import create_feedback_block -def app_mentioned_callback(agent: BoltAgent, client: WebClient, event: dict, logger: Logger, say: Say): +def app_mentioned_callback( + agent: BoltAgent, + event: dict, + logger: Logger, + say: Say, +): """ Handles the event when the app is mentioned in a Slack conversation and generates an AI response. Args: agent: BoltAgent for making API calls - client: Slack WebClient for making API calls event: Event payload containing mention details (channel, user, text, etc.) logger: Logger instance for error tracking say: Function to send messages to the thread from the app """ try: - channel_id = event.get("channel") - team_id = event.get("team") text = event.get("text") - thread_ts = event.get("thread_ts") or event.get("ts") - user_id = event.get("user") - client.assistant_threads_setStatus( - channel_id=channel_id, - thread_ts=thread_ts, + agent.set_status( status="thinking...", loading_messages=[ "Teaching the hamsters to type faster…",