Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | @@ -28,7 +28,7 @@ css=""" | |
| 28 | 
             
            }
         | 
| 29 | 
             
            .chat_card{
         | 
| 30 | 
             
                background: #253251;
         | 
| 31 | 
            -
                color | 
| 32 | 
             
                border-radius: 15px;
         | 
| 33 | 
             
                border-width: thin;
         | 
| 34 | 
             
                padding: 15px;
         | 
| @@ -64,11 +64,13 @@ def make_filename(inp): | |
| 64 | 
             
                    first_name=inp[:30]
         | 
| 65 | 
             
                first_name=first_name.replace(" ","_")
         | 
| 66 | 
             
                print(first_name)
         | 
| 67 | 
            -
                last_name=random.randint(1, | 
| 68 | 
             
                filename=first_name+str(last_name)
         | 
| 69 | 
             
                return filename
         | 
| 70 | 
            -
            def get_screenshot(chat,css_in,w,h):
         | 
| 71 |  | 
|  | |
|  | |
|  | |
| 72 | 
             
                html_body=""
         | 
| 73 | 
             
                for user,bot in chat:
         | 
| 74 | 
             
                    html_body += html_user.replace("$chat",user)
         | 
| @@ -141,6 +143,12 @@ with gr.Blocks(css=css) as app: | |
| 141 | 
             
                            with gr.Row():
         | 
| 142 | 
             
                                im_height=gr.Number(label="Height",value=1000)
         | 
| 143 | 
             
                                im_width=gr.Number(label="Width",value=500)
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 144 | 
             
                            wait_time=gr.Number(label="Wait Time",value=3000)
         | 
| 145 | 
             
                            theme=gr.Radio(label="Theme", choices=["light","dark"],value="light")
         | 
| 146 | 
             
                            chatblock=gr.Dropdown(label="Chatblocks",choices=[c for c in range(1,40)],multiselect=True)
         | 
| @@ -149,7 +157,7 @@ with gr.Blocks(css=css) as app: | |
| 149 | 
             
                            img=gr.Image(type='filepath')
         | 
| 150 | 
             
                css_box=gr.Textbox(lines=50,value=css)
         | 
| 151 | 
             
                html_view=gr.HTML()
         | 
| 152 | 
            -
                btn.click(chat_inf,[sys_inp,inp,chat_b],chat_b)
         | 
| 153 | 
             
                im_btn.click(get_screenshot,[chat_b,css_box,im_width,im_height],[img,html_view])
         | 
| 154 | 
             
                #im_btn.click(get_screenshot,[chat_b,im_height,im_width,chatblock,theme,wait_time],img)
         | 
| 155 | 
             
                #app.load(get_screenshot,inp,img)
         | 
|  | |
| 28 | 
             
            }
         | 
| 29 | 
             
            .chat_card{
         | 
| 30 | 
             
                background: #253251;
         | 
| 31 | 
            +
                color:#ffffff;
         | 
| 32 | 
             
                border-radius: 15px;
         | 
| 33 | 
             
                border-width: thin;
         | 
| 34 | 
             
                padding: 15px;
         | 
|  | |
| 64 | 
             
                    first_name=inp[:30]
         | 
| 65 | 
             
                first_name=first_name.replace(" ","_")
         | 
| 66 | 
             
                print(first_name)
         | 
| 67 | 
            +
                last_name=random.randint(1,99999999999999)
         | 
| 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 | 
            +
                if user_c:
         | 
| 73 | 
            +
                    html_user=html_user.replace("background: #367bb9;",f"background: {user_c};")
         | 
| 74 | 
             
                html_body=""
         | 
| 75 | 
             
                for user,bot in chat:
         | 
| 76 | 
             
                    html_body += html_user.replace("$chat",user)
         | 
|  | |
| 143 | 
             
                            with gr.Row():
         | 
| 144 | 
             
                                im_height=gr.Number(label="Height",value=1000)
         | 
| 145 | 
             
                                im_width=gr.Number(label="Width",value=500)
         | 
| 146 | 
            +
                            with gr.Row():
         | 
| 147 | 
            +
                                user_c=gr.Color_Picker(value="#367bb9")
         | 
| 148 | 
            +
                                bot_c=gr.Color_Picker(value="#1c3c9b")
         | 
| 149 | 
            +
                            with gr.Row():
         | 
| 150 | 
            +
                                background_c=gr.Color_Picker(value="#253251")
         | 
| 151 | 
            +
                                font_c=gr.Color_Picker(value="#ffffff")                    
         | 
| 152 | 
             
                            wait_time=gr.Number(label="Wait Time",value=3000)
         | 
| 153 | 
             
                            theme=gr.Radio(label="Theme", choices=["light","dark"],value="light")
         | 
| 154 | 
             
                            chatblock=gr.Dropdown(label="Chatblocks",choices=[c for c in range(1,40)],multiselect=True)
         | 
|  | |
| 157 | 
             
                            img=gr.Image(type='filepath')
         | 
| 158 | 
             
                css_box=gr.Textbox(lines=50,value=css)
         | 
| 159 | 
             
                html_view=gr.HTML()
         | 
| 160 | 
            +
                btn.click(chat_inf,[sys_inp,inp,chat_b,user_c,bot_c,background_c,font_c],chat_b)
         | 
| 161 | 
             
                im_btn.click(get_screenshot,[chat_b,css_box,im_width,im_height],[img,html_view])
         | 
| 162 | 
             
                #im_btn.click(get_screenshot,[chat_b,im_height,im_width,chatblock,theme,wait_time],img)
         | 
| 163 | 
             
                #app.load(get_screenshot,inp,img)
         | 
