Spaces:
				
			
			
	
			
			
		Runtime error
		
	
	
	
			
			
	
	
	
	
		
		
		Runtime error
		
	| import gradio as gr | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| # Load your model and tokenizer | |
| model_name = "facebook/blenderbot-400M-distill" # Replace with your model | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| model = AutoModelForCausalLM.from_pretrained(model_name) | |
| # Define the chatbot function | |
| def chatbot_response(input_text): | |
| inputs = tokenizer.encode(input_text, return_tensors="pt") | |
| outputs = model.generate(inputs, max_length=50, num_return_sequences=1) | |
| response = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| return response | |
| # Create Gradio interface | |
| interface = gr.Interface( | |
| fn=chatbot_response, | |
| inputs=gr.Textbox(label="Ask me anything!"), | |
| outputs=gr.Textbox(label="Response"), | |
| title="My Chatbot", | |
| description="A simple chatbot deployed using Hugging Face Spaces and Gradio!" | |
| ) | |
| # Launch the app | |
| if __name__ == "__main__": | |
| interface.launch() | |