Skip to content

Commit

Permalink
Add Support for .env File Configuration (#107)
Browse files Browse the repository at this point in the history
Co-authored-by: Kazuhiro Sera <[email protected]>
  • Loading branch information
letnaturebe2 and seratch authored Jan 9, 2025
1 parent 3ba1134 commit 76dbade
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
OPENAI_API_KEY=sk-...
SLACK_BOT_TOKEN=xoxb-...
SLACK_APP_TOKEN=xapp-1-...
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ pip install -r requirements.txt
python main.py
```

### Using .env for credential loading

If you prefer using .env file to load env variables for local development, you can rename .env.example file to .env:

```bash
cp .env.example .env
```
Then, replace the values in .env file with your own API keys and tokens:
```text
OPENAI_API_KEY=sk-your-openai-key
SLACK_BOT_TOKEN=xoxb-your-slack-bot-token
SLACK_APP_TOKEN=xapp-1-your-slack-app-token
```

## Running the App for Company Workspaces

Confidentiality of information is top priority for businesses.
Expand Down
2 changes: 2 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from dotenv import load_dotenv
import logging
import os

Expand All @@ -21,6 +22,7 @@
)
from app.slack_ui import build_home_tab

load_dotenv()

if __name__ == "__main__":
from slack_bolt.adapter.socket_mode import SocketModeHandler
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ tiktoken>=0.7,<0.8
# https://github.com/Yelp/elastalert/issues/2306
urllib3<2
pillow>=10.4.0,<11
requests>=2.32,<3
requests>=2.32,<3
python-dotenv>=1.0.1,<2

0 comments on commit 76dbade

Please sign in to comment.