imperialwool commited on
Commit
28a268c
1 Parent(s): 69aec0a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -4,7 +4,8 @@ from flask import *
4
  from routes.helpers import configFile
5
  from routes import *
6
 
7
- from transformers import AutoTokenizer, AutoModelForSequenceClassification
 
8
 
9
  #initing
10
  app = Flask(__name__)
@@ -129,7 +130,7 @@ def generateText():
129
  try:
130
  text = helpers.getFromRequest(request, "text")
131
  if not text: return {"status": "error", "details": { "error_code": 101, "error_details": "No text provided" }} , 400
132
- result = generator(text, max_length=1024, return_full_text=False, do_sample=bool(randint(0,1)), temperature=float(randint(5,15))/10.0)
133
  return {"status": "pass", "result": result[0]["generated_text"]}
134
  except Exception as e: return {"status": "error", "details": { "error_code": 123, "error_details": str(e).replace("\n", " | ") }} , 400
135
 
 
4
  from routes.helpers import configFile
5
  from routes import *
6
 
7
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
8
+ from random import randint
9
 
10
  #initing
11
  app = Flask(__name__)
 
130
  try:
131
  text = helpers.getFromRequest(request, "text")
132
  if not text: return {"status": "error", "details": { "error_code": 101, "error_details": "No text provided" }} , 400
133
+ result = generator(text, max_length=1024, return_full_text=False, do_sample=bool(randint(0,1)), temperature=float(randint(5,15))/10.0, max_time)
134
  return {"status": "pass", "result": result[0]["generated_text"]}
135
  except Exception as e: return {"status": "error", "details": { "error_code": 123, "error_details": str(e).replace("\n", " | ") }} , 400
136