Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -155,11 +155,47 @@ def generate_outputs(role, supervisor_name, project_id, milestones, reflection):
|
|
155 |
e = text.find(end, s) if end else len(text)
|
156 |
return text[s + len(start):e].strip() if s != -1 else ""
|
157 |
|
|
|
158 |
checklist = extract_between(result, "Checklist:\n", "Suggestions:")
|
159 |
suggestions = extract_between(result, "Suggestions:\n", None)
|
160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
return checklist, suggestions
|
162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
# Interface
|
164 |
def create_interface():
|
165 |
roles = get_roles_from_salesforce()
|
|
|
155 |
e = text.find(end, s) if end else len(text)
|
156 |
return text[s + len(start):e].strip() if s != -1 else ""
|
157 |
|
158 |
+
# Extract the checklist and suggestions
|
159 |
checklist = extract_between(result, "Checklist:\n", "Suggestions:")
|
160 |
suggestions = extract_between(result, "Suggestions:\n", None)
|
161 |
|
162 |
+
# If checklist or suggestions are empty, generate fallback content
|
163 |
+
if not checklist.strip():
|
164 |
+
checklist = generate_fallback_checklist(role, milestones)
|
165 |
+
if not suggestions.strip():
|
166 |
+
suggestions = generate_fallback_suggestions(reflection)
|
167 |
+
|
168 |
return checklist, suggestions
|
169 |
|
170 |
+
# Fallback generation for checklist and suggestions
|
171 |
+
def generate_fallback_checklist(role, milestones):
|
172 |
+
checklist_items = []
|
173 |
+
|
174 |
+
# If milestones are provided, add them to the checklist directly
|
175 |
+
if milestones and milestones.strip():
|
176 |
+
kpis = [kpi.strip() for kpi in milestones.split(",")]
|
177 |
+
for kpi in kpis:
|
178 |
+
checklist_items.append(f"- Ensure progress on {kpi}")
|
179 |
+
else:
|
180 |
+
checklist_items.append("- Perform daily safety inspection")
|
181 |
+
|
182 |
+
return "\n".join(checklist_items)
|
183 |
+
|
184 |
+
def generate_fallback_suggestions(reflection):
|
185 |
+
suggestions_items = []
|
186 |
+
reflection_lower = reflection.lower()
|
187 |
+
if "student" in reflection_lower or "learning" in reflection_lower:
|
188 |
+
suggestions_items.append("- Ensure students are logging incidents consistently")
|
189 |
+
suggestions_items.append("- Provide guidance on timely incident recording")
|
190 |
+
if "incident" in reflection_lower:
|
191 |
+
suggestions_items.append("- Follow up on reported incidents with corrective actions")
|
192 |
+
|
193 |
+
if not suggestions_items:
|
194 |
+
suggestions_items.append("- Monitor team coordination")
|
195 |
+
suggestions_items.append("- Review safety protocols with the team")
|
196 |
+
|
197 |
+
return "\n".join(suggestions_items)
|
198 |
+
|
199 |
# Interface
|
200 |
def create_interface():
|
201 |
roles = get_roles_from_salesforce()
|