|
2 | 2 | from logging import Logger |
3 | 3 |
|
4 | 4 | from openai.types.responses import ResponseInputParam |
5 | | -from slack_bolt import BoltAgent, BoltContext, Say, SetStatus |
6 | | -from slack_sdk import WebClient |
| 5 | +from slack_bolt import BoltAgent, Say |
7 | 6 | from slack_sdk.models.messages.chunk import ( |
8 | 7 | MarkdownTextChunk, |
9 | 8 | PlanUpdateChunk, |
|
16 | 15 |
|
17 | 16 | def message( |
18 | 17 | agent: BoltAgent, |
19 | | - client: WebClient, |
20 | | - context: BoltContext, |
21 | 18 | logger: Logger, |
22 | 19 | message: dict, |
23 | | - payload: dict, |
24 | 20 | say: Say, |
25 | | - set_status: SetStatus, |
26 | 21 | ): |
27 | 22 | """ |
28 | 23 | Handles when users send messages or select a prompt in an assistant thread and generate AI responses: |
29 | 24 |
|
30 | 25 | Args: |
31 | 26 | agent: BoltAgent for making API calls |
32 | | - client: Slack WebClient for making API calls |
33 | | - context: Bolt context containing channel and thread information |
34 | 27 | logger: Logger instance for error tracking |
35 | | - payload: Event payload with message details (channel, user, text, etc.) |
| 28 | + message: Dictionary with message information |
36 | 29 | say: Function to send messages to the thread |
37 | | - set_status: Function to update the assistant's status |
38 | 30 | """ |
39 | 31 | try: |
40 | | - channel_id = payload["channel"] |
41 | | - team_id = context.team_id |
42 | | - thread_ts = payload["thread_ts"] |
43 | | - user_id = context.user_id |
44 | | - |
45 | 32 | # The first example shows a message with thinking steps that has different |
46 | 33 | # chunks to construct and update a plan alongside text outputs. |
47 | 34 | if message["text"] == "Wonder a few deep thoughts.": |
48 | | - set_status( |
| 35 | + agent.set_status( |
49 | 36 | status="thinking...", |
50 | 37 | loading_messages=[ |
51 | 38 | "Teaching the hamsters to type faster…", |
@@ -125,7 +112,7 @@ def message( |
125 | 112 | # This second example shows a generated text response for a provided prompt |
126 | 113 | # displayed as a timeline. |
127 | 114 | else: |
128 | | - set_status( |
| 115 | + agent.set_status( |
129 | 116 | status="thinking...", |
130 | 117 | loading_messages=[ |
131 | 118 | "Teaching the hamsters to type faster…", |
|
0 commit comments