Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,15 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from fpdf import FPDF
|
| 3 |
|
| 4 |
-
# Function to create
|
| 5 |
-
def
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
pdf.ln(10) # Line break
|
| 15 |
-
pdf.multi_cell(0, 10, document_text) # Allow wrapping text
|
| 16 |
-
|
| 17 |
-
return pdf
|
| 18 |
|
| 19 |
# Streamlit app
|
| 20 |
def main():
|
|
@@ -26,26 +21,21 @@ def main():
|
|
| 26 |
# Input text for the proposal
|
| 27 |
proposal_text = st.text_area("Enter the content of your proposal:", height=300)
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
# Check if the text is provided and if the button is clicked
|
| 30 |
if st.button("Generate Proposal"):
|
| 31 |
if proposal_text:
|
| 32 |
-
#
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
pdf_output = pdf.output(dest='S').encode('latin1') # Convert PDF to bytes for download
|
| 39 |
-
|
| 40 |
-
# Download button for the generated PDF
|
| 41 |
-
st.download_button(
|
| 42 |
-
label="Download Proposal as PDF",
|
| 43 |
-
data=pdf_output,
|
| 44 |
-
file_name="proposal.pdf",
|
| 45 |
-
mime="application/pdf"
|
| 46 |
-
)
|
| 47 |
else:
|
| 48 |
st.warning("Please enter the content of your proposal.")
|
| 49 |
|
| 50 |
if __name__ == "__main__":
|
| 51 |
-
main()
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
+
# Function to create various types of proposals with different patterns
|
| 4 |
+
def generate_proposal(document_text, style="formal"):
|
| 5 |
+
if style == "formal":
|
| 6 |
+
return f"Dear Sir/Madam,\n\nI am writing to propose the following idea:\n\n{document_text}\n\nSincerely,\nYour Name"
|
| 7 |
+
elif style == "casual":
|
| 8 |
+
return f"Hey there!\n\nI’ve been thinking about this idea:\n\n{document_text}\n\nLet me know what you think!\nCheers!"
|
| 9 |
+
elif style == "business":
|
| 10 |
+
return f"Subject: Proposal for the Idea\n\nDear [Recipient's Name],\n\nI would like to formally propose the following idea:\n\n{document_text}\n\nLooking forward to your feedback.\nBest regards,\n[Your Name]"
|
| 11 |
+
else:
|
| 12 |
+
return f"Proposal:\n\n{document_text}\n\nBest regards,\n[Your Name]"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# Streamlit app
|
| 15 |
def main():
|
|
|
|
| 21 |
# Input text for the proposal
|
| 22 |
proposal_text = st.text_area("Enter the content of your proposal:", height=300)
|
| 23 |
|
| 24 |
+
# Format (pattern) selection
|
| 25 |
+
st.subheader("Choose the format for your proposal")
|
| 26 |
+
format_choice = st.selectbox("Select the proposal format", ["Formal", "Casual", "Business"])
|
| 27 |
+
|
| 28 |
# Check if the text is provided and if the button is clicked
|
| 29 |
if st.button("Generate Proposal"):
|
| 30 |
if proposal_text:
|
| 31 |
+
# Generate the proposal with the selected format
|
| 32 |
+
formatted_proposal = generate_proposal(proposal_text, style=format_choice.lower())
|
| 33 |
+
|
| 34 |
+
# Display the generated proposal
|
| 35 |
+
st.subheader("Your Generated Proposal:")
|
| 36 |
+
st.markdown(f"```\n{formatted_proposal}\n```")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
else:
|
| 38 |
st.warning("Please enter the content of your proposal.")
|
| 39 |
|
| 40 |
if __name__ == "__main__":
|
| 41 |
+
main()
|