Daniel Fried commited on
Commit
a2fc40d
1 Parent(s): 13f28f2

better single <infill> error handling

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -123,7 +123,9 @@ async def infill_maybe(info: str):
123
  temperature = float(form['temperature'])
124
  try:
125
  if len(form['parts']) > 2:
126
- return {'result': 'error', 'text': ''.join(form['parts']), 'type': 'infill', 'message': f"error: Only a single infill is supported!"}
 
 
127
  prefix, suffix = form['parts']
128
  generation = generate(prefix, suffix=suffix, temperature=temperature, max_new_tokens=length_limit, top_p=0.95, repetition_penalty=1.0)
129
  generation['result'] = 'success'
 
123
  temperature = float(form['temperature'])
124
  try:
125
  if len(form['parts']) > 2:
126
+ return {'result': 'error', 'text': ''.join(form['parts']), 'type': 'infill', 'message': f"error: Only a single <infill> token is supported!"}
127
+ elif len(form['parts']) == 1:
128
+ return {'result': 'error', 'text': ''.join(form['parts']), 'type': 'infill', 'message': f"error: Must have an <infill> token present!"}
129
  prefix, suffix = form['parts']
130
  generation = generate(prefix, suffix=suffix, temperature=temperature, max_new_tokens=length_limit, top_p=0.95, repetition_penalty=1.0)
131
  generation['result'] = 'success'