manabb commited on
Commit
551a01f
·
verified ·
1 Parent(s): 658849d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -18
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
- data = {'Status': '', 'Severity': '', 'Fix': '', 'Deviations': '', 'Analysis': ''}
103
- lines = llm_response.strip().splitlines()
 
 
 
 
104
  for line in lines:
105
  line = line.strip()
106
  if not line:
107
  continue
108
- if ':' in line:
109
- key, value = line.split(':', 1)
110
- key = key.strip()
111
- value = value.strip()
112
- if key in data:
113
- data[key] = value
 
 
 
114
  elif 'COMPLIANCE ANALYSIS:' in line:
 
115
  data['Analysis'] = line.split('COMPLIANCE ANALYSIS:', 1)[1].strip()
116
- else:
117
- data['Analysis'] += ' ' + line # Append to analysis if multi-line
 
 
 
 
118
 
119
  #print(data) # {'Status': 'COMPLIANT', 'Severity': 'LOW', ...}
120
- html = """
121
- <tr><th>Status</th><td class="status-compliant">{Status}</td></tr>
122
- <tr><th>Severity</th><td class="status-low">{Severity}</td></tr>
123
- <tr><th>Deviations</th><td>{Deviations}</td></tr>
124
- <tr><th>Fix</th><td>{Fix}</td></tr>
125
- <tr><th>Analysis</th><td class="analysis">{Analysis}</td></tr>
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