RAHULJUNEJA33 commited on
Commit
7e2c723
·
verified ·
1 Parent(s): 4717fd1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +61 -0
app.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+ from reportlab.lib.pagesizes import letter
4
+ from reportlab.pdfgen import canvas
5
+ import random
6
+
7
+ def generate_functional_requirements(topic):
8
+ generator = pipeline("text-generation", model="meta-llama/Llama-2-7b-chat-hf")
9
+ prompt = f"Generate a comprehensive functional requirement document for {topic} in the banking sector."
10
+
11
+ # Generate content
12
+ output = generator(prompt, max_length=4096, do_sample=True, temperature=0.8)
13
+ return output[0]['generated_text']
14
+
15
+ def save_to_pdf(content, filename):
16
+ c = canvas.Canvas(filename, pagesize=letter)
17
+ c.setFont("Helvetica", 12)
18
+
19
+ text = c.beginText(40, 750)
20
+ text.setFont("Helvetica", 10)
21
+ text.setLeading(14)
22
+
23
+ for line in content.split("\n"):
24
+ text.textLine(line)
25
+ if text.getY() < 50: # Start new page when space runs out
26
+ c.drawText(text)
27
+ c.showPage()
28
+ text = c.beginText(40, 750)
29
+ text.setFont("Helvetica", 10)
30
+ text.setLeading(14)
31
+
32
+ c.drawText(text)
33
+ c.save()
34
+
35
+ def main():
36
+ st.title("AI-Powered Functional Requirement Generator for Banking")
37
+
38
+ banking_topics = [
39
+ "Core Banking System",
40
+ "Loan Management System",
41
+ "Payment Processing Gateway",
42
+ "Risk and Fraud Detection",
43
+ "Regulatory Compliance Management",
44
+ "Digital Banking APIs",
45
+ "Customer Onboarding & KYC",
46
+ "Treasury Management",
47
+ "Wealth & Portfolio Management"
48
+ ]
49
+
50
+ topic = st.selectbox("Select a Banking Functional Requirement Topic", banking_topics)
51
+
52
+ if st.button("Generate Functional Requirement Document"):
53
+ with st.spinner("Generating... This may take a while."):
54
+ content = generate_functional_requirements(topic)
55
+ filename = "functional_requirement.pdf"
56
+ save_to_pdf(content, filename)
57
+ st.success("Functional requirement document generated successfully!")
58
+ st.download_button(label="Download PDF", data=open(filename, "rb"), file_name=filename, mime="application/pdf")
59
+
60
+ if __name__ == "__main__":
61
+ main()