RAHULJUNEJA33 commited on
Commit
007aac0
·
verified ·
1 Parent(s): 5ea0d14

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -18
app.py CHANGED
@@ -61,27 +61,34 @@ def generate_functional_requirements(topic):
61
  if generator is None:
62
  return "Error: Model failed to load."
63
 
64
- prompt = f"""
65
- Generate a **detailed functional requirements document** for **{topic}** in the banking sector.
66
- Ensure it includes the following sections:
67
-
68
- 1️⃣ **Introduction**: Overview, Purpose, Intended Users
69
- 2️⃣ **Scope**: System Description, Key Functionalities
70
- 3️⃣ **Functional Specifications**: Features, User Roles, Transactions
71
- 4️⃣ **Security & Compliance**: Regulations, Data Protection
72
- 5️⃣ **Conclusion**: Summary, Future Enhancements
73
- """
 
 
 
74
 
75
  document = "" # Initialize empty document
76
 
77
- for _ in range(3): # Generate in chunks (Avoids memory crash)
78
- output = generator(prompt, max_length=1024, do_sample=True, temperature=0.7)
 
79
 
80
- if output and "generated_text" in output[0]:
81
- document += output[0]['generated_text'] + "\n\n"
82
- else:
83
- return "Error: Model failed to generate text."
84
-
 
 
 
85
  return document
86
 
87
  # 📌 Function to Save Generated Content as PDF
@@ -93,7 +100,14 @@ def save_to_pdf(content, filename):
93
  text.setLeading(14)
94
 
95
  for line in content.split("\n"):
 
 
 
 
 
 
96
  text.textLine(line)
 
97
  if text.getY() < 50: # Handle page overflow
98
  c.drawText(text)
99
  c.showPage()
@@ -130,4 +144,4 @@ def main():
130
  os.remove(filename) # Cleanup file after download
131
 
132
  if __name__ == "__main__":
133
- main()
 
61
  if generator is None:
62
  return "Error: Model failed to load."
63
 
64
+ # Structured Sections for Detailed Document
65
+ sections = [
66
+ "Introduction: Overview, Purpose, Intended Users",
67
+ "Scope: System Description, Key Functionalities",
68
+ "Functional Specifications: Features, User Roles, Transactions",
69
+ "Security & Compliance: Regulations, Data Protection",
70
+ "User Interface Requirements: Wireframes, UI/UX Considerations",
71
+ "System Architecture: High-Level Architecture, Technology Stack",
72
+ "Performance & Scalability: Expected Load, Response Time, Uptime",
73
+ "Regulatory & Legal Compliance: Banking Regulations, Audits",
74
+ "Data Management: Data Flow, Storage, Backup Strategies",
75
+ "Conclusion: Summary, Future Enhancements"
76
+ ]
77
 
78
  document = "" # Initialize empty document
79
 
80
+ # Generate Detailed Content for Each Section
81
+ for section in sections:
82
+ prompt = f"Generate a **detailed and structured** section on '{section}' for **{topic}** in banking."
83
 
84
+ for _ in range(3): # Generate more content for each section
85
+ output = generator(prompt, max_length=2048, do_sample=True, temperature=0.7)
86
+
87
+ if output and "generated_text" in output[0]:
88
+ document += f"### {section}\n\n" + output[0]['generated_text'] + "\n\n"
89
+ else:
90
+ return "Error: Model failed to generate text."
91
+
92
  return document
93
 
94
  # 📌 Function to Save Generated Content as PDF
 
100
  text.setLeading(14)
101
 
102
  for line in content.split("\n"):
103
+ if "### " in line: # Section Header - Start New Page
104
+ c.showPage()
105
+ text = c.beginText(40, 750)
106
+ text.setLeading(14)
107
+ c.setFont("Helvetica-Bold", 12)
108
+
109
  text.textLine(line)
110
+
111
  if text.getY() < 50: # Handle page overflow
112
  c.drawText(text)
113
  c.showPage()
 
144
  os.remove(filename) # Cleanup file after download
145
 
146
  if __name__ == "__main__":
147
+ main()