Spaces:
Runtime error
Runtime error
Commit
·
e01d0a4
1
Parent(s):
eb4b465
Update app.py
Browse files
app.py
CHANGED
@@ -12,9 +12,7 @@ conn = psycopg2.connect("CONN")
|
|
12 |
cur = conn.cursor()
|
13 |
|
14 |
MIDDLE
|
15 |
-
def rename_customer(id, newName)
|
16 |
-
# PROMPT
|
17 |
-
cur.execute("UPDATE customer SET name
|
18 |
"""
|
19 |
|
20 |
modelPath = {
|
@@ -52,7 +50,7 @@ def generation(tokenizer, model, content):
|
|
52 |
return my_token_prob
|
53 |
|
54 |
prob = next_words(content, len(tokenizer(content)['input_ids']), seek_token_ids)
|
55 |
-
return ["".join(full_output.tokens), prob]
|
56 |
|
57 |
def code_from_prompts(prompt, model, type_hints, pre_content):
|
58 |
tokenizer = AutoTokenizer.from_pretrained(modelPath[model])
|
@@ -69,15 +67,11 @@ def code_from_prompts(prompt, model, type_hints, pre_content):
|
|
69 |
code = code.replace('MIDDLE\n', '')
|
70 |
elif 'Concatenation' in pre_content:
|
71 |
code = code.replace('MIDDLE', """
|
72 |
-
def get_customer(id)
|
73 |
-
cur.execute('SELECT * FROM customers WHERE id = ' + str(id))
|
74 |
-
return cur.fetchall()
|
75 |
""".strip() + "\n")
|
76 |
elif 'composition' in pre_content:
|
77 |
code = code.replace('MIDDLE', """
|
78 |
-
def get_customer(id)
|
79 |
-
cur.execute('SELECT * FROM customers WHERE id = %s', str(id))
|
80 |
-
return cur.fetchall()
|
81 |
""".strip() + "\n")
|
82 |
|
83 |
results = generation(tokenizer, model, code)
|
|
|
12 |
cur = conn.cursor()
|
13 |
|
14 |
MIDDLE
|
15 |
+
def rename_customer(id, newName):\n\t# PROMPT\n\tcur.execute("UPDATE customer SET name
|
|
|
|
|
16 |
"""
|
17 |
|
18 |
modelPath = {
|
|
|
50 |
return my_token_prob
|
51 |
|
52 |
prob = next_words(content, len(tokenizer(content)['input_ids']), seek_token_ids)
|
53 |
+
return ["".join(full_output.tokens), str(prob.item() * 100) + '% chance of risky concatenation']
|
54 |
|
55 |
def code_from_prompts(prompt, model, type_hints, pre_content):
|
56 |
tokenizer = AutoTokenizer.from_pretrained(modelPath[model])
|
|
|
67 |
code = code.replace('MIDDLE\n', '')
|
68 |
elif 'Concatenation' in pre_content:
|
69 |
code = code.replace('MIDDLE', """
|
70 |
+
def get_customer(id):\n\tcur.execute('SELECT * FROM customers WHERE id = ' + str(id))\n\treturn cur.fetchall()
|
|
|
|
|
71 |
""".strip() + "\n")
|
72 |
elif 'composition' in pre_content:
|
73 |
code = code.replace('MIDDLE', """
|
74 |
+
def get_customer(id):\n\tcur.execute('SELECT * FROM customers WHERE id = %s', str(id))\n\treturn cur.fetchall()
|
|
|
|
|
75 |
""".strip() + "\n")
|
76 |
|
77 |
results = generation(tokenizer, model, code)
|