Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | 
         @@ -26,6 +26,15 @@ client = InferenceClient( 
     | 
|
| 26 | 
         
             
            )
         
     | 
| 27 | 
         | 
| 28 | 
         | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 29 | 
         
             
            def read_pdf(pdf_path):
         
     | 
| 30 | 
         
             
                from pypdf import PdfReader
         
     | 
| 31 | 
         
             
                text=""
         
     | 
| 
         @@ -179,21 +188,27 @@ def summarize(inp,history,data=None,file=None): 
     | 
|
| 179 | 
         
             
                            zz=read_pdf(file)
         
     | 
| 180 | 
         
             
                            print (zz)
         
     | 
| 181 | 
         
             
                            data=f'{data}\nFile:\n{zz}'
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 182 | 
         
             
                    except Exception as e:
         
     | 
| 
         | 
|
| 183 | 
         
             
                        print (e) 
         
     | 
| 184 | 
         
            -
                
         
     | 
| 185 | 
         
            -
             
     | 
| 186 | 
         
            -
             
     | 
| 187 | 
         
            -
             
     | 
| 188 | 
         
            -
             
     | 
| 189 | 
         
            -
             
     | 
| 190 | 
         
            -
             
     | 
| 191 | 
         
            -
             
     | 
| 192 | 
         
            -
             
     | 
| 193 | 
         
            -
             
     | 
| 194 | 
         
            -
             
     | 
| 195 | 
         
            -
             
     | 
| 196 | 
         
            -
                
         
     | 
| 
         | 
|
| 197 | 
         
             
                #print (rawp)
         
     | 
| 198 | 
         
             
                #print (f'out:: {out}')
         
     | 
| 199 | 
         
             
                #history += "observation: the search results are:\n {}\n".format(out)
         
     | 
| 
         | 
|
| 26 | 
         
             
            )
         
     | 
| 27 | 
         | 
| 28 | 
         | 
| 29 | 
         
            +
             
     | 
| 30 | 
         
            +
            def read_txt(txt_path):
         
     | 
| 31 | 
         
            +
                text=""
         
     | 
| 32 | 
         
            +
                with open(txt_path,"r") as f:
         
     | 
| 33 | 
         
            +
                    text = f.read()
         
     | 
| 34 | 
         
            +
                f.close()
         
     | 
| 35 | 
         
            +
                print (text)
         
     | 
| 36 | 
         
            +
                return text
         
     | 
| 37 | 
         
            +
             
     | 
| 38 | 
         
             
            def read_pdf(pdf_path):
         
     | 
| 39 | 
         
             
                from pypdf import PdfReader
         
     | 
| 40 | 
         
             
                text=""
         
     | 
| 
         | 
|
| 188 | 
         
             
                            zz=read_pdf(file)
         
     | 
| 189 | 
         
             
                            print (zz)
         
     | 
| 190 | 
         
             
                            data=f'{data}\nFile:\n{zz}'
         
     | 
| 191 | 
         
            +
                        elif file.endswith(".txt"):
         
     | 
| 192 | 
         
            +
                            zz=read_txt(file)
         
     | 
| 193 | 
         
            +
                            print (zz)
         
     | 
| 194 | 
         
            +
                            data=f'{data}\nFile:\n{zz}'                
         
     | 
| 195 | 
         
             
                    except Exception as e:
         
     | 
| 196 | 
         
            +
                        data = "Error"
         
     | 
| 197 | 
         
             
                        print (e) 
         
     | 
| 198 | 
         
            +
                if not data == "Error":
         
     | 
| 199 | 
         
            +
                    print(inp)
         
     | 
| 200 | 
         
            +
                    out = str(data)
         
     | 
| 201 | 
         
            +
                    rl = len(out)
         
     | 
| 202 | 
         
            +
                    print(f'rl:: {rl}')
         
     | 
| 203 | 
         
            +
                    c=0
         
     | 
| 204 | 
         
            +
                    for i in str(out):
         
     | 
| 205 | 
         
            +
                        if i == " " or i=="," or i=="\n":
         
     | 
| 206 | 
         
            +
                            c +=1
         
     | 
| 207 | 
         
            +
                    print (f'c:: {c}')
         
     | 
| 208 | 
         
            +
                    
         
     | 
| 209 | 
         
            +
                    rawp = compress_data(c,inp,out)    
         
     | 
| 210 | 
         
            +
                else:
         
     | 
| 211 | 
         
            +
                    rawp = "Error"
         
     | 
| 212 | 
         
             
                #print (rawp)
         
     | 
| 213 | 
         
             
                #print (f'out:: {out}')
         
     | 
| 214 | 
         
             
                #history += "observation: the search results are:\n {}\n".format(out)
         
     |