{"id":13820774,"url":"https://github.com/Vokturz/LLM-slackbot-channels","last_synced_at":"2025-05-16T10:32:46.656Z","repository":{"id":176943753,"uuid":"652792809","full_name":"Vokturz/LLM-slackbot-channels","owner":"Vokturz","description":"A user-customized bot for your slack channels using LLMs, Tools and Documents","archived":false,"fork":false,"pushed_at":"2023-08-12T02:04:05.000Z","size":553,"stargazers_count":39,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-19T20:46:43.566Z","etag":null,"topics":["agent","langchain","llm","open-llm","slack-bot","slackbolt","slackbot"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Vokturz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-12T20:08:07.000Z","updated_at":"2024-11-07T20:42:44.000Z","dependencies_parsed_at":"2024-07-19T22:06:17.751Z","dependency_job_id":"e53f8a97-d37c-43e2-ac45-f7aac4e9666a","html_url":"https://github.com/Vokturz/LLM-slackbot-channels","commit_stats":null,"previous_names":["vokturz/llm-slackbot-channels"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vokturz%2FLLM-slackbot-channels","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vokturz%2FLLM-slackbot-channels/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vokturz%2FLLM-slackbot-channels/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vokturz%2FLLM-slackbot-channels/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Vokturz","download_url":"https://codeload.github.com/Vokturz/LLM-slackbot-channels/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254512771,"owners_count":22083459,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","langchain","llm","open-llm","slack-bot","slackbolt","slackbot"],"created_at":"2024-08-04T08:01:08.769Z","updated_at":"2025-05-16T10:32:41.647Z","avatar_url":"https://github.com/Vokturz.png","language":"Python","funding_links":[],"categories":["Python","Building"],"sub_categories":["Tools"],"readme":"# LLM Slack Bot Channels\n\nLLM-SlackBot-Channels is a Slack bot developed using the Slack Bolt framework. It allows users to interact with the bot through Slack channels by employing various commands. The bot leverages a Large Language Model (LLM) to generate responses based on both user input and channel-specific configurations. Unique to each channel, the bot can adopt different personalities and follow a customized set of instructions. This includes the ability to use it as an *agent*, integrating tools and documents.\n\nThis repository mainly uses **langchain**. It supports the usage of open LLMs and embeddings, and OpenAI's models as well.\n\u003cp align=\"center\" style=\"width:80%; max-width:600px;\"\u003e\n  \u003cimg src=\"https://github.com/Vokturz/LLM-slackbot-channels/assets/21696514/4ed5b2b0-b9e3-4dec-8f59-569eb4a3c943\" style=\"width:80%;\"\u003e\n\u003c/p\u003e\n\nSee a video example here:\n\nhttps://github.com/Vokturz/LLM-slackbot-channels/assets/21696514/d69106f3-3de1-4781-9e1d-9b855acd2836\n\n\n\n## What's new? v0.2\n- Improve the way a file is uploaded to a QA thread\n- If using OpenAI models, then you can customize which model you want to use in each channel\n- Use the LLM model as an Agent with your own tools! see more in [v0.2 release](https://github.com/Vokturz/LLM-slackbot-channels/releases/tag/v0.2)\n    - You can add files to the channel, which are used by the agent with a *doc retriever* tool\n## Commands\n\n- **/modify_bot**\n    This command allows you to customize the bot's personality, instructions, and temperature within the channel it's operating in. If `!no-notify` is included, then no notification is sent to the channel.\n    \u003cp align=\"center\" style=\"width:40%; max-width:300px;\"\u003e\n      \u003cimg src=\"https://github.com/Vokturz/LLM-slackbot-channels/assets/21696514/ed1cf3f1-bb67-4859-bf44-1b546031390b\" style=\"width:40%;\"\u003e\n    \u003c/p\u003e\n\n- **/bot_info**\n    This command presents the initial prompt used by the bot, as well as the default 'temperature' for generating responses.\n- **/ask**\n    Use this command to ask questions or make requests. The bot employs the LLM to generate appropriate responses.\n\n    Command syntax: `/ask (\u003c!all\u003e) (\u003c!temp=temp\u003e) \u003cquestion or request\u003e`\n\n    Here, if `!all` is included, the bot sends its response to the entire channel. If `!temp` is included, the response's \"temperature\" (randomness of the bot's output) is adjusted.\n\n- **/permissions** (optional)\n    This command modify which users can interact with the bot. It requires a password defined in the environment variables\n\n    Command syntax: `/permissions \u003cPERMISSIONS_PASSWORD\u003e` \n\n    If no password was defined inside `.env`, then this command do nothing.\n\n- **/edit_docs**\n    This command allows the user to edit the descriptions of the documents that have been uploaded to the channel. These edited descriptions are used in the *doc_retriever* tool (See *Mentions*).\n    \n## Mentions\n- When the bot is mentioned in a thread, it can respond based on the context. The context limit is handled using a `max token limit` in a similar way as `ConversationTokenBufferMemory` from langchain.\n\n- If the bot is mentioned in channel along with uploaded file, then it ask if you want to start a QA thread or upload the file directly to the channel: The user has the possibility to add some context and new separators to chunk the file(s). The files are downloaded in `data/tmp` to define a persistent VectorStore in `data/db`, after the generation of the VectorStore all files are deleted. \n\n    - **QA Thread**: The bot responds to the user's message that contains the uploaded file(s), stating that a QA thread has been created with the uploaded file(s) and the context provided by the user.\n        - If the user wants to remove the QA thread, use the flag `!delete-qa` while mentioning the bot.\n    \u003cp align=\"center\" style=\"width:100%; max-width:800px;\"\u003e\n      \u003cimg src=\"https://github.com/Vokturz/LLM-slackbot-channels/assets/21696514/fea57117-e939-4f44-9ef1-5ab26e315b7f\" style=\"width:100%;\"\u003e\n    \u003c/p\u003e\n    \n    - **Upload to channel**: The file is upload to the channel and the tool *doc_retriever* appears in the list of tools once at least one file has been added to the channel. This tool take as context all the files uploaded by the users using this method.\n    If the channel is used as a simple LLM chain, then a `ConversationRetrievalChain`, otherwise a tool to retrieve the important information from the documents is created and passed to the Agent.\n\n### How are documents handled?\nThe documents are handled using **ChromaDB**, saving the database to `data/db/{channel_id}/{timestamp}` for each QA thread, where `channel_id` refers to the channel which contains the thread and `timestamp` to the time when the QA thread was initiated. It is important to mention that typically embedding models are not compatible, so if you change the embedding model after creating the database for a given QA thread, then that thread will not work.\n## Usage\n\n### Requirements \n\nTo install the necessary requirements, use:\n```bash\npip install -r requirements.txt\n```\n\nFor CTransformers or OpenAI functionalities, you will need to install these packages separately:\n```bash\npip install ctransformers\npip install openai\n```\n\nFor Open-source embeddings, you will need to install `sentence-transformers`:\n```bash\npip install sentence-transformers\n```\n\n### Environment variables\nDuplicate `example.env` to `.env` and adjust as necessary:\n```\nOPENAI_API_KEY= Your OpenAI key\nCTRANSFORMERS_MODEL= model name from HuggingFace or model path in your computer\nEMB_MODEL=all-MiniLM-L6-v2 # Embedding model\nSLACK_BOT_TOKEN=xoxb-... Slack API Bot Token \nSLACK_APP_TOKEN=xapp-... Slack API App Token\nPERMISSIONS_PASSWORD=CHANGEME # Password to activate /permissions command\n```\n\n### Starting the Bot\nTo start the bot, simply run:\n```bash\npython main.py\n```\nThis file contains the basic configuration to run the bot:\n```python\nfrom src.slackbot import SlackBot\nfrom src.handlers import create_handlers\n\n# Set model_type\n# OpenAI\n# Llama (CTransformers)\n# FakeLLM (just for testing) \nmodel_type='OpenAI'\nbot = SlackBot(name='SlackBot', model_type=model_type)\n\n# Set configuration\nconfig = dict(model_name=\"gpt-3.5-turbo\", temperature=0.8, max_tokens=500)\n\n# Initialize LLM and embeddings\n# max_tokens_threads refers to the max tokens to consider in a thread message history\nbot.initialize_llm(max_tokens_threads=2000, config=config)\n\n# If you don't want to use OpenAI Embeddings, you can add model_type parameter  to use a model from EMB_MODEL env variable\nbot.initialize_embeddings() # model_type='llama' for HugginFaceEmbeddings\n\n# Create handlers for commands /ask, /modify_bot, /bot_info  and bot mentions\ncreate_handlers(bot)\n\n### You can create new handlers for other commands as follow\n# @bot.app.command(\"/foo\")\n# async def handle_foo(say, respond, ack, command):\n#     await ack()\n#     # do something..\n```\n\n## Slack API configuration\nThe bot requires the following permissions:\n1. Enable **Socket Mode**\n2. Activate **Incoming Webhooks**\n3. Create **Slash Commands**\n   - `/ask` Ask a question or make a request\n   - `/modify_bot` Modify bot's configuration for the current channel \n   - `/bot_info` Get *prompt* and *temperature* of the bot in the current channel\n   - `/permissions` (optional)  Modify which users can interact with the bot\n   - `/edit_docs` Modify documents uploaded to the bot in the current channel\n4. Enable **Events**\n   - Subscribe to `app_mention`\n5. Set **Scopes**\n   - `app_mention:read`\n   - `channels:history`\n   - `channels:join`\n   - `channels:read`\n   - `chat:write`\n   - `files:read`\n   - `im:write`  _\u003c- To notify users about change in permissions_\n   - `users:read`  _\u003c- To get list of users_\n\n    _Note that for **groups** you will require also `groups:history`, `groups:join` and `groups:read`_ \n## ToDo / Ideas\n- [x] Add a command to modify which users can interact with the bot. The command should be initialized using a password, example `/permissions \u003cPASSWORD\u003e`\n- [x] A `ingest` method to create a vector database and use a QA retriever\n- [x] add a custom CallbackHandler to update the messages on the go\n- [x] A modal view to modify files description\n- [x] a method to remove files from the vectorstore\n- [x] A way to delete unused QA threads\n- [ ] Create a doc retriever for each document, currently is using the same approach from [privateGPT](https://github.com/imartinez/privateGPT)\n- [ ] Create tests\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FVokturz%2FLLM-slackbot-channels","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FVokturz%2FLLM-slackbot-channels","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FVokturz%2FLLM-slackbot-channels/lists"}