-
Notifications
You must be signed in to change notification settings - Fork 17
refactor: breakup assistant.py into separate files #25
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9221080
ref: breakup assistant.py into separate files
srtaalej 1ed3461
docs: update README to reflect file structure changes
srtaalej 75bbdd9
Update listeners/assistant/__init__.py
srtaalej 0b18145
Update listeners/assistant/__init__.py
srtaalej 1687283
Update README.md
srtaalej bd0da37
Update README.md
srtaalej afa1d4d
Update listeners/assistant/message.py
srtaalej 73b13e5
chore: match js sample app name conventions
srtaalej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,7 +1,14 @@ | ||
| from slack_bolt import App | ||
| from slack_bolt import App, Assistant | ||
|
|
||
| from .assistant import assistant | ||
| from .assistant_thread_started import assistant_thread_started | ||
| from .message import message | ||
|
|
||
|
|
||
| # Refer to https://docs.slack.dev/tools/bolt-python/concepts/ai-apps#assistant for more details on the Assistant class | ||
| def register(app: App): | ||
| assistant = Assistant() | ||
|
|
||
| assistant.thread_started(assistant_thread_started) | ||
| assistant.user_message(message) | ||
|
|
||
| app.assistant(assistant) |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| from logging import Logger | ||
| from typing import Dict, List | ||
|
|
||
| from slack_bolt import Say, SetSuggestedPrompts | ||
|
|
||
|
|
||
| def assistant_thread_started( | ||
| say: Say, | ||
| set_suggested_prompts: SetSuggestedPrompts, | ||
| logger: Logger, | ||
| ): | ||
| """ | ||
| Handle the assistant thread start event by greeting the user and setting suggested prompts. | ||
|
|
||
| Args: | ||
| say: Function to send messages to the thread from the app | ||
| set_suggested_prompts: Function to configure suggested prompt options | ||
| logger: Logger instance for error tracking | ||
| """ | ||
| try: | ||
| say("How can I help you?") | ||
|
|
||
| prompts: List[Dict[str, str]] = [ | ||
| { | ||
| "title": "What does Slack stand for?", | ||
| "message": "Slack, a business communication service, was named after an acronym. Can you guess what it stands for?", | ||
| }, | ||
| { | ||
| "title": "Write a draft announcement", | ||
| "message": "Can you write a draft announcement about a new feature my team just released? It must include how impactful it is.", | ||
| }, | ||
| { | ||
| "title": "Suggest names for my Slack app", | ||
| "message": "Can you suggest a few names for my Slack app? The app helps my teammates better organize information and plan priorities and action items.", | ||
| }, | ||
| ] | ||
|
|
||
| set_suggested_prompts(prompts=prompts) | ||
| except Exception as e: | ||
| logger.exception(f"Failed to handle an assistant_thread_started event: {e}", e) | ||
| say(f":warning: Something went wrong! ({e})") |
47 changes: 2 additions & 45 deletions
47
listeners/assistant/assistant.py → listeners/assistant/message.py
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.