import gradio as gr from transformers import pipeline import os # Initialize Hugging Face model model_name = "gpt2" # Use an appropriate Hugging Face model (e.g., GPT-2 for general text generation) generator = pipeline("text-generation", model=model_name) # Function to generate the construction checklist using Hugging Face model def generate_checklist(project_type, project_size, location, timeline): prompt = f"Generate a detailed construction checklist for a {project_type} with {project_size} in {location}. The project timeline is {timeline}." # Generate text using Hugging Face model generated_text = generator(prompt, max_length=500, num_return_sequences=1) return generated_text[0]['generated_text'].strip() # Gradio interface def gradio_interface(): # Inputs for the form inputs = [ gr.Textbox(label="Project Type (e.g., House, Office, Shed)", placeholder="Enter the project type..."), gr.Textbox(label="Project Size (e.g., 2000 sq ft)", placeholder="Enter the project size..."), gr.Textbox(label="Location (optional, e.g., California)", placeholder="Enter location..."), gr.Textbox(label="Timeline (optional, e.g., 6 months)", placeholder="Enter the project timeline..."), ] # Output for the generated checklist output = gr.Textbox(label="Generated Construction Checklist") # Create and launch the Gradio interface gr.Interface(fn=generate_checklist, inputs=inputs, outputs=output, live=True).launch() # Run the Gradio interface when the script is executed if __name__ == "__main__": gradio_interface()