Skip to content

Repository files navigation

Cosense-RAG

RAG App for Your Cosense Project through Slack

English | Japanese

cosense-rag
By using this app, you can retrieve documents related to a user’s query from all documents contained in a Cosense project, based on both surface-level and semantic similarity.

Environment Setup

$ git clone https://github.com/Onely7/Cosense-RAG_for_slack.git
$ cd Cosense-RAG_for_slack

Set Environment Variables

Create a .env file under the project directory and fill in the following fields.

export SLACK_SIGNING_SECRET="<cf*****>"
export SLACK_BOT_TOKEN="<xo*****>"
export PORT="<8888>"
export NGROK_AUTHTOKEN="<2z*****>"
export SOURCE_JSONL_PATH="<./source_data/fetched_original_pages_content.jsonl>"
export DB_PATH="<./vector_db>"
export SAVE_PATH="<./results>"

Next, create a download_source_data/.env file under download_source_data and specify the SID for Cosense (Scrapbox).

export COSENSE_PROJECT_NAME="<my-project>"
export COSENSE_SID="<s%*****>"
export METADATA_FILE_PATH="<./source_data/fetched_original_pages_metadata.jsonl>"
export SOURCE_JSONL_PATH="<./source_data/fetched_original_pages_content.jsonl>"

Create Python Virtual Environment

Move to the project root directory and run the following.

$ cd Cosense-RAG_for_slack
$ uv python install 3.10.18
$ uv python pin 3.10.18
$ uv sync

Data Preparation

Edit the download_source_data/fetch_metadata_and_content.sh file as appropriate and run it.
This will extract all documents included in the Cosense (Scrapbox) project and save them in JSONL format to the file path specified by the SOURCE_JSONL_PATH environment variable.

$ cd Cosense-RAG_for_slack/download_source_data
$ /bin/bash download_source_data/fetch_metadata_and_content.sh

Put the RAG App in a Waiting State for Execution

Configure the app settings on the Slack side appropriately.
Also, by using ngrok, you can map a local port to a public URL so that this app running locally can be accessed externally.
As shown below, open two terminals and keep them running at the same time.

Terminal 1

# Put the RAG app in a state waiting for queries
$ /bin/bash app.sh

Terminal 2

# Associate the local port with a public URL via ngrok
$ /bin/bash run_ngrok.sh

Send a Query from Slack

First, from the Slack user interface, complete the initial setup by following the instructions in ./description.pdf.
Next, send a query with a mention to @Cosense-RAG as shown below; the query will be fed to the RAG app, and documents related to the query will be returned in a consolidated format.

@Cosense-RAG
If there are documents that mention BERT’s masking rate, please output a bulleted list with each item’s title and a one-sentence summary of what was explained.

Citation

@software{
  author = {Daiki Shiono},
  month = {Aug},
  title = {{Cosense-RAG}},
  url = {https://github.com/Onely7/Cosense-RAG_for_slack},
  version = {0.1.0},
  year = {2025}
}

About

RAG App for Your Cosense Project through Slack

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages