georeactor commited on
Commit
2636ace
·
1 Parent(s): 3d9b66a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -9,7 +9,7 @@ import psycopg2
9
  conn = psycopg2.connect("CONN")
10
  cur = conn.cursor()
11
 
12
- def set_customer_name(id: int, new_name: str):
13
  # PROMPT
14
  cur.execute("UPDATE customer SET name
15
  """
@@ -25,6 +25,7 @@ modelPath = {
25
 
26
  def generation(tokenizer, model, content):
27
  input_ids = tokenizer.encode(content, return_tensors='pt')
 
28
  num_beams = 2 if decoder == 'Beam' else None
29
  typical_p = 0.8 if decoder == 'Typical' else None
30
  do_sample = (decoder in ['Beam', 'Typical', 'Sample'])
@@ -47,7 +48,9 @@ def code_from_prompts(prompt, model, type_hints):
47
 
48
  code = header.strip().replace('CONN', "dbname='store'").replace('PROMPT', prompt)
49
 
50
- # if type_hints:
 
 
51
 
52
  results = [
53
  generation(tokenizer, model, code),
@@ -68,6 +71,6 @@ iface = gr.Interface(
68
  gr.outputs.Textbox(label="Generated code"),
69
  gr.outputs.Textbox(label="Probability"),
70
  ],
71
- description="What does a code-generation model assume about the name in the header comment?",
72
  )
73
- iface.launch()
 
9
  conn = psycopg2.connect("CONN")
10
  cur = conn.cursor()
11
 
12
+ def set_customer_name(id, new_name):
13
  # PROMPT
14
  cur.execute("UPDATE customer SET name
15
  """
 
25
 
26
  def generation(tokenizer, model, content):
27
  input_ids = tokenizer.encode(content, return_tensors='pt')
28
+ decoder = 'Standard'
29
  num_beams = 2 if decoder == 'Beam' else None
30
  typical_p = 0.8 if decoder == 'Typical' else None
31
  do_sample = (decoder in ['Beam', 'Typical', 'Sample'])
 
48
 
49
  code = header.strip().replace('CONN', "dbname='store'").replace('PROMPT', prompt)
50
 
51
+ if type_hints:
52
+ code = code.replace('id,', 'id: int,')
53
+ code = code.replace('new_name)', 'new_name: str) -> None')
54
 
55
  results = [
56
  generation(tokenizer, model, code),
 
71
  gr.outputs.Textbox(label="Generated code"),
72
  gr.outputs.Textbox(label="Probability"),
73
  ],
74
+ description="Prompt the code model to write a SQL query with string concatenation.",
75
  )
76
+ iface.launch()