Zeel Somaiya commited on
Commit
46a2fb4
·
unverified ·
1 Parent(s): e22e8a7

Add: 2 routes to build a simple application

Browse files
Files changed (4) hide show
  1. .gitignore +14 -0
  2. Dockerfile +9 -0
  3. app.py +16 -0
  4. requirements.txt +5 -0
.gitignore ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Environments
2
+ .env
3
+ .venv
4
+ env/
5
+ venv/
6
+
7
+
8
+
9
+ # PyCharm
10
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
11
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
12
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
13
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
14
+ .idea/
Dockerfile ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ WORKDIR /app
4
+
5
+ COPY ./ /app
6
+
7
+ RUN pip install -r requirements.txt
8
+
9
+ CMD fastapi run --reload --host=0.0.0.0 --port=7860
app.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from transformers import pipeline
3
+
4
+ pipe = pipeline("text2text-generation", model="google/flan-t5-base")
5
+ app = FastAPI()
6
+
7
+
8
+ @app.get('/')
9
+ def home():
10
+ return {"hello": "people"}
11
+
12
+
13
+ @app.get('/ask')
14
+ def ask(prompt: str):
15
+ result = pipe(prompt)
16
+ return result[0]
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ fastapi[standard]
2
+ uvicorn
3
+ transformers
4
+ torch
5
+ torchvision