Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from webscraping import get_about_section | |
| from llm_processing import generate_email | |
| from email_generator import format_email | |
| def process_input(input_type, url_or_text, recipient_name, project_name, key_features, email_style): | |
| try: | |
| # Get the about text based on input type | |
| if input_type == "URL of Recipient": | |
| about_text = get_about_section(url_or_text) | |
| if about_text.startswith("Error:"): | |
| return about_text | |
| else: | |
| # "Text" option | |
| about_text = url_or_text | |
| # Generate email using LLM with style | |
| generated_email = generate_email(about_text, recipient_name, project_name, key_features.split(','), email_style) | |
| if generated_email.startswith("Error:"): | |
| return generated_email | |
| # Format the email | |
| formatted_email = format_email(generated_email) | |
| return formatted_email | |
| except Exception as e: | |
| return f"An error occurred: {str(e)}" | |
| # Define Gradio interface | |
| iface = gr.Interface( | |
| fn=process_input, | |
| inputs=[ | |
| gr.Radio(["URL of Recipient", "Text"], label="Input Type"), | |
| gr.Textbox(label="Profile URL or About Text"), | |
| gr.Textbox(label="Recipient Name"), | |
| gr.Textbox(label="Project Name"), | |
| gr.Textbox(label="Key Features of your project (comma-separated)"), | |
| gr.Radio(["Casual", "Professional", "Cold"], label="Email Style") | |
| ], | |
| outputs=gr.Textbox(label="Generated Email"), | |
| title="Personalized Email Generator", | |
| description="Provide recipient information, project details, and select an email style to generate a personalized email." | |
| ) | |
| # Launch the app | |
| if __name__ == "__main__": | |
| iface.launch() |