-
Notifications
You must be signed in to change notification settings - Fork 12
feat: feedback block #13
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
Changes from all commits
66b5404
bd2e837
a4309b4
94e0d29
9a2df8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,8 @@ pip install -r requirements.txt | |
| python3 app.py | ||
| ``` | ||
|
|
||
| Start talking to the bot! Start a new DM or thread and click the feedback button when it responds. | ||
|
|
||
| #### Linting | ||
| ```zsh | ||
| # Run flake8 from root directory for linting | ||
|
|
@@ -74,8 +76,8 @@ black . | |
|
|
||
| Every incoming request is routed to a "listener". This directory groups each listener based on the Slack Platform feature used, so `/listeners/events` handles incoming events, `/listeners/shortcuts` would handle incoming [Shortcuts](https://docs.slack.dev/interactivity/implementing-shortcuts/) requests, and so on. | ||
|
|
||
| :::info[The `listeners/events` folder is purely educational and demonstrates alternative approaches to implementation] | ||
| These listeners are **not registered** and are not used in the actual application. For the working implementation, refer to `listeners/assistant.py`. | ||
| > [!NOTE] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is good! i have no idea why i suggested to use our docs syntax in a readme - i got mixed up with which repo i was commenting on probably |
||
| > The `listeners/events` folder is purely educational and demonstrates alternative approaches to implementation. These listeners are **not registered** and are not used in the actual application. For the working implementation, refer to `listeners/assistant/assistant.py`. | ||
|
|
||
| **`/listeners/assistant`** | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| from slack_bolt import App | ||
| from .actions import handle_feedback | ||
|
|
||
|
|
||
| def register(app: App): | ||
| app.action("feedback")(handle_feedback) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import logging | ||
|
|
||
|
|
||
| # Handle feedback buttons (thumbs up/down) | ||
| def handle_feedback(ack, body, client, logger: logging.Logger): | ||
| try: | ||
| ack() | ||
| message_ts = body["message"]["ts"] | ||
| channel_id = body["channel"]["id"] | ||
| feedback_type = body["actions"][0]["value"] | ||
| is_positive = feedback_type == "good-feedback" | ||
|
|
||
| if is_positive: | ||
| client.chat_postEphemeral( | ||
| channel=channel_id, | ||
| user=body["user"]["id"], | ||
| thread_ts=message_ts, | ||
| text="We're glad you found this useful.", | ||
| ) | ||
| else: | ||
| client.chat_postEphemeral( | ||
| channel=channel_id, | ||
| user=body["user"]["id"], | ||
| thread_ts=message_ts, | ||
| text="Sorry to hear that response wasn't up to par :slightly_frowning_face: Starting a new chat may help with AI mistakes and hallucinations.", | ||
| ) | ||
|
|
||
| logger.debug(f"Handled feedback: type={feedback_type}, message_ts={message_ts}") | ||
| except Exception as error: | ||
| logger.error(f":warning: Something went wrong! {error}") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| from slack_bolt import App | ||
| from .assistant import assistant | ||
|
|
||
| __all__ = ["assistant"] | ||
|
|
||
| def register(app: App): | ||
| app.assistant(assistant) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| --extra-index-url=https://test.pypi.org/simple/ | ||
| slack_sdk==3.36.0.dev2 | ||
| slack-sdk==3.36.0.dev3 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. praise: Thank you! 🙏🏻 |
||
| slack-bolt>=1.21,<2 | ||
|
|
||
| # If you use a different LLM vendor, replace this dependency | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukegalbraithrussell me trying to check items off of @mwbrooks wishlist 🆘