Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | 
         @@ -2,17 +2,18 @@ import openai 
     | 
|
| 2 | 
         
             
            import gradio as gr
         
     | 
| 3 | 
         | 
| 4 | 
         
             
            # Set up OpenAI API key
         
     | 
| 5 | 
         
            -
            openai.api_key = " 
     | 
| 6 | 
         | 
| 7 | 
         
             
            # Define a function to call the OpenAI API
         
     | 
| 8 | 
         
             
            def chatbot(input_text):
         
     | 
| 9 | 
         
             
                try:
         
     | 
| 10 | 
         
            -
                     
     | 
| 11 | 
         
            -
             
     | 
| 
         | 
|
| 12 | 
         
             
                        prompt=input_text,
         
     | 
| 13 | 
         
             
                        max_tokens=150
         
     | 
| 14 | 
         
             
                    )
         
     | 
| 15 | 
         
            -
                    return response 
     | 
| 16 | 
         
             
                except Exception as e:
         
     | 
| 17 | 
         
             
                    return f"Error: {str(e)}"
         
     | 
| 18 | 
         | 
| 
         @@ -26,4 +27,3 @@ iface = gr.Interface( 
     | 
|
| 26 | 
         | 
| 27 | 
         
             
            # Launch the interface
         
     | 
| 28 | 
         
             
            iface.launch()
         
     | 
| 29 | 
         
            -
             
     | 
| 
         | 
|
| 2 | 
         
             
            import gradio as gr
         
     | 
| 3 | 
         | 
| 4 | 
         
             
            # Set up OpenAI API key
         
     | 
| 5 | 
         
            +
            openai.api_key = "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"
         
     | 
| 6 | 
         | 
| 7 | 
         
             
            # Define a function to call the OpenAI API
         
     | 
| 8 | 
         
             
            def chatbot(input_text):
         
     | 
| 9 | 
         
             
                try:
         
     | 
| 10 | 
         
            +
                    # Updated API call for v1.0.0+
         
     | 
| 11 | 
         
            +
                    response = openai.Completion.create(
         
     | 
| 12 | 
         
            +
                        model="gpt-3.5-turbo",  # You can change this to GPT-4 or others
         
     | 
| 13 | 
         
             
                        prompt=input_text,
         
     | 
| 14 | 
         
             
                        max_tokens=150
         
     | 
| 15 | 
         
             
                    )
         
     | 
| 16 | 
         
            +
                    return response['choices'][0]['text'].strip()
         
     | 
| 17 | 
         
             
                except Exception as e:
         
     | 
| 18 | 
         
             
                    return f"Error: {str(e)}"
         
     | 
| 19 | 
         | 
| 
         | 
|
| 27 | 
         | 
| 28 | 
         
             
            # Launch the interface
         
     | 
| 29 | 
         
             
            iface.launch()
         
     | 
| 
         |