SFM2001 commited on
Commit
e835b95
·
1 Parent(s): 0dd7283
Files changed (2) hide show
  1. create_app.py +2 -2
  2. views/infer.py +6 -6
create_app.py CHANGED
@@ -46,12 +46,12 @@ def load_models():
46
  print("LONGFORMER MODEL LOADED", flush=True)
47
  LONGFORMER_MODEL.eval()
48
  MODELS_LOADED = True
49
- print("LOAD ENDED")
50
 
51
  def create_app():
52
  set_seed(42)
53
  load_models()
54
- print("MODEL LOADED")
55
  app = Flask(__name__)
56
  app.config.from_pyfile('configs.py')
57
  db.init_app(app)
 
46
  print("LONGFORMER MODEL LOADED", flush=True)
47
  LONGFORMER_MODEL.eval()
48
  MODELS_LOADED = True
49
+ print("LOAD ENDED", flush=True)
50
 
51
  def create_app():
52
  set_seed(42)
53
  load_models()
54
+ print("MODEL LOADED", flush=True)
55
  app = Flask(__name__)
56
  app.config.from_pyfile('configs.py')
57
  db.init_app(app)
views/infer.py CHANGED
@@ -7,7 +7,7 @@ from inference.infer_single import *
7
  from utils.util_func import *
8
  @infer_bp.route('/infer', methods=['GET'])
9
  def infer():
10
- print("Infer function entered")
11
  token = request.args.get('token')
12
  if token is None:
13
  flash("Please go to the home page to check your essay.")
@@ -20,6 +20,7 @@ def infer():
20
  essay = session.get('essay', "")
21
  feedback = session.get('feedback', {}) or {}
22
  feedback = dict(feedback)
 
23
  tr_feedback = feedback.get('TR_feedback', 'No feedback available. Your essay does not make sense, try to refine it.')
24
  cc_feedback = feedback.get('CC_feedback', 'No feedback available. Your essay does not make sense, try to refine it.')
25
  lr_feedback = feedback.get('LR_feedback', 'No feedback available. Your essay does not make sense, try to refine it.')
@@ -32,12 +33,12 @@ def infer():
32
 
33
  @infer_bp.route('/', methods=['GET', 'POST'])
34
  def index():
35
- print("INPUT??")
36
  set_seed(42)
37
  if request.method == 'POST':
38
  topic = request.form['topic'].strip()
39
  essay = request.form['essay'].strip()
40
- print("ESSAY TOPIC", essay, topic)
41
  if not topic or not essay:
42
  flash('Please provide both a topic and an essay text.')
43
  return render_template('index.html', isempty='True')
@@ -47,7 +48,7 @@ def index():
47
  session['topic'] = topic
48
  session['essay'] = essay
49
  session['feedback'] = {}
50
- print("LESS THAN 20 WORDS")
51
  else:
52
  scores, feedback = generate_and_score_essay(
53
  topic, essay
@@ -71,9 +72,8 @@ def index():
71
  )
72
  db.session.add(new_history)
73
  db.session.commit()
74
- print("REDIRECT TO INFER")
75
  return redirect(url_for('infer.infer', token=token))
76
- print("FAILED TO INFER")
77
  return render_template('index.html', isempty='False', username=current_user.nickname if current_user.is_authenticated else '')
78
 
79
  @infer_bp.route('/rubric_explanation')
 
7
  from utils.util_func import *
8
  @infer_bp.route('/infer', methods=['GET'])
9
  def infer():
10
+ print("Infer function entered", flush=True)
11
  token = request.args.get('token')
12
  if token is None:
13
  flash("Please go to the home page to check your essay.")
 
20
  essay = session.get('essay', "")
21
  feedback = session.get('feedback', {}) or {}
22
  feedback = dict(feedback)
23
+ print("Feedback:", feedback, flush=True)
24
  tr_feedback = feedback.get('TR_feedback', 'No feedback available. Your essay does not make sense, try to refine it.')
25
  cc_feedback = feedback.get('CC_feedback', 'No feedback available. Your essay does not make sense, try to refine it.')
26
  lr_feedback = feedback.get('LR_feedback', 'No feedback available. Your essay does not make sense, try to refine it.')
 
33
 
34
  @infer_bp.route('/', methods=['GET', 'POST'])
35
  def index():
36
+ print("INPUT??", flush=True)
37
  set_seed(42)
38
  if request.method == 'POST':
39
  topic = request.form['topic'].strip()
40
  essay = request.form['essay'].strip()
41
+ print("ESSAY TOPIC", essay, topic, flush=True)
42
  if not topic or not essay:
43
  flash('Please provide both a topic and an essay text.')
44
  return render_template('index.html', isempty='True')
 
48
  session['topic'] = topic
49
  session['essay'] = essay
50
  session['feedback'] = {}
51
+ print("LESS THAN 20 WORDS", flush=True)
52
  else:
53
  scores, feedback = generate_and_score_essay(
54
  topic, essay
 
72
  )
73
  db.session.add(new_history)
74
  db.session.commit()
75
+ print("REDIRECT TO INFER", flush=True)
76
  return redirect(url_for('infer.infer', token=token))
 
77
  return render_template('index.html', isempty='False', username=current_user.nickname if current_user.is_authenticated else '')
78
 
79
  @infer_bp.route('/rubric_explanation')