Ilma-Salsabil commited on
Commit
8c84ef7
·
verified ·
1 Parent(s): cda0038

Upload 3 files

Browse files
Files changed (3) hide show
  1. Dockerfile +38 -0
  2. app.py +30 -0
  3. requirements.txt +36 -0
Dockerfile ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## use the official Python 3.9 image
2
+ FROM python:3.9
3
+
4
+ ## set the working directory to /code
5
+
6
+ WORKDIR /code
7
+
8
+ ## copy the current directory contents in the container at /code
9
+
10
+ COPY ./requirements.txt /code/requirements.txt
11
+
12
+ # install the requirements.txt
13
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
14
+
15
+ # set up a new user named user
16
+ RUN useradd user
17
+
18
+ # switch to the "user" user
19
+ USER user
20
+
21
+ # set home to the user's home directory
22
+
23
+ ENV HOME=/home/user \
24
+ PATH=/home/user/.local/bin:$PATH
25
+
26
+
27
+ # set the working directory to the user's home directory
28
+
29
+ WORKDIR $HOME/app
30
+
31
+ # copy the current directory contents into the container at $HOME/app setting the owner to user
32
+
33
+ COPY --chown=user . $HOME/app
34
+
35
+ # start the FastApi app on port 7860
36
+
37
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
38
+
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # text generation
2
+
3
+ from fastapi import FastAPI
4
+ from transformers import pipeline
5
+
6
+ # create a fastapi instances
7
+
8
+ app = FastAPI()
9
+
10
+ # initialize the text generation pipeline
11
+ pipe = pipeline("text2text-generation", model="google/flan-t5-small")
12
+
13
+ @app.get("/")
14
+ def home():
15
+ return {"message":"Hello World!"}
16
+
17
+
18
+ # get request '/generate'
19
+
20
+ @app.get("/generate")
21
+ def generate(text:str):
22
+ # use the pipeline to generate text from given input text
23
+
24
+ output = pipe(text)
25
+
26
+ # return the generate text in json response
27
+
28
+ return {"output":output[0]['generated_text']}
29
+
30
+
requirements.txt ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ python-dotenv
2
+ langchain-groq
3
+ langchain
4
+ langchain_core
5
+ langchain_community
6
+ crewai
7
+ crewai_tools
8
+ groq
9
+ langchainhub
10
+ langchain_google_genai
11
+ requests
12
+ langchain-astradb
13
+ SpeechRecognition
14
+ pyaudio
15
+ soundfile
16
+ opencv-python
17
+ # pyttsx3
18
+ numpy
19
+ sounddevice
20
+ cartesia
21
+ openai
22
+ faiss-cpu
23
+ streamlit
24
+ pypdf
25
+ langchain_nvidia_ai_endpoints
26
+ langchain-huggingface
27
+ huggingface_hub
28
+ assemblyai
29
+ yt-dlp
30
+ mesop
31
+ google-generativeai
32
+ fastapi
33
+ uvicorn[standard]
34
+ sentencepiece
35
+ torch
36
+ transformers