Omnibus commited on
Commit
3c0088a
1 Parent(s): 717b983

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -68,12 +68,19 @@ def make_filename(inp):
68
  filename=first_name+str(last_name)
69
  return filename
70
 
71
- def get_screenshot(chat,css_in,w,h,user_c,bot_c,background_c,font_c):
72
- print(len(chat))
 
 
73
  if user_c:
74
  user_c=user_c.strip('""').strip("''")
75
  css_in=css_in.replace("$user_c",user_c).replace("$bot_c",bot_c).replace("$background_c",background_c).replace("$font_c",font_c)
76
  html_body=""
 
 
 
 
 
77
  for user,bot in chat:
78
  html_body += html_user.replace("$chat",user)
79
  html_body += html_bot.replace("$chat",bot)
@@ -159,7 +166,7 @@ with gr.Blocks(css=css) as app:
159
  img=gr.Image(type='filepath')
160
  html_view=gr.HTML()
161
  btn.click(chat_inf,[sys_inp,inp,chat_b],chat_b)
162
- im_btn.click(get_screenshot,[chat_b,css_box,im_width,im_height,user_c,bot_c,background_c,font_c],[img,html_view])
163
  #im_btn.click(get_screenshot,[chat_b,im_height,im_width,chatblock,theme,wait_time],img)
164
  #app.load(get_screenshot,inp,img)
165
  app.launch()
 
68
  filename=first_name+str(last_name)
69
  return filename
70
 
71
+ def get_screenshot(chat,block,css_in,w,h,user_c,bot_c,background_c,font_c):
72
+ chat_len=len(chat)
73
+ print(chat_len)
74
+ block_box=[]
75
  if user_c:
76
  user_c=user_c.strip('""').strip("''")
77
  css_in=css_in.replace("$user_c",user_c).replace("$bot_c",bot_c).replace("$background_c",background_c).replace("$font_c",font_c)
78
  html_body=""
79
+ if block:
80
+ for i in range(chat_len):
81
+ if i+1 in block:
82
+ block_box.append(chat[i])
83
+ chat=block_box
84
  for user,bot in chat:
85
  html_body += html_user.replace("$chat",user)
86
  html_body += html_bot.replace("$chat",bot)
 
166
  img=gr.Image(type='filepath')
167
  html_view=gr.HTML()
168
  btn.click(chat_inf,[sys_inp,inp,chat_b],chat_b)
169
+ im_btn.click(get_screenshot,[chat_b,chatblock,css_box,im_width,im_height,user_c,bot_c,background_c,font_c],[img,html_view])
170
  #im_btn.click(get_screenshot,[chat_b,im_height,im_width,chatblock,theme,wait_time],img)
171
  #app.load(get_screenshot,inp,img)
172
  app.launch()