Spaces:
Sleeping
Sleeping
Commit ·
bf2bc7a
1
Parent(s): 07bd23e
Added the code to view input template, with more user appealing web interface
Browse files
app.py
CHANGED
|
@@ -30,18 +30,61 @@ def process_csv(file, user_prompt):
|
|
| 30 |
|
| 31 |
|
| 32 |
# Streamlit UI
|
| 33 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
# File uploader for CSV
|
| 36 |
-
uploaded_file = st.file_uploader("Upload CSV File", type=["csv"])
|
| 37 |
-
user_prompt = st.text_area(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
|
|
|
| 39 |
if uploaded_file is not None and user_prompt:
|
| 40 |
-
st.write("Processing file...")
|
| 41 |
processed_df = process_csv(uploaded_file, user_prompt)
|
| 42 |
|
| 43 |
# Display results
|
| 44 |
-
st.
|
|
|
|
| 45 |
|
| 46 |
# Option to download the processed CSV
|
| 47 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".csv") as temp_file:
|
|
@@ -49,11 +92,17 @@ if uploaded_file is not None and user_prompt:
|
|
| 49 |
temp_file.close() # Ensure the file is properly closed before proceeding
|
| 50 |
|
| 51 |
st.download_button(
|
| 52 |
-
label="Download Results CSV",
|
| 53 |
data=open(temp_file.name, "rb"),
|
| 54 |
file_name="generated_invitations.csv",
|
| 55 |
-
mime="text/csv"
|
| 56 |
)
|
| 57 |
|
| 58 |
-
#
|
| 59 |
os.unlink(temp_file.name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
|
| 32 |
# Streamlit UI
|
| 33 |
+
st.set_page_config(page_title="Invitation Generator", page_icon="📜", layout="wide")
|
| 34 |
+
|
| 35 |
+
# Header
|
| 36 |
+
st.title("Invite AI")
|
| 37 |
+
st.markdown(
|
| 38 |
+
"""
|
| 39 |
+
Welcome to the Invitation Generator! This tool helps you create personalized invitations using the power of AI.
|
| 40 |
+
Follow the steps below to upload your data and generate professional invitation texts.
|
| 41 |
+
"""
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
# Section: Template Download and Instructions
|
| 45 |
+
st.sidebar.title("Instructions")
|
| 46 |
+
st.sidebar.markdown(
|
| 47 |
+
"""
|
| 48 |
+
### Template Download
|
| 49 |
+
[Click here to download the suggested CSV template](http://surl.li/ptvzzv) 📥
|
| 50 |
+
|
| 51 |
+
### Required Fields
|
| 52 |
+
- **Unique Identifier for each receiver**
|
| 53 |
+
- **Name of the receiver**
|
| 54 |
+
- **Designation/Job title of the receiver**
|
| 55 |
+
- **Company/Organisation where the receiver works**
|
| 56 |
+
- **Areas the receiver is interested in / has expertise in**
|
| 57 |
+
- **Categorize receivers into groups** for consistent instructions.
|
| 58 |
+
"""
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
# Main Section
|
| 62 |
+
st.markdown(
|
| 63 |
+
"""
|
| 64 |
+
### Steps to Use
|
| 65 |
+
1. **Download the template** from the sidebar.
|
| 66 |
+
2. **Fill out the details** as per the instructions.
|
| 67 |
+
3. **Upload the completed CSV file** below.
|
| 68 |
+
4. Enter a **prompt** to generate personalized invitations.
|
| 69 |
+
"""
|
| 70 |
+
)
|
| 71 |
|
| 72 |
# File uploader for CSV
|
| 73 |
+
uploaded_file = st.file_uploader("📂 Upload CSV File", type=["csv"])
|
| 74 |
+
user_prompt = st.text_area(
|
| 75 |
+
"✍️ Enter the prompt for generating invitation texts:",
|
| 76 |
+
"Write professional invitation text tailored for the group.",
|
| 77 |
+
height=150,
|
| 78 |
+
)
|
| 79 |
|
| 80 |
+
# Processing and displaying results
|
| 81 |
if uploaded_file is not None and user_prompt:
|
| 82 |
+
st.write("⏳ Processing your file... Please wait.")
|
| 83 |
processed_df = process_csv(uploaded_file, user_prompt)
|
| 84 |
|
| 85 |
# Display results
|
| 86 |
+
st.write("### Generated Invitations")
|
| 87 |
+
st.dataframe(processed_df, use_container_width=True)
|
| 88 |
|
| 89 |
# Option to download the processed CSV
|
| 90 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".csv") as temp_file:
|
|
|
|
| 92 |
temp_file.close() # Ensure the file is properly closed before proceeding
|
| 93 |
|
| 94 |
st.download_button(
|
| 95 |
+
label="📥 Download Results CSV",
|
| 96 |
data=open(temp_file.name, "rb"),
|
| 97 |
file_name="generated_invitations.csv",
|
| 98 |
+
mime="text/csv",
|
| 99 |
)
|
| 100 |
|
| 101 |
+
# Safely delete the temporary file
|
| 102 |
os.unlink(temp_file.name)
|
| 103 |
+
|
| 104 |
+
# Footer
|
| 105 |
+
st.markdown("---")
|
| 106 |
+
st.markdown(
|
| 107 |
+
"💡 **Tip:** Ensure your data aligns with the provided template for accurate results."
|
| 108 |
+
)
|