naruto7 commited on
Commit
3d42328
·
1 Parent(s): 5b2bd80

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -8
app.py CHANGED
@@ -17,17 +17,31 @@ def get_model():
17
 
18
  def format_input(question, starter_code=""):
19
  answer_type = (
20
- "\nUse Call-Based format\n" if starter_code else "\nUse Standard Input format\n"
 
 
 
 
21
  )
22
- return f"\nQUESTION:\n{question}\n{starter_code}\n{answer_type}\nANSWER:\n"
 
 
 
 
 
 
23
 
24
 
25
  def clean_text(generation):
26
  # clean up text has discussed in OpenAI's paper "Evaluating Large Language Models Trained on Code"
27
- generation = generation.split("\ndef")[0]
28
- generation = generation.split("\nclass")[0]
29
- generation = generation.split("\n#")[0]
30
- generation = generation.split("\nif")[0]
 
 
 
 
31
 
32
  return generation
33
 
@@ -150,9 +164,10 @@ def run():
150
  st.code(output, language="python")
151
 
152
  # Create link to carbon to make a nice screenshot of the generated code
153
- url_code = urllib.parse.quote(f"# {question}\n{output}")
 
154
  st.markdown(
155
- f"[Carbon Screenshot](https://carbon.now.sh/?bg=rgba%280%2C0%2C0%2C0%29&t=seti&wt=none&l=python&ds=false&dsyoff=20px&dsblur=68px&wc=true&wa=false&pv=56px&ph=56px&ln=false&fl=1&fm=Hack&fs=14px&lh=133%25&si=false&es=2x&wm=false&code={url_code})"
156
  )
157
 
158
 
 
17
 
18
  def format_input(question, starter_code=""):
19
  answer_type = (
20
+ "\
21
+ Use Call-Based format\
22
+ " if starter_code else "\
23
+ Use Standard Input format\
24
+ "
25
  )
26
+ return f"\
27
+ QUESTION:\
28
+ {question}\
29
+ {starter_code}\
30
+ {answer_type}\
31
+ ANSWER:\
32
+ "
33
 
34
 
35
  def clean_text(generation):
36
  # clean up text has discussed in OpenAI's paper "Evaluating Large Language Models Trained on Code"
37
+ generation = generation.split("\
38
+ def")[0]
39
+ generation = generation.split("\
40
+ class")[0]
41
+ generation = generation.split("\
42
+ #")[0]
43
+ generation = generation.split("\
44
+ if")[0]
45
 
46
  return generation
47
 
 
164
  st.code(output, language="python")
165
 
166
  # Create link to carbon to make a nice screenshot of the generated code
167
+ url_code = urllib.parse.quote(f"# {question}\
168
+ {output}")
169
  st.markdown(
170
+ f"[Would you like a 'Carbon' copy?](https://carbon.now.sh/?bg=rgba%280%2C0%2C0%2C0%29&t=seti&wt=none&l=python&ds=false&dsyoff=20px&dsblur=68px&wc=true&wa=false&pv=56px&ph=56px&ln=false&fl=1&fm=Hack&fs=14px&lh=133%25&si=false&es=2x&wm=false&code={url_code})"
171
  )
172
 
173