Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -57,22 +57,27 @@ $body
|
|
| 57 |
</pre>
|
| 58 |
"""
|
| 59 |
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
def get_screenshot(chat,css_in,w,h):
|
| 62 |
-
|
| 63 |
html_body=""
|
| 64 |
for user,bot in chat:
|
| 65 |
-
print (f'user::{user}')
|
| 66 |
-
print (f'bot::{bot}')
|
| 67 |
html_body += html_user.replace("$chat",user)
|
| 68 |
html_body += html_bot.replace("$chat",bot)
|
| 69 |
html=html_card.replace("$body",html_body)
|
| 70 |
-
#css = css
|
| 71 |
-
#hti.screenshot(html_str=html, save_as='red_page.png')
|
| 72 |
-
#hti.screenshot(html_str=html_card, css_str=css, save_as='red_page.png')
|
| 73 |
hti.size = (w, h)
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
| 76 |
|
| 77 |
|
| 78 |
def format_prompt(message, history):
|
|
@@ -133,7 +138,7 @@ with gr.Blocks(css=css) as app:
|
|
| 133 |
with gr.Column(scale=1):
|
| 134 |
with gr.Group():
|
| 135 |
with gr.Row():
|
| 136 |
-
im_height=gr.Number(label="Height",value=
|
| 137 |
im_width=gr.Number(label="Width",value=500)
|
| 138 |
wait_time=gr.Number(label="Wait Time",value=3000)
|
| 139 |
theme=gr.Radio(label="Theme", choices=["light","dark"],value="light")
|
|
|
|
| 57 |
</pre>
|
| 58 |
"""
|
| 59 |
|
| 60 |
+
def make_filename(inp):
|
| 61 |
+
if len(inp)<=20:
|
| 62 |
+
first_name=inp
|
| 63 |
+
else:
|
| 64 |
+
first_name=inp[:20]
|
| 65 |
+
print(first_name)
|
| 66 |
+
last_name=random.randint(1,1111111111)
|
| 67 |
+
filename=first_name+last_name
|
| 68 |
+
return filename
|
| 69 |
def get_screenshot(chat,css_in,w,h):
|
| 70 |
+
|
| 71 |
html_body=""
|
| 72 |
for user,bot in chat:
|
|
|
|
|
|
|
| 73 |
html_body += html_user.replace("$chat",user)
|
| 74 |
html_body += html_bot.replace("$chat",bot)
|
| 75 |
html=html_card.replace("$body",html_body)
|
|
|
|
|
|
|
|
|
|
| 76 |
hti.size = (w, h)
|
| 77 |
+
filename=f'{make_filename(chat[0][0])}.png'
|
| 78 |
+
print(filename)
|
| 79 |
+
hti.screenshot(html_str=html, css_str=css_in, save_as=filename)
|
| 80 |
+
return filename,html
|
| 81 |
|
| 82 |
|
| 83 |
def format_prompt(message, history):
|
|
|
|
| 138 |
with gr.Column(scale=1):
|
| 139 |
with gr.Group():
|
| 140 |
with gr.Row():
|
| 141 |
+
im_height=gr.Number(label="Height",value=1000)
|
| 142 |
im_width=gr.Number(label="Width",value=500)
|
| 143 |
wait_time=gr.Number(label="Wait Time",value=3000)
|
| 144 |
theme=gr.Radio(label="Theme", choices=["light","dark"],value="light")
|