georeactor commited on
Commit
d4533bc
1 Parent(s): 8e9c357

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -41,7 +41,9 @@ def generation(tokenizer, model, content):
41
  repetition_penalty=4.0,
42
  )
43
  txt = tokenizer.decode(typ_output[0], skip_special_tokens=True)
44
- return txt
 
 
45
 
46
  def code_from_prompts(prompt, model, type_hints, pre_content):
47
  tokenizer = AutoTokenizer.from_pretrained(modelPath[model])
@@ -61,18 +63,15 @@ def code_from_prompts(prompt, model, type_hints, pre_content):
61
  def get_customer(id):
62
  cur.execute('SELECT * FROM customers WHERE id = ' + str(id))
63
  return cur.fetchall()
64
- """.strip())
65
  elif 'composition' in pre_content:
66
  code = code.replace('MIDDLE', """
67
  def get_customer(id):
68
  cur.execute('SELECT * FROM customers WHERE id = %s', str(id))
69
  return cur.fetchall()
70
- """.strip())
71
 
72
- results = [
73
- generation(tokenizer, model, code),
74
- 0.5,
75
- ]
76
  del tokenizer
77
  del model
78
  return results
@@ -90,8 +89,8 @@ iface = gr.Interface(
90
  ], label="Pre-written function")
91
  ],
92
  outputs=[
93
- gr.outputs.Textbox(label="Generated code"),
94
- gr.outputs.Textbox(label="Probability"),
95
  ],
96
  description="Prompt the code model to write a SQL query with string concatenation.",
97
  )
 
41
  repetition_penalty=4.0,
42
  )
43
  txt = tokenizer.decode(typ_output[0], skip_special_tokens=True)
44
+
45
+ prob = 0.5
46
+ return [txt, prob]
47
 
48
  def code_from_prompts(prompt, model, type_hints, pre_content):
49
  tokenizer = AutoTokenizer.from_pretrained(modelPath[model])
 
63
  def get_customer(id):
64
  cur.execute('SELECT * FROM customers WHERE id = ' + str(id))
65
  return cur.fetchall()
66
+ """.strip() + "\n")
67
  elif 'composition' in pre_content:
68
  code = code.replace('MIDDLE', """
69
  def get_customer(id):
70
  cur.execute('SELECT * FROM customers WHERE id = %s', str(id))
71
  return cur.fetchall()
72
+ """.strip() + "\n")
73
 
74
+ results = generation(tokenizer, model, code)
 
 
 
75
  del tokenizer
76
  del model
77
  return results
 
89
  ], label="Pre-written function")
90
  ],
91
  outputs=[
92
+ gr.outputs.Textbox(label="Most probable code"),
93
+ gr.outputs.Textbox(label="Probability of concat"),
94
  ],
95
  description="Prompt the code model to write a SQL query with string concatenation.",
96
  )