import gradio as gr from transformers import pipeline bio_gpt = pipeline("text-generation", model="microsoft/biogpt") def medical_chatbot(query): try: result = bio_gpt(query, max_length=1000, num_return_sequences=1, temperature=0.7, top_k=50) generated_text = result[0]["generated_text"][len(query):].strip() return generated_text except Exception as e: print(f"Error: {e}") return "An error occurred." iface = gr.Interface( fn=medical_chatbot, inputs=gr.Textbox(placeholder="Ask me a medical question..."), outputs="text", title="Medical Chatbot" ) iface.launch(share=True)