Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -99,32 +99,43 @@ def generate_html(llm_response):
|
|
| 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 |
-
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
for line in lines:
|
| 105 |
line = line.strip()
|
| 106 |
if not line:
|
| 107 |
continue
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
|
|
|
|
|
|
|
|
|
| 114 |
elif 'COMPLIANCE ANALYSIS:' in line:
|
|
|
|
| 115 |
data['Analysis'] = line.split('COMPLIANCE ANALYSIS:', 1)[1].strip()
|
| 116 |
-
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
#print(data) # {'Status': 'COMPLIANT', 'Severity': 'LOW', ...}
|
| 120 |
-
html = """
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
""".format(**data)
|
| 128 |
return html
|
| 129 |
|
| 130 |
|
|
|
|
| 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 |
if not line:
|
| 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 |
|