-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Di Wang <[email protected]>
- Loading branch information
Showing
2 changed files
with
8 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
from slack_sdk import WebClient | ||
from slack_sdk.errors import SlackApiError | ||
from langchain_core.tools import tool | ||
import os | ||
from slack_sdk.errors import SlackApiError | ||
|
||
from app.dependencies.slack_client import slack_client | ||
|
||
|
||
@tool() | ||
def get_thread_msg(channel_id: str, thread_ts: str): | ||
""" | ||
Retrieves messages from a specified thread. | ||
""" | ||
client = WebClient(token=os.getenv('SLACK_BOT_TOKEN')) | ||
try: | ||
response = client.conversations_replies(channel=channel_id, ts=thread_ts) | ||
response = slack_client.conversations_replies(channel=channel_id, ts=thread_ts) | ||
messages = response['messages'] | ||
return {'thread_messages': messages} | ||
except SlackApiError as e: | ||
print(f"Error fetching thread messages: {e}") | ||
return {'error': str(e)} | ||
|