Skip to content

Commit 291ef2d

Browse files
committed
fix: update imports after file structure refactor
1 parent e1bc98a commit 291ef2d

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

listeners/assistant/assistant.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from slack_sdk import WebClient
66
from slack_sdk.errors import SlackApiError
77

8-
from .llm_caller import call_llm
8+
from ..llm_caller import call_llm
99

1010
# Refer to https://tools.slack.dev/bolt-python/concepts/assistant/ for more details
1111
assistant = Assistant()
@@ -72,13 +72,17 @@ def respond_in_assistant_thread(
7272
thread_context = get_thread_context()
7373
referred_channel_id = thread_context.get("channel_id")
7474
try:
75-
channel_history = client.conversations_history(channel=referred_channel_id, limit=50)
75+
channel_history = client.conversations_history(
76+
channel=referred_channel_id, limit=50
77+
)
7678
except SlackApiError as e:
7779
if e.response["error"] == "not_in_channel":
7880
# If this app's bot user is not in the public channel,
7981
# we'll try joining the channel and then calling the same API again
8082
client.conversations_join(channel=referred_channel_id)
81-
channel_history = client.conversations_history(channel=referred_channel_id, limit=50)
83+
channel_history = client.conversations_history(
84+
channel=referred_channel_id, limit=50
85+
)
8286
else:
8387
raise e
8488

listeners/events/__init__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,25 @@
1515
def register(app: App):
1616
app.event("assistant_thread_started")(start_thread_with_suggested_prompts)
1717
app.event("assistant_thread_context_changed")(save_new_thread_context)
18-
app.event("message", matchers=[is_user_message_event_in_assistant_thread])(respond_to_user_message)
18+
app.event("message", matchers=[is_user_message_event_in_assistant_thread])(
19+
respond_to_user_message
20+
)
1921
app.event("message", matchers=[is_message_event_in_assistant_thread])(just_ack)
2022

2123

2224
def is_message_event_in_assistant_thread(body: Dict[str, Any]) -> bool:
2325
if is_event(body):
24-
return body["event"]["type"] == "message" and body["event"].get("channel_type") == "im"
26+
return (
27+
body["event"]["type"] == "message"
28+
and body["event"].get("channel_type") == "im"
29+
)
2530
return False
2631

2732

2833
def is_user_message_event_in_assistant_thread(body: Dict[str, Any]) -> bool:
29-
return is_message_event_in_assistant_thread(body) and body["event"].get("subtype") in (None, "file_share")
34+
return is_message_event_in_assistant_thread(body) and body["event"].get(
35+
"subtype"
36+
) in (None, "file_share")
3037

3138

3239
def just_ack():

listeners/events/thread_context_store.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ def _find_parent_message(
2323
)
2424
if response.get("messages"):
2525
for message in response.get("messages"):
26-
if message.get("subtype") is None and message.get("user") == context.bot_user_id:
26+
if (
27+
message.get("subtype") is None
28+
and message.get("user") == context.bot_user_id
29+
):
2730
return message
2831

2932

@@ -34,7 +37,9 @@ def get_thread_context(
3437
channel_id: str,
3538
thread_ts: str,
3639
) -> Optional[dict]:
37-
parent_message = _find_parent_message(context=context, client=client, channel_id=channel_id, thread_ts=thread_ts)
40+
parent_message = _find_parent_message(
41+
context=context, client=client, channel_id=channel_id, thread_ts=thread_ts
42+
)
3843
if parent_message is not None and parent_message.get("metadata") is not None:
3944
return parent_message["metadata"]["event_payload"]
4045

0 commit comments

Comments
 (0)