Spaces:
Runtime error
Runtime error
ncoop57
commited on
Commit
·
5b2bd80
1
Parent(s):
d75a461
Add loading gif when generating solution and add button for generating Carbon screenshot
Browse files- app.py +15 -1
- loading.gif +0 -0
app.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
|
@@ -135,12 +137,24 @@ def run():
|
|
135 |
submit_button = st.button("Solve")
|
136 |
|
137 |
if submit_button:
|
138 |
-
st.text("
|
|
|
|
|
139 |
output = generate_solution(
|
140 |
model, tokenizer, question, starter_code, temperature, num_beams
|
141 |
)
|
|
|
|
|
|
|
|
|
142 |
st.code(output, language="python")
|
143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
|
145 |
if __name__ == "__main__":
|
146 |
run()
|
|
|
1 |
+
import urllib
|
2 |
+
|
3 |
import streamlit as st
|
4 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
5 |
|
|
|
137 |
submit_button = st.button("Solve")
|
138 |
|
139 |
if submit_button:
|
140 |
+
text = st.text("Generating solution...")
|
141 |
+
# gif from https://giphy.com/gifs/alan-DfSXiR60W9MVq
|
142 |
+
gif_runner = st.image("./loading.gif")
|
143 |
output = generate_solution(
|
144 |
model, tokenizer, question, starter_code, temperature, num_beams
|
145 |
)
|
146 |
+
text.empty()
|
147 |
+
gif_runner.empty()
|
148 |
+
|
149 |
+
st.text("Solution:")
|
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 |
|
159 |
if __name__ == "__main__":
|
160 |
run()
|
loading.gif
ADDED