Skip to content

Commit

Permalink
Cleanup graph
Browse files Browse the repository at this point in the history
Signed-off-by: Di Wang <[email protected]>
  • Loading branch information
hemslo committed Feb 17, 2024
1 parent 9b6d126 commit e72eff4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
18 changes: 3 additions & 15 deletions app/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,14 @@ class AgentState(TypedDict):
"tools": slack_toolkit.get_tools(),
"system_prompt": "You are a slack toolkit.",
},
"WebrcaCreate": {
"tools": [webrca_create],
"system_prompt": "You are a webrca incident creator.",
},
"DatetimeProvider": {
"tools": [datetime_provider],
"system_prompt": "You are a datetime provider.",
},
"ThreadSummary": {
"tools": [get_thread_msg],
"system_prompt": "You are a slack thread messages summarizer.",
},
"DatetimeProvider": {
"tools": [datetime_provider],
"system_prompt": "You are a datetime provider.",
"WebrcaCreate": {
"tools": [webrca_create],
"system_prompt": "You are a webrca incident creator.",
},
"ThreadSummary": {
"tools": [get_thread_msg],
"system_prompt": "You are a slack thread messages summarizer.",
}
}

SUPERVISOR_MEMBERS = {k: v["system_prompt"] for k, v in GRAPH.items()}
Expand Down
11 changes: 5 additions & 6 deletions app/tools/get_thread_msg.py
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)}

0 comments on commit e72eff4

Please sign in to comment.