Skip to content

Commit

Permalink
Slackbot - allow users to set the command strings
Browse files Browse the repository at this point in the history
Signed-off-by: Ygal Blum <[email protected]>
  • Loading branch information
ygalblum committed Sep 12, 2024
1 parent 5556149 commit 4d67d0f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
10 changes: 8 additions & 2 deletions knowledge_base_gpt/apps/slackbot/slack_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,14 @@ def __init__(

# Register message and command handlers
self._handler.app.message()(self._got_message)
self._handler.app.command('/conversation_reset')(self._reset_conversation)
self._handler.app.command('/conversation_forward')(self._forward_question)

cmd_string = f'/{settings.slackbot.command_strings.reset}'
self._logger.info("Registering to %s as reset command", cmd_string)
self._handler.app.command(cmd_string)(self._reset_conversation)

cmd_string = f'/{settings.slackbot.command_strings.forward}'
self._logger.info("Registering to %s as forward command", cmd_string)
self._handler.app.command(cmd_string)(self._forward_question)

def run(self):
""" Start the Slackbot backend application """
Expand Down
13 changes: 13 additions & 0 deletions knowledge_base_gpt/libs/settings/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
from knowledge_base_gpt.libs.settings.settings_loader import load_active_settings


class SlackBotCommandStrings(BaseModel):
""" Override strings used for Slack commands """
reset: str = Field(
"conversation_reset",
description="Slack command to reset the current conversation"
)
forward: str = Field(
"conversation_forward",
description="Slack command to forward the current conversation to the forward channel"
)


class SlackBotSettings(BaseModel):
""" Slackbot Settings """
app_token: str = Field(
Expand All @@ -22,6 +34,7 @@ class SlackBotSettings(BaseModel):
"",
description="Base URL of the Slack server - used for testing"
)
command_strings: SlackBotCommandStrings


class LLMSettings(BaseModel):
Expand Down
3 changes: 2 additions & 1 deletion settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ slackbot:
app_token: $SLACK_APP_TOKEN|""
bot_token: $SLACK_BOT_TOKEN|""
forward_channel: $FORWARD_QUESTION_CHANNEL_NAME|""
command_strings: {}

llm:
mode: ollama
Expand All @@ -27,7 +28,7 @@ google_drive:
text_splitter: {}

embedding:
mode: ollama
mode: infinity

hugging_face:
embedding_model: $EMBEDDINGS_MODEL_NAME|all-MiniLM-L6-v2
Expand Down
1 change: 1 addition & 0 deletions tests/sub-system/simple_test/resources/slackbot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ data:
bot_token: xoxb-test
forward_channel: forward-questions
base_url: http://slack-server-mock:8888
command_strings: {}
llm:
mode: fake
ollama: {}
Expand Down

0 comments on commit 4d67d0f

Please sign in to comment.