Spaces:
Sleeping
Sleeping
Mohammed-Altaf
commited on
Commit
•
e4cf227
1
Parent(s):
ab597f1
changed the configuration of Docker
Browse files- Dockerfile +5 -3
- main.py +6 -3
Dockerfile
CHANGED
@@ -2,10 +2,12 @@ FROM python:3.11-slim
|
|
2 |
|
3 |
WORKDIR /app
|
4 |
|
5 |
-
COPY requirements.txt requirements.txt
|
6 |
|
7 |
-
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
8 |
|
9 |
-
COPY .
|
|
|
|
|
10 |
|
11 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
2 |
|
3 |
WORKDIR /app
|
4 |
|
5 |
+
COPY requirements.txt /app/requirements.txt
|
6 |
|
7 |
+
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
|
8 |
|
9 |
+
COPY . /app
|
10 |
+
|
11 |
+
EXPOSE 7860
|
12 |
|
13 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
main.py
CHANGED
@@ -1,17 +1,20 @@
|
|
|
|
1 |
from load_meta_data import ChatBot
|
2 |
|
|
|
3 |
from enum import Enum
|
4 |
from fastapi import FastAPI
|
5 |
from fastapi.middleware.cors import CORSMiddleware
|
6 |
|
|
|
7 |
class Repo_ID(Enum):
|
8 |
chat_model: str = "Mohammed-Altaf/medical_chatbot-8bit"
|
9 |
|
10 |
-
|
11 |
app = FastAPI()
|
12 |
bot = ChatBot()
|
13 |
|
14 |
-
# middlewares
|
15 |
app.add_middleware(
|
16 |
CORSMiddleware,
|
17 |
allow_origins=['*'],
|
@@ -20,7 +23,7 @@ app.add_middleware(
|
|
20 |
allow_headers=['*'],
|
21 |
)
|
22 |
|
23 |
-
# load the model asynchronously on startup
|
24 |
@app.on_event("startup")
|
25 |
async def startup():
|
26 |
bot.load_from_hub(Repo_ID.chat_model.value)
|
|
|
1 |
+
# Custom Imports
|
2 |
from load_meta_data import ChatBot
|
3 |
|
4 |
+
# Built-in Imports
|
5 |
from enum import Enum
|
6 |
from fastapi import FastAPI
|
7 |
from fastapi.middleware.cors import CORSMiddleware
|
8 |
|
9 |
+
# Enum to save the Model Id, which is Constant
|
10 |
class Repo_ID(Enum):
|
11 |
chat_model: str = "Mohammed-Altaf/medical_chatbot-8bit"
|
12 |
|
13 |
+
# initializing the application and the chatbot class from the load meta data file
|
14 |
app = FastAPI()
|
15 |
bot = ChatBot()
|
16 |
|
17 |
+
# middlewares to allow cross orgin communications
|
18 |
app.add_middleware(
|
19 |
CORSMiddleware,
|
20 |
allow_origins=['*'],
|
|
|
23 |
allow_headers=['*'],
|
24 |
)
|
25 |
|
26 |
+
# load the model asynchronously on startup and save it into memory
|
27 |
@app.on_event("startup")
|
28 |
async def startup():
|
29 |
bot.load_from_hub(Repo_ID.chat_model.value)
|