Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix slack bot "message link not found" #7

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ Index a Slack export to the Janelia class in Weaviate:

./index_slack.py -i ./data/slack/slack_export_Janelia-Software_ALL -c Janelia

./index_slack.py -i ./data/slack/janelia-software/slack_to_2023-05-18 -c Janelia

Add a wiki export:

./index_wiki.py -i ./data/wiki -c Janelia
Expand Down
8 changes: 7 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ services:
SLACK_TOKEN:

slack-bot:
image: ghcr.io/janeliascicomp/gpt-semantic-search-slack-bot:0.1.5
image: ghcr.io/janeliascicomp/gpt-semantic-search-slack-bot:0.1.6
restart: unless-stopped
environment:
WEAVIATE_URL: 'http://weaviate:8080'
Expand All @@ -43,3 +43,9 @@ services:
# volumes:
# - ./slack_app.py:/app/slack_app.py:ro
# - ./generate_full_response.py:/app/generate_full_response.py:ro

# To push an update to the docker image, run the following command and fill in the blanks:
# docker buildx build --push --build-arg GIT_TAG=0.1.5 --progress=plain --platform linux/arm64,linux/amd64 --tag ghcr.io/janeliascicomp/gpt-semantic-search-___:0._._ -f Dockerfile_ .
# docker buildx build --push --platform linux/arm64,linux/amd64 --tag ghcr.io/janeliascicomp/gpt-semantic-search-slack-bot:0.1.5 -f Dockerfile_slack .

# docker buildx build --push --build-arg GIT_TAG=0.1.6 --progress=plain --platform linux/arm64,linux/amd64 --tag ghcr.io/janeliascicomp/gpt-semantic-search-slack-bot:0.1.6 -f Dockerfile_slack .
11 changes: 10 additions & 1 deletion generate_full_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,21 @@ def generate_response(self, query):
if source.lower() == 'slack':
channel_id = extra_info['channel']
ts = extra_info['ts']
msg += f"• {source}: <{self.get_message_link(self.slack_client, channel_id, ts)}|{text}>\n"
# Only add new link when a slack message is found
try:
message_link = self.get_message_link(self.slack_client, channel_id, ts)
if message_link:
msg += f"• {source}: <{message_link}|{text}>\n"
else:
logger.warning(f"Message not found for channel: {channel_id}, ts: {ts}")
except Exception as e:
logger.warning(f"Error fetching Slack message link: {str(e)}")
else:
msg += f"• {source}: <{extra_info['link']}|{extra_info['title']}>\n"

return msg


# Example usage
if __name__ == "__main__":
weaviate_url = "http://localhost:8777"
Expand Down
3 changes: 2 additions & 1 deletion slack_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def animate():
response = "I'm sorry, but it's taking me longer than expected to generate a response. Could you try rephrasing your question or asking something else?"

except Exception as e:
response = f"Oops! Something went wrong: {str(e)}"
response = f"Oops! Something went wrong!"
logger.error(e)

finally:
# Stop the animation thread
Expand Down