Spaces:
Build error
Build error
Commit
·
b12c19b
1
Parent(s):
139e987
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from reportlab.pdfgen import canvas
|
| 3 |
|
| 4 |
-
def
|
| 5 |
-
|
| 6 |
-
|
| 7 |
content = f"AI Innovation Challenges Documentation Template:\n\nProject Title: {project_title}\n"
|
| 8 |
content += f"**Objective:**\n{objectives}\n"
|
| 9 |
content += f"**Metrics:**\n- Collaborator Numbers: {metrics_collaborators} AI experts and innovators engaged.\n"
|
|
@@ -12,12 +12,123 @@ def generate_pdf(project_title, objectives, metrics_collaborators, metrics_impac
|
|
| 12 |
content += f"**Key Achievements:**\n- Collaborated with {achievements_collaborators} innovators from diverse backgrounds.\n"
|
| 13 |
content += f"- Generated {achievements_solutions} cutting-edge solutions addressing AI challenges.\n"
|
| 14 |
content += f"- Successfully implemented {achievements_implementation} solutions in real-world scenarios.\n\n"
|
| 15 |
-
content += f"**Lessons Learned:**\n-
|
| 16 |
-
content += f"-
|
| 17 |
-
content += f"-
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
c = canvas.Canvas(pdf_filename)
|
| 22 |
width, height = c._pagesize
|
| 23 |
c.setFont("Helvetica", 12)
|
|
@@ -29,38 +140,103 @@ def generate_pdf(project_title, objectives, metrics_collaborators, metrics_impac
|
|
| 29 |
return pdf_filename
|
| 30 |
|
| 31 |
def main():
|
| 32 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
# Input boxes for each section
|
| 35 |
project_title = st.text_input("Project Title")
|
| 36 |
objectives = st.text_area("Objectives")
|
| 37 |
-
metrics_collaborators = st.text_input("Collaborator Numbers")
|
| 38 |
-
metrics_impact = st.text_input("Impact Results
|
| 39 |
metrics_outcomes = st.text_input("Final Outcomes")
|
| 40 |
-
achievements_collaborators = st.text_input("Collaborated with
|
| 41 |
-
achievements_solutions = st.text_input("Generated
|
| 42 |
-
achievements_implementation = st.text_input("Successfully implemented
|
| 43 |
-
lessons_collaboration = st.text_area("Importance of interdisciplinary collaboration
|
| 44 |
-
|
| 45 |
lessons_insights = st.text_area("Insights into challenges and opportunities")
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
|
|
|
| 66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from reportlab.pdfgen import canvas
|
| 3 |
|
| 4 |
+
def generate_ai_innovation_pdf(project_title, objectives, metrics_collaborators, metrics_impact, metrics_outcomes,
|
| 5 |
+
achievements_collaborators, achievements_solutions, achievements_implementation,
|
| 6 |
+
lessons_collaboration, lessons_measuring, lessons_insights):
|
| 7 |
content = f"AI Innovation Challenges Documentation Template:\n\nProject Title: {project_title}\n"
|
| 8 |
content += f"**Objective:**\n{objectives}\n"
|
| 9 |
content += f"**Metrics:**\n- Collaborator Numbers: {metrics_collaborators} AI experts and innovators engaged.\n"
|
|
|
|
| 12 |
content += f"**Key Achievements:**\n- Collaborated with {achievements_collaborators} innovators from diverse backgrounds.\n"
|
| 13 |
content += f"- Generated {achievements_solutions} cutting-edge solutions addressing AI challenges.\n"
|
| 14 |
content += f"- Successfully implemented {achievements_implementation} solutions in real-world scenarios.\n\n"
|
| 15 |
+
content += f"**Lessons Learned:**\n- {lessons_collaboration}\n"
|
| 16 |
+
content += f"- {lessons_measuring}\n"
|
| 17 |
+
content += f"- {lessons_insights}"
|
| 18 |
|
| 19 |
+
pdf_filename = f"{project_title.replace(' ', '_')}_ai_innovation_output.pdf"
|
| 20 |
+
c = canvas.Canvas(pdf_filename)
|
| 21 |
+
width, height = c._pagesize
|
| 22 |
+
c.setFont("Helvetica", 12)
|
| 23 |
+
lines = content.split('\n')
|
| 24 |
+
for i, line in enumerate(lines):
|
| 25 |
+
c.drawString(100, height - 100 - i * 12, line)
|
| 26 |
+
c.save()
|
| 27 |
+
|
| 28 |
+
return pdf_filename
|
| 29 |
+
|
| 30 |
+
def generate_community_impact_pdf(project_title, objectives, metrics_collaborators, metrics_impact, metrics_outcomes,
|
| 31 |
+
achievements_collaborators, achievements_solutions, achievements_implementation,
|
| 32 |
+
lessons_collaboration, lessons_measuring, lessons_insights):
|
| 33 |
+
content = f"Community Impact Report Documentation Template:\n\nProject Title: {project_title}\n"
|
| 34 |
+
content += f"**Objective:**\n{objectives}\n"
|
| 35 |
+
content += f"**Metrics:**\n- Collaborator Numbers: {metrics_collaborators} community members involved.\n"
|
| 36 |
+
content += f"- Impact Results: {metrics_impact} positive changes or contributions.\n"
|
| 37 |
+
content += f"- Final Outcomes: {metrics_outcomes} sustainable impact on the community.\n\n"
|
| 38 |
+
content += f"**Key Achievements:**\n- Engaged with {achievements_collaborators} community members through diverse initiatives.\n"
|
| 39 |
+
content += f"- Implemented projects resulting in {achievements_solutions} positive changes.\n"
|
| 40 |
+
content += f"- Established {achievements_implementation} sustainable solutions for long-term impact.\n\n"
|
| 41 |
+
content += f"**Lessons Learned:**\n- {lessons_collaboration}\n"
|
| 42 |
+
content += f"- {lessons_measuring}\n"
|
| 43 |
+
content += f"- {lessons_insights}"
|
| 44 |
+
|
| 45 |
+
pdf_filename = f"{project_title.replace(' ', '_')}_community_impact_output.pdf"
|
| 46 |
+
c = canvas.Canvas(pdf_filename)
|
| 47 |
+
width, height = c._pagesize
|
| 48 |
+
c.setFont("Helvetica", 12)
|
| 49 |
+
lines = content.split('\n')
|
| 50 |
+
for i, line in enumerate(lines):
|
| 51 |
+
c.drawString(100, height - 100 - i * 12, line)
|
| 52 |
+
c.save()
|
| 53 |
+
|
| 54 |
+
return pdf_filename
|
| 55 |
+
|
| 56 |
+
def generate_local_chapter_challenges_pdf(project_title, objectives, metrics_collaborators, metrics_impact, metrics_outcomes,
|
| 57 |
+
achievements_collaborators, achievements_solutions, achievements_implementation,
|
| 58 |
+
lessons_collaboration, lessons_cross_chapter, lessons_local_context):
|
| 59 |
+
content = f"Local Chapter Challenges Documentation Template:\n\nProject Title: {project_title}\n"
|
| 60 |
+
content += f"**Objective:**\n{objectives}\n"
|
| 61 |
+
content += f"**Metrics:**\n- Collaborator Numbers: {metrics_collaborators} local chapter members involved.\n"
|
| 62 |
+
content += f"- Impact Results: {metrics_impact} challenges identified and resolved.\n"
|
| 63 |
+
content += f"- Final Outcomes: {metrics_outcomes} documented solutions for knowledge sharing.\n\n"
|
| 64 |
+
content += f"**Key Achievements:**\n- Engaged with {achievements_collaborators} local chapters across {achievements_solutions} regions.\n"
|
| 65 |
+
content += f"- Identified and addressed {achievements_implementation} challenges through collaborative efforts.\n"
|
| 66 |
+
content += f"- Established a knowledge-sharing platform for local chapters.\n\n"
|
| 67 |
+
content += f"**Lessons Learned:**\n- {lessons_collaboration}\n"
|
| 68 |
+
content += f"- {lessons_cross_chapter}\n"
|
| 69 |
+
content += f"- {lessons_local_context}"
|
| 70 |
+
|
| 71 |
+
pdf_filename = f"{project_title.replace(' ', '_')}_local_chapter_challenges_output.pdf"
|
| 72 |
+
c = canvas.Canvas(pdf_filename)
|
| 73 |
+
width, height = c._pagesize
|
| 74 |
+
c.setFont("Helvetica", 12)
|
| 75 |
+
lines = content.split('\n')
|
| 76 |
+
for i, line in enumerate(lines):
|
| 77 |
+
c.drawString(100, height - 100 - i * 12, line)
|
| 78 |
+
c.save()
|
| 79 |
+
|
| 80 |
+
return pdf_filename
|
| 81 |
+
|
| 82 |
+
def generate_academy_project_pdf(project_title, lead_facilitator, collaborators, project_overview, collaborator_metrics,
|
| 83 |
+
project_deliverables, class_deliverables, impact_metrics, milestones, evaluation_feedback,
|
| 84 |
+
resources_support, timeline, communication_channels, next_steps):
|
| 85 |
+
content = f"Omdena Academy Project Template\nProject Title: {project_title}\n"
|
| 86 |
+
content += f"Collaborators:\n- Lead Facilitator: {lead_facilitator}\n- Collaborators: {collaborators}\n"
|
| 87 |
+
content += f"Project Overview:\n- {project_overview}\n\n"
|
| 88 |
+
content += f"Key Metrics:\n1. Collaborator Metrics:\n- Number of Collaborators: {collaborator_metrics}\n"
|
| 89 |
+
content += f"- Diversity Metrics: {impact_metrics['diversity']}\n"
|
| 90 |
+
content += f"2. Deliverables:\n- Project Deliverables: {project_deliverables}\n- Class Deliverables: {class_deliverables}\n\n"
|
| 91 |
+
content += f"Impact Metrics:\n1. Social Impact:\n- {impact_metrics['social']}\n"
|
| 92 |
+
content += f"2. Technical Impact:\n- {impact_metrics['technical']}\n"
|
| 93 |
+
content += f"3. Learning Impact:\n- {impact_metrics['learning']}\n\n"
|
| 94 |
+
content += f"Milestones:\n1. Project Milestones: {milestones['project']}\n"
|
| 95 |
+
content += f"2. Learning Milestones: {milestones['learning']}\n\n"
|
| 96 |
+
content += f"Evaluation and Feedback:\n1. Continuous Evaluation: {evaluation_feedback['continuous']}\n"
|
| 97 |
+
content += f"2. Feedback Mechanism: {evaluation_feedback['mechanism']}\n\n"
|
| 98 |
+
content += f"Resources and Support:\n1. Collaborator Support: {resources_support['collaborator']}\n"
|
| 99 |
+
content += f"2. Learning Resources: {resources_support['learning']}\n\n"
|
| 100 |
+
content += f"Timeline:\n- {timeline}\n\n"
|
| 101 |
+
content += f"Communication Channels:\n- Primary Communication Platform: {communication_channels['platform']}\n"
|
| 102 |
+
content += f"- Regular Meetings: {communication_channels['meetings']}\n\n"
|
| 103 |
+
content += f"Next Steps:\n- {next_steps}"
|
| 104 |
+
|
| 105 |
+
pdf_filename = f"{project_title.replace(' ', '_')}_academy_project_output.pdf"
|
| 106 |
+
c = canvas.Canvas(pdf_filename)
|
| 107 |
+
width, height = c._pagesize
|
| 108 |
+
c.setFont("Helvetica", 12)
|
| 109 |
+
lines = content.split('\n')
|
| 110 |
+
for i, line in enumerate(lines):
|
| 111 |
+
c.drawString(100, height - 100 - i * 12, line)
|
| 112 |
+
c.save()
|
| 113 |
+
|
| 114 |
+
return pdf_filename
|
| 115 |
+
|
| 116 |
+
def generate_top_talent_deployment_pdf(project_title, objectives, metrics_collaborators, metrics_impact, metrics_outcomes,
|
| 117 |
+
achievements_collaborators, achievements_solutions, achievements_implementation,
|
| 118 |
+
lessons_collaboration, lessons_insights, lessons_continuous_improvement):
|
| 119 |
+
content = f"Top Talent/Product Deployment Documentation Template:\n\nProject Title: {project_title}\n"
|
| 120 |
+
content += f"**Objective:**\n{objectives}\n"
|
| 121 |
+
content += f"**Metrics:**\n- Collaborator Numbers: {metrics_collaborators} top talents or product developers involved.\n"
|
| 122 |
+
content += f"- Impact Results: {metrics_impact} successful deployments or launches.\n"
|
| 123 |
+
content += f"- Final Outcomes: {metrics_outcomes} measurable impact on the target audience or market.\n\n"
|
| 124 |
+
content += f"**Key Achievements:**\n- Engaged with {achievements_collaborators} top talents or product developers.\n"
|
| 125 |
+
content += f"- Executed successful deployments resulting in {achievements_solutions} positive outcomes.\n"
|
| 126 |
+
content += f"- Achieved {achievements_implementation} market recognition or user satisfaction.\n\n"
|
| 127 |
+
content += f"**Lessons Learned:**\n- {lessons_collaboration}\n"
|
| 128 |
+
content += f"- {lessons_insights}\n"
|
| 129 |
+
content += f"- {lessons_continuous_improvement}"
|
| 130 |
+
|
| 131 |
+
pdf_filename = f"{project_title.replace(' ', '_')}_top_talent_deployment_output.pdf"
|
| 132 |
c = canvas.Canvas(pdf_filename)
|
| 133 |
width, height = c._pagesize
|
| 134 |
c.setFont("Helvetica", 12)
|
|
|
|
| 140 |
return pdf_filename
|
| 141 |
|
| 142 |
def main():
|
| 143 |
+
st.set_page_config(layout="wide", page_title="Documentation App", page_icon="📄")
|
| 144 |
+
|
| 145 |
+
# Set background color to white
|
| 146 |
+
st.markdown(
|
| 147 |
+
"""
|
| 148 |
+
<style>
|
| 149 |
+
body {
|
| 150 |
+
background-color: #ffffff;
|
| 151 |
+
}
|
| 152 |
+
</style>
|
| 153 |
+
""",
|
| 154 |
+
unsafe_allow_html=True
|
| 155 |
+
)
|
| 156 |
+
|
| 157 |
+
# Set side panel color to blue
|
| 158 |
+
st.sidebar.markdown(
|
| 159 |
+
"""
|
| 160 |
+
<style>
|
| 161 |
+
div.sidebar {
|
| 162 |
+
background-color: #3498db;
|
| 163 |
+
}
|
| 164 |
+
</style>
|
| 165 |
+
""",
|
| 166 |
+
unsafe_allow_html=True
|
| 167 |
+
)
|
| 168 |
+
|
| 169 |
+
st.sidebar.title("Select Document Type")
|
| 170 |
+
document_type = st.sidebar.selectbox("Choose Document Type", ["AI Innovation Challenges", "Community Impact Report", "Local Chapter Challenges", "Omdena Academy Project", "Top Talent/Product Deployment"])
|
| 171 |
+
|
| 172 |
+
st.title(f"{document_type} Documentation App")
|
| 173 |
|
| 174 |
# Input boxes for each section
|
| 175 |
project_title = st.text_input("Project Title")
|
| 176 |
objectives = st.text_area("Objectives")
|
| 177 |
+
metrics_collaborators = st.text_input("Collaborator Numbers" )
|
| 178 |
+
metrics_impact = st.text_input("Impact Results")
|
| 179 |
metrics_outcomes = st.text_input("Final Outcomes")
|
| 180 |
+
achievements_collaborators = st.text_input("Collaborated with")
|
| 181 |
+
achievements_solutions = st.text_input("Generated cutting-edge solutions")
|
| 182 |
+
achievements_implementation = st.text_input("Successfully implemented")
|
| 183 |
+
lessons_collaboration = st.text_area("Importance of interdisciplinary collaboration")
|
| 184 |
+
lessons_measuring = st.text_area("Strategies for measuring and sustaining impact")
|
| 185 |
lessons_insights = st.text_area("Insights into challenges and opportunities")
|
| 186 |
|
| 187 |
+
if document_type == "AI Innovation Challenges":
|
| 188 |
+
pdf_filename = generate_ai_innovation_pdf(project_title, objectives, metrics_collaborators, metrics_impact, metrics_outcomes,
|
| 189 |
+
achievements_collaborators, achievements_solutions, achievements_implementation,
|
| 190 |
+
lessons_collaboration, lessons_measuring, lessons_insights)
|
| 191 |
+
elif document_type == "Community Impact Report":
|
| 192 |
+
pdf_filename = generate_community_impact_pdf(project_title, objectives, metrics_collaborators, metrics_impact, metrics_outcomes,
|
| 193 |
+
achievements_collaborators, achievements_solutions, achievements_implementation,
|
| 194 |
+
lessons_collaboration, lessons_measuring, lessons_insights)
|
| 195 |
+
elif document_type == "Local Chapter Challenges":
|
| 196 |
+
pdf_filename = generate_local_chapter_challenges_pdf(project_title, objectives, metrics_collaborators, metrics_impact, metrics_outcomes,
|
| 197 |
+
achievements_collaborators, achievements_solutions, achievements_implementation,
|
| 198 |
+
lessons_collaboration, lessons_cross_chapter, lessons_local_context)
|
| 199 |
+
elif document_type == "Omdena Academy Project":
|
| 200 |
+
lead_facilitator = st.text_input("Lead Facilitator")
|
| 201 |
+
collaborators = st.text_input("Collaborators (comma-separated)")
|
| 202 |
+
project_overview = st.text_area("Project Overview")
|
| 203 |
+
collaborator_metrics = st.text_input("Number of Collaborators")
|
| 204 |
+
project_deliverables = st.text_input("Project Deliverables (comma-separated)")
|
| 205 |
+
class_deliverables = st.text_input("Class Deliverables (comma-separated)")
|
| 206 |
+
impact_metrics_social = st.text_input("Social Impact Metrics")
|
| 207 |
+
impact_metrics_technical = st.text_input("Technical Impact Metrics")
|
| 208 |
+
impact_metrics_learning = st.text_input("Learning Impact Metrics")
|
| 209 |
+
milestones_project = st.text_input("Project Milestones (comma-separated)")
|
| 210 |
+
milestones_learning = st.text_input("Learning Milestones (comma-separated)")
|
| 211 |
+
evaluation_feedback_continuous = st.text_area("Continuous Evaluation")
|
| 212 |
+
evaluation_feedback_mechanism = st.text_area("Feedback Mechanism")
|
| 213 |
+
resources_support_collaborator = st.text_area("Collaborator Support")
|
| 214 |
+
resources_support_learning = st.text_input("Learning Resources (comma-separated)")
|
| 215 |
+
timeline = st.text_area("Timeline")
|
| 216 |
+
communication_channels_platform = st.text_input("Primary Communication Platform")
|
| 217 |
+
communication_channels_meetings = st.text_input("Regular Meetings (e.g., frequency and format)")
|
| 218 |
+
next_steps = st.text_area("Next Steps")
|
| 219 |
|
| 220 |
+
pdf_filename = generate_academy_project_pdf(project_title, lead_facilitator, collaborators, project_overview, collaborator_metrics,
|
| 221 |
+
project_deliverables, class_deliverables, impact_metrics, milestones, evaluation_feedback,
|
| 222 |
+
resources_support, timeline, {"platform": communication_channels_platform, "meetings": communication_channels_meetings},
|
| 223 |
+
next_steps)
|
| 224 |
+
else: # Top Talent/Product Deployment
|
| 225 |
+
metrics_continuous_improvement = st.text_area("Continuous Improvement Approaches")
|
| 226 |
+
pdf_filename = generate_top_talent_deployment_pdf(project_title, objectives, metrics_collaborators, metrics_impact, metrics_outcomes,
|
| 227 |
+
achievements_collaborators, achievements_solutions, achievements_implementation,
|
| 228 |
+
lessons_collaboration, lessons_insights, metrics_continuous_improvement)
|
| 229 |
|
| 230 |
+
st.success(f"PDF generated successfully! [Download PDF]({pdf_filename})")
|
| 231 |
|
| 232 |
+
# Download button
|
| 233 |
+
st.download_button(
|
| 234 |
+
label="Click to Download",
|
| 235 |
+
data=open(pdf_filename, "rb").read(),
|
| 236 |
+
key="download_pdf",
|
| 237 |
+
file_name=pdf_filename,
|
| 238 |
+
mime="application/pdf",
|
| 239 |
+
)
|
| 240 |
+
|
| 241 |
+
if __name__ == "__main__":
|
| 242 |
+
main()
|