Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -90,52 +90,12 @@ def generate_response(manual, proposal):
|
|
| 90 |
)
|
| 91 |
return response.choices[0].message.content
|
| 92 |
|
| 93 |
-
def generate_html(llm_response):
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
#Severity: LOW
|
| 97 |
-
#Deviations: None
|
| 98 |
-
#Fix: None
|
| 99 |
-
#COMPLIANCE ANALYSIS: The proposal complies with the MANUAL requirements as it is based on a firm offer from an OEM, which is acceptable for the specified Tender Type. Since the proposal is for OEM procurement, it adheres to the guidelines that allow for a single vendor's firm offer to serve as the basis for the estimate. There are no deviations noted, and thus no corrective actions are necessary."""
|
| 100 |
-
|
| 101 |
-
# Parse key-values and analysis
|
| 102 |
-
# Improved parsing
|
| 103 |
-
data = {'Status': 'N/A', 'Severity': 'N/A', 'Deviations': 'N/A', 'Fix': 'N/A', 'Analysis': ''}
|
| 104 |
-
lines = llm_response.strip().split('\n')
|
| 105 |
-
in_analysis = False
|
| 106 |
-
analysis_parts = []
|
| 107 |
-
|
| 108 |
for line in lines:
|
| 109 |
-
line = line.strip()
|
| 110 |
-
|
| 111 |
-
continue
|
| 112 |
-
|
| 113 |
-
if line.startswith('Status:'):
|
| 114 |
-
data['Status'] = line.split(':', 1)[1].strip()
|
| 115 |
-
elif line.startswith('Severity:'):
|
| 116 |
-
data['Severity'] = line.split(':', 1)[1].strip()
|
| 117 |
-
elif line.startswith('Deviations:'):
|
| 118 |
-
data['Deviations'] = line.split(':', 1)[1].strip()
|
| 119 |
-
elif line.startswith('Fix:'):
|
| 120 |
-
data['Fix'] = line.split(':', 1)[1].strip()
|
| 121 |
-
elif 'COMPLIANCE ANALYSIS:' in line:
|
| 122 |
-
in_analysis = True
|
| 123 |
-
data['Analysis'] = line.split('COMPLIANCE ANALYSIS:', 1)[1].strip()
|
| 124 |
-
elif in_analysis:
|
| 125 |
-
analysis_parts.append(line)
|
| 126 |
-
|
| 127 |
-
# Append any trailing analysis
|
| 128 |
-
if analysis_parts:
|
| 129 |
-
data['Analysis'] += ' ' + ' '.join(analysis_parts).strip()
|
| 130 |
-
|
| 131 |
-
#print(data) # {'Status': 'COMPLIANT', 'Severity': 'LOW', ...}
|
| 132 |
-
html = f"""
|
| 133 |
-
<tr><th>Status</th><td class="compliant">{data.get('Status', 'N/A')}</td></tr>
|
| 134 |
-
<tr><th>Severity</th><td class="low">{data.get('Severity', 'N/A')}</td></tr>
|
| 135 |
-
<tr><th>Deviations</th><td>{data.get('Deviations', 'N/A')}</td></tr>
|
| 136 |
-
<tr><th>Fix</th><td>{data.get('Fix', 'N/A')}</td></tr>
|
| 137 |
-
<tr><th>Analysis</th><td class="analysis">{data.get('Analysis', 'N/A')}</td></tr>
|
| 138 |
-
"""
|
| 139 |
return html
|
| 140 |
|
| 141 |
|
|
@@ -199,8 +159,8 @@ def loop_function(df):
|
|
| 199 |
|
| 200 |
"""
|
| 201 |
text +="<h2>"+rr+"</h2>"
|
| 202 |
-
text +="<h2>Same is given below in
|
| 203 |
-
text += "<table><tr><td>As per proposal, "+key + "
|
| 204 |
|
| 205 |
rr_html=generate_html(rr)
|
| 206 |
text += rr_html
|
|
|
|
| 90 |
)
|
| 91 |
return response.choices[0].message.content
|
| 92 |
|
| 93 |
+
def generate_html(llm_response):
|
| 94 |
+
lines = llm_response.strip().split('\n')
|
| 95 |
+
html=""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
for line in lines:
|
| 97 |
+
line = line.strip()
|
| 98 |
+
html+="<tr><td>"+line+"</td></tr>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
return html
|
| 100 |
|
| 101 |
|
|
|
|
| 159 |
|
| 160 |
"""
|
| 161 |
text +="<h2>"+rr+"</h2>"
|
| 162 |
+
text +="<h2>Same is given below in line wise format....</h2>"
|
| 163 |
+
text += "<table><tr><td>As per proposal, "+key + " : "+value+"</td></tr>"
|
| 164 |
|
| 165 |
rr_html=generate_html(rr)
|
| 166 |
text += rr_html
|