Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -129,7 +129,7 @@ def generate_red_document(document: str, compliance_report: str) -> str:
|
|
| 129 |
response = model.generate_content(prompt)
|
| 130 |
return response.text
|
| 131 |
|
| 132 |
-
|
| 133 |
prompt = f"""
|
| 134 |
Analyze the following document and provide a Level of Effort (LOE) breakdown:
|
| 135 |
|
|
@@ -148,6 +148,7 @@ def generate_loe(document: str) -> Tuple[str, pd.DataFrame]:
|
|
| 148 |
- Total Hours
|
| 149 |
|
| 150 |
Present the detailed breakdown first, followed by the summary table.
|
|
|
|
| 151 |
"""
|
| 152 |
response = model.generate_content(prompt)
|
| 153 |
|
|
@@ -157,8 +158,13 @@ def generate_loe(document: str) -> Tuple[str, pd.DataFrame]:
|
|
| 157 |
table_text = response.text[table_start:table_end]
|
| 158 |
|
| 159 |
# Convert the table to a pandas DataFrame
|
| 160 |
-
|
| 161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
|
| 163 |
return response.text, df
|
| 164 |
|
|
|
|
| 129 |
response = model.generate_content(prompt)
|
| 130 |
return response.text
|
| 131 |
|
| 132 |
+
ddef generate_loe(document: str) -> Tuple[str, pd.DataFrame]:
|
| 133 |
prompt = f"""
|
| 134 |
Analyze the following document and provide a Level of Effort (LOE) breakdown:
|
| 135 |
|
|
|
|
| 148 |
- Total Hours
|
| 149 |
|
| 150 |
Present the detailed breakdown first, followed by the summary table.
|
| 151 |
+
Ensure the table is properly formatted with | as column separators and a header row.
|
| 152 |
"""
|
| 153 |
response = model.generate_content(prompt)
|
| 154 |
|
|
|
|
| 158 |
table_text = response.text[table_start:table_end]
|
| 159 |
|
| 160 |
# Convert the table to a pandas DataFrame
|
| 161 |
+
try:
|
| 162 |
+
df = pd.read_csv(StringIO(table_text), sep='|', skipinitialspace=True).dropna(axis=1, how='all')
|
| 163 |
+
df.columns = df.columns.str.strip()
|
| 164 |
+
except pd.errors.EmptyDataError:
|
| 165 |
+
# If no table is found or it's empty, create a default DataFrame
|
| 166 |
+
df = pd.DataFrame(columns=['Task Summary', 'Labor Categories', 'Hours per Labor Category', 'Total Hours'])
|
| 167 |
+
response.text += "\n\nNote: No detailed LOE table could be generated from the AI response."
|
| 168 |
|
| 169 |
return response.text, df
|
| 170 |
|