pponnolu commited on
Commit
c5c4ac8
·
verified ·
1 Parent(s): ccb2dd0

Upload 4 files

Browse files
Files changed (4) hide show
  1. README.md +13 -3
  2. app.py +145 -0
  3. gitattributes +35 -0
  4. requirements.txt +5 -0
README.md CHANGED
@@ -1,3 +1,13 @@
1
- ---
2
- license: afl-3.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: RFP
3
+ emoji: 💬
4
+ colorFrom: yellow
5
+ colorTo: purple
6
+ sdk: gradio
7
+ sdk_version: 4.36.1
8
+ app_file: app.py
9
+ pinned: false
10
+ license: afl-3.0
11
+ ---
12
+
13
+ An example chatbot using [Gradio](https://gradio.app), [`huggingface_hub`](https://huggingface.co/docs/huggingface_hub/v0.22.2/en/index), and the [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index).
app.py ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ from docx import Document
3
+ from docx.shared import Pt
4
+ from io import BytesIO
5
+ from base64 import b64encode
6
+ from reportlab.lib.pagesizes import letter
7
+ from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
8
+ from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
9
+ import gradio as gr
10
+ from huggingface_hub import InferenceClient
11
+
12
+ # Initialize Hugging Face Inference Client
13
+ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
14
+
15
+ def generate_rfp_response_content(input_text):
16
+ prompt = f"""
17
+ Generate a response to the following RFP based on the provided input:
18
+ {input_text}
19
+
20
+ The response should include the following sections:
21
+ 1. Cover Letter: Write a cover letter addressed to the client, expressing appreciation for the opportunity to respond to the RFP and outlining the key points of the response.
22
+ 2. Executive Summary: Summarize the key elements of the response, highlighting the main points and benefits of choosing our company.
23
+ 3. Vendor Profile: Provide an overview of our company, including our history, mission, and key capabilities.
24
+ 4. Technical Approach: Detail our technical approach to the project, explaining how we will meet the requirements and deliver the desired outcomes.
25
+ 5. Project Plan: Outline our proposed project plan, including major milestones, timelines, and deliverables.
26
+ 6. Cost Proposal: Present our cost proposal, breaking down the costs associated with the project.
27
+ 7. Experience and References: Highlight our relevant experience and provide references from similar projects.
28
+ 8. Compliance and Certifications: Detail our compliance with the required standards and any relevant certifications we hold.
29
+ 9. Support and Maintenance: Explain our support and maintenance services post-implementation.
30
+ 10. Appendices: Include any additional information or documents relevant to the response.
31
+ 11. Timeline: This document outlines the project timeline, including major milestones and deliverables.
32
+ 12. Risk Management Plan: This document outlines our risk management approach, identifying potential risks and mitigation strategies.
33
+ 13. Change Request Form: This document provides a standardized form for requesting changes to the project scope, timeline, or budget.
34
+
35
+ Non-Functional Requirements (Low Priority)
36
+ 4.1 Performance
37
+ • The system should generate RFP responses within 1 minute.
38
+ • The API should handle up to 100 concurrent requests.
39
+ 4.2 Scalability
40
+ • The system should scale horizontally to accommodate increased load.
41
+ 4.3 Security
42
+ • Ensure compliance with data protection regulations (e.g., GDPR, CCPA).
43
+ • Implement robust authentication and authorization mechanisms.
44
+ 4.4 Reliability
45
+ • The system should have an uptime of 99.9%.
46
+ • Implement failover mechanisms to ensure high availability.
47
+ 4.5 Usability
48
+ • The user interface should be intuitive and easy to navigate.
49
+ • Provide comprehensive documentation and user guides.
50
+
51
+ Ensure the content is in English, formatted with Times New Roman, Font size 12, black color.
52
+ """
53
+
54
+ response = client.chat_completion(
55
+ messages=[
56
+ {"role": "system", "content": "You are a helpful assistant."},
57
+ {"role": "user", "content": prompt}
58
+ ],
59
+ max_tokens=1500,
60
+ temperature=0.7
61
+ )
62
+
63
+ content = response.choices[0].message.content
64
+
65
+ # Remove Formatting Guidelines section if present
66
+ if "Formatting Guidelines" in content:
67
+ content = content.split("Formatting Guidelines")[0].strip()
68
+
69
+ # Remove asterisks from the content
70
+ content = content.replace("*", "")
71
+
72
+ return content
73
+
74
+ def create_word_document(content):
75
+ doc = Document()
76
+ section_number = 1
77
+ for line in content.split('\n'):
78
+ if line.strip():
79
+ # Check if the line starts with a section number
80
+ if line.strip().startswith(str(section_number) + "."):
81
+ paragraph = doc.add_paragraph(line.strip(), style="Heading 1")
82
+ section_number += 1
83
+ else:
84
+ paragraph = doc.add_paragraph(line.strip())
85
+ for run in paragraph.runs:
86
+ run.font.name = 'Times New Roman'
87
+ run.font.size = Pt(12)
88
+
89
+ byte_io = BytesIO()
90
+ doc.save(byte_io)
91
+ byte_io.seek(0)
92
+ return byte_io
93
+
94
+ def create_pdf_document(content):
95
+ byte_io = BytesIO()
96
+ doc = SimpleDocTemplate(byte_io, pagesize=letter)
97
+ styles = getSampleStyleSheet()
98
+ normal_style = styles["Normal"]
99
+ normal_style.fontName = "Times-Roman"
100
+ normal_style.fontSize = 12
101
+
102
+ story = []
103
+ section_number = 1
104
+ for line in content.split('\n'):
105
+ if line.strip():
106
+ if line.strip().startswith(str(section_number) + "."):
107
+ style_name = "Heading1"
108
+ style = ParagraphStyle(name=style_name, parent=normal_style, fontSize=12, spaceAfter=12)
109
+ story.append(Paragraph(line.strip(), style))
110
+ section_number += 1
111
+ else:
112
+ story.append(Paragraph(line.strip(), normal_style))
113
+ story.append(Spacer(1, 12)) # Add space between paragraphs
114
+
115
+ doc.build(story)
116
+ byte_io.seek(0)
117
+ return byte_io
118
+
119
+ def generate_rfp(input_text):
120
+ content = generate_rfp_response_content(input_text)
121
+
122
+ word_io = create_word_document(content)
123
+ pdf_io = create_pdf_document(content)
124
+
125
+ word_base64 = b64encode(word_io.read()).decode('utf-8')
126
+ pdf_base64 = b64encode(pdf_io.read()).decode('utf-8')
127
+
128
+ word_link = f'<a href="data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64,{word_base64}" download="RFP_Response.docx">Download Word Document</a>'
129
+ pdf_link = f'<a href="data:application/pdf;base64,{pdf_base64}" download="RFP_Response.pdf">Download PDF Document</a>'
130
+
131
+ return word_link, pdf_link
132
+
133
+ demo = gr.Interface(
134
+ fn=generate_rfp,
135
+ inputs=gr.Textbox(lines=7, placeholder="Enter specific input for the RFP response here..."),
136
+ outputs=[
137
+ gr.HTML(label="Download Word Document"),
138
+ gr.HTML(label="Download PDF Document")
139
+ ],
140
+ title="AI-Driven RFP Response Generation (By Chandra Shekhar)",
141
+ description="Generate RFP response content using GPT4 model."
142
+ )
143
+
144
+ if __name__ == "__main__":
145
+ demo.launch()
gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ huggingface_hub==0.22.2
2
+ gradio
3
+ python-docx
4
+ reportlab
5
+