Spaces:
Paused
Paused
mattoofahad commited on
Commit ·
ee2d18c
1
Parent(s): 5301790
adding a docker file, removing discord hook dependency, updating app logo
Browse files- Dockerfile +17 -0
- README.md +25 -14
- src/app.py +8 -4
Dockerfile
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# app/Dockerfile
|
| 2 |
+
|
| 3 |
+
FROM python:3.10-slim
|
| 4 |
+
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
COPY requirements.txt /app/
|
| 8 |
+
|
| 9 |
+
COPY src /app/src/
|
| 10 |
+
|
| 11 |
+
RUN pip install -r requirements.txt
|
| 12 |
+
|
| 13 |
+
EXPOSE 8501
|
| 14 |
+
|
| 15 |
+
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
| 16 |
+
|
| 17 |
+
ENTRYPOINT ["streamlit", "run", "src/app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
README.md
CHANGED
|
@@ -12,29 +12,40 @@ pinned: false
|
|
| 12 |
# simple-chat-bot
|
| 13 |
This is a simple chat bot using openAI GPT models.
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
## Create env
|
| 16 |
|
| 17 |
1. Create conda env
|
| 18 |
-
```
|
| 19 |
-
conda create -n chat_bot_env python=3.10
|
| 20 |
-
```
|
| 21 |
|
| 22 |
2. Activate env
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
```
|
| 27 |
|
| 28 |
3. install packages
|
| 29 |
-
```
|
| 30 |
-
pip install -r requirements.txt
|
| 31 |
-
```
|
| 32 |
|
| 33 |
## Run the application
|
| 34 |
-
|
| 35 |
-
```
|
| 36 |
-
streamlit run src\app.py
|
| 37 |
-
```
|
| 38 |
|
| 39 |
|
| 40 |
|
|
|
|
| 12 |
# simple-chat-bot
|
| 13 |
This is a simple chat bot using openAI GPT models.
|
| 14 |
|
| 15 |
+
## Docker
|
| 16 |
+
1. Create the docker container
|
| 17 |
+
```bash
|
| 18 |
+
docker build -t streamlit .
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
2. run the container
|
| 22 |
+
```bash
|
| 23 |
+
docker run -p 8501:8501 streamlit
|
| 24 |
+
```
|
| 25 |
+
3. The application is running on `http://localhost:8501/` URL.
|
| 26 |
+
|
| 27 |
## Create env
|
| 28 |
|
| 29 |
1. Create conda env
|
| 30 |
+
```bash
|
| 31 |
+
conda create -n chat_bot_env python=3.10
|
| 32 |
+
```
|
| 33 |
|
| 34 |
2. Activate env
|
| 35 |
+
```bash
|
| 36 |
+
conda activate chat_bot_env
|
| 37 |
+
```
|
|
|
|
| 38 |
|
| 39 |
3. install packages
|
| 40 |
+
```bash
|
| 41 |
+
pip install -r requirements.txt
|
| 42 |
+
```
|
| 43 |
|
| 44 |
## Run the application
|
| 45 |
+
1. start the application
|
| 46 |
+
```bash
|
| 47 |
+
streamlit run src\app.py
|
| 48 |
+
```
|
| 49 |
|
| 50 |
|
| 51 |
|
src/app.py
CHANGED
|
@@ -13,9 +13,10 @@ load_dotenv()
|
|
| 13 |
|
| 14 |
def discord_hook(message):
|
| 15 |
"""_summary_"""
|
| 16 |
-
url = os.environ
|
| 17 |
-
|
| 18 |
-
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
discord_hook("Simple chat bot initiated")
|
|
@@ -51,7 +52,10 @@ def check_openai_api_key():
|
|
| 51 |
def main():
|
| 52 |
"""_summary_"""
|
| 53 |
st.set_page_config(
|
| 54 |
-
page_title="
|
|
|
|
|
|
|
|
|
|
| 55 |
)
|
| 56 |
st.title("Simple Chat Bot")
|
| 57 |
|
|
|
|
| 13 |
|
| 14 |
def discord_hook(message):
|
| 15 |
"""_summary_"""
|
| 16 |
+
url = os.environ.get("DISCORD_HOOK", "NO_HOOK")
|
| 17 |
+
if url != "NO_HOOK":
|
| 18 |
+
webhook = DiscordWebhook(url=url, username="simple-chat-bot", content=message)
|
| 19 |
+
webhook.execute()
|
| 20 |
|
| 21 |
|
| 22 |
discord_hook("Simple chat bot initiated")
|
|
|
|
| 52 |
def main():
|
| 53 |
"""_summary_"""
|
| 54 |
st.set_page_config(
|
| 55 |
+
page_title="simple-chat-bot",
|
| 56 |
+
page_icon="👾",
|
| 57 |
+
layout="centered",
|
| 58 |
+
initial_sidebar_state="auto",
|
| 59 |
)
|
| 60 |
st.title("Simple Chat Bot")
|
| 61 |
|