Spaces:
				
			
			
	
			
			
		Runtime error
		
	
	
	
			
			
	
	
	
	
		
		
		Runtime error
		
	Commit 
							
							·
						
						30c5642
	
1
								Parent(s):
							
							3bcc6e5
								
db integration
Browse files- app.py +11 -0
- requirements.txt +2 -1
    	
        app.py
    CHANGED
    
    | @@ -7,6 +7,7 @@ import csv | |
| 7 | 
             
            import openai
         | 
| 8 | 
             
            import ast
         | 
| 9 | 
             
            import os
         | 
|  | |
| 10 |  | 
| 11 |  | 
| 12 | 
             
            openai.api_key = os.getenv('API_KEY')
         | 
| @@ -37,9 +38,19 @@ def get_json(mahalle, il, sokak, apartman): | |
| 37 | 
             
                dump = json.dumps(adres, indent=4, ensure_ascii=False)
         | 
| 38 | 
             
                return dump
         | 
| 39 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 40 |  | 
| 41 | 
             
            def text_dict(input):
         | 
| 42 | 
             
                eval_result = ast.literal_eval(input)
         | 
|  | |
| 43 |  | 
| 44 | 
             
                return (
         | 
| 45 | 
             
                    str(eval_result['city']),
         | 
|  | |
| 7 | 
             
            import openai
         | 
| 8 | 
             
            import ast
         | 
| 9 | 
             
            import os
         | 
| 10 | 
            +
            from deta import Deta
         | 
| 11 |  | 
| 12 |  | 
| 13 | 
             
            openai.api_key = os.getenv('API_KEY')
         | 
|  | |
| 38 | 
             
                dump = json.dumps(adres, indent=4, ensure_ascii=False)
         | 
| 39 | 
             
                return dump
         | 
| 40 |  | 
| 41 | 
            +
            def write_db(data_dict):
         | 
| 42 | 
            +
                # 2) initialize with a project key
         | 
| 43 | 
            +
                deta_key = os.getenv('DETA_KEY')
         | 
| 44 | 
            +
                deta = Deta(deta_key)
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                # 3) create and use as many DBs as you want!
         | 
| 47 | 
            +
                users = deta.Base("deprem-ocr")
         | 
| 48 | 
            +
                users.insert(data_dict)
         | 
| 49 | 
            +
             | 
| 50 |  | 
| 51 | 
             
            def text_dict(input):
         | 
| 52 | 
             
                eval_result = ast.literal_eval(input)
         | 
| 53 | 
            +
                write_db(eval_result)
         | 
| 54 |  | 
| 55 | 
             
                return (
         | 
| 56 | 
             
                    str(eval_result['city']),
         | 
    	
        requirements.txt
    CHANGED
    
    | @@ -1,4 +1,5 @@ | |
| 1 | 
             
            openai
         | 
| 2 | 
             
            Pillow
         | 
| 3 | 
             
            easyocr
         | 
| 4 | 
            -
            gradio
         | 
|  | 
|  | |
| 1 | 
             
            openai
         | 
| 2 | 
             
            Pillow
         | 
| 3 | 
             
            easyocr
         | 
| 4 | 
            +
            gradio
         | 
| 5 | 
            +
            deta
         | 

