maulerr commited on
Commit
4c84960
1 Parent(s): 34b2a3b
Files changed (2) hide show
  1. app.py +29 -0
  2. requirements.txt +7 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import request
2
+ from textblob import TextBlob
3
+ from flask import app
4
+
5
+ @app.route("/text/summarize", methods=["POST"])
6
+ def summarize():
7
+ text = request.json.get("text")
8
+ return {"summary": TextBlob(text).summarize()}
9
+
10
+ @app.route("/text/extract", methods=["POST"])
11
+ def extract():
12
+ text = request.json.get("text")
13
+ return {"keywords": TextBlob(text).keywords}
14
+
15
+ @app.route("/text/paraphrase", methods=["POST"])
16
+ def paraphrase():
17
+ text = request.json.get("text")
18
+ return {"paraphrase": TextBlob(text).correct()}
19
+
20
+ @app.route("/text/grammar", methods=["POST"])
21
+ def grammar():
22
+ text = request.json.get("text")
23
+ return {"errors": TextBlob(text).spellcheck()}
24
+
25
+ @app.route("/chat", methods=["POST"])
26
+ def chat():
27
+ prompt = request.json.get("prompt")
28
+ #TODO: create chatting logic
29
+ return {"response": f"prompt: {prompt}\nresponse: Still working on Text Generation logic, thanks for the patience!"}
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Core dependencies
2
+ Flask==2.2.2
3
+ textblob==0.15.3
4
+
5
+ # Machine learning and NLP
6
+ torch==1.13.1+cpu
7
+ transformers==4.27.0