Skip to content

Commit b3b2d11

Browse files
committed
feat: use 'agent' argument and 'agent.chat_stream()'
1 parent 0dcc875 commit b3b2d11

2 files changed

Lines changed: 9 additions & 23 deletions

File tree

listeners/assistant/message.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from logging import Logger
33

44
from openai.types.responses import ResponseInputParam
5-
from slack_bolt import BoltContext, Say, SetStatus
5+
from slack_bolt import BoltAgent, BoltContext, Say, SetStatus
66
from slack_sdk import WebClient
77
from slack_sdk.models.messages.chunk import (
88
MarkdownTextChunk,
@@ -15,6 +15,7 @@
1515

1616

1717
def message(
18+
agent: BoltAgent,
1819
client: WebClient,
1920
context: BoltContext,
2021
logger: Logger,
@@ -27,6 +28,7 @@ def message(
2728
Handles when users send messages or select a prompt in an assistant thread and generate AI responses:
2829
2930
Args:
31+
agent: BoltAgent for making API calls
3032
client: Slack WebClient for making API calls
3133
context: Bolt context containing channel and thread information
3234
logger: Logger instance for error tracking
@@ -56,13 +58,7 @@ def message(
5658

5759
time.sleep(4)
5860

59-
streamer = client.chat_stream(
60-
channel=channel_id,
61-
recipient_team_id=team_id,
62-
recipient_user_id=user_id,
63-
thread_ts=thread_ts,
64-
task_display_mode="plan",
65-
)
61+
streamer = agent.chat_stream(task_display_mode="plan")
6662
streamer.append(
6763
chunks=[
6864
MarkdownTextChunk(
@@ -140,13 +136,7 @@ def message(
140136
],
141137
)
142138

143-
streamer = client.chat_stream(
144-
channel=channel_id,
145-
recipient_team_id=team_id,
146-
recipient_user_id=user_id,
147-
thread_ts=thread_ts,
148-
task_display_mode="timeline",
149-
)
139+
streamer = agent.chat_stream(task_display_mode="timeline")
150140
prompts: ResponseInputParam = [
151141
{
152142
"role": "user",

listeners/events/app_mentioned.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
from logging import Logger
22

33
from openai.types.responses import ResponseInputParam
4-
from slack_bolt import Say
4+
from slack_bolt import BoltAgent, Say
55
from slack_sdk import WebClient
66

77
from agent.llm_caller import call_llm
88
from listeners.views.feedback_block import create_feedback_block
99

1010

11-
def app_mentioned_callback(client: WebClient, event: dict, logger: Logger, say: Say):
11+
def app_mentioned_callback(agent: BoltAgent, client: WebClient, event: dict, logger: Logger, say: Say):
1212
"""
1313
Handles the event when the app is mentioned in a Slack conversation
1414
and generates an AI response.
1515
1616
Args:
17+
agent: BoltAgent for making API calls
1718
client: Slack WebClient for making API calls
1819
event: Event payload containing mention details (channel, user, text, etc.)
1920
logger: Logger instance for error tracking
@@ -39,12 +40,7 @@ def app_mentioned_callback(client: WebClient, event: dict, logger: Logger, say:
3940
],
4041
)
4142

42-
streamer = client.chat_stream(
43-
channel=channel_id,
44-
recipient_team_id=team_id,
45-
recipient_user_id=user_id,
46-
thread_ts=thread_ts,
47-
)
43+
streamer = agent.chat_stream()
4844
prompts: ResponseInputParam = [
4945
{
5046
"role": "user",

0 commit comments

Comments
 (0)