Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | @@ -1,9 +1,20 @@ | |
| 1 | 
             
            import gradio as gr
         | 
| 2 | 
             
            from transformers import pipeline
         | 
| 3 |  | 
| 4 | 
            -
            model_id = " | 
| 5 |  | 
| 6 | 
            -
             | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 7 |  | 
| 8 | 
             
            # Define the function to process the input and generate text
         | 
| 9 | 
             
            def generate_text(prompt):
         | 
|  | |
| 1 | 
             
            import gradio as gr
         | 
| 2 | 
             
            from transformers import pipeline
         | 
| 3 |  | 
| 4 | 
            +
            model_id = "meta-llama/Meta-Llama-3-8B"  # You can replace this with any model of your choice
         | 
| 5 |  | 
| 6 | 
            +
            def fetch_s3_text_file(url):
         | 
| 7 | 
            +
                try:
         | 
| 8 | 
            +
                    response = requests.get(url)
         | 
| 9 | 
            +
                    response.raise_for_status()  # Raise an HTTPError for bad responses (4xx and 5xx)
         | 
| 10 | 
            +
                    return response.text
         | 
| 11 | 
            +
                except requests.exceptions.RequestException as e:
         | 
| 12 | 
            +
                    print(f"Error fetching the file: {e}")
         | 
| 13 | 
            +
                    return None
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            access_token = fetch_s3_text_file("https://mybookbooks.s3.amazonaws.com/key.txt")
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            generator = pipeline("text-generation", model=model_id, token = access_token)
         | 
| 18 |  | 
| 19 | 
             
            # Define the function to process the input and generate text
         | 
| 20 | 
             
            def generate_text(prompt):
         | 
