muzakkirhussain011 commited on
Commit
ac5e746
Β·
1 Parent(s): 849b6c1

Add application files

Browse files
Files changed (1) hide show
  1. app.py +82 -7
app.py CHANGED
@@ -243,22 +243,97 @@ async def run_pipeline_gradio(company_names_input: str) -> AsyncGenerator[tuple,
243
  # Yield updates
244
  yield chat_history, status, format_workflow_logs(workflow_logs)
245
 
246
- # Pipeline complete
247
- final_msg = f"""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
  βœ… **Pipeline Execution Complete!**
249
 
250
  **Summary:**
251
- - Companies Processed: {len(pipeline_state['company_outputs'])}
252
  - Total Events: {len(workflow_logs)}
253
  - MCP Interactions: {sum(1 for log in workflow_logs if 'MCP' in log['action'])}
254
  - Agents Run: {len(set(log['agent'] for log in workflow_logs))}
 
255
 
256
  All prospects have been enriched, scored, and prepared for outreach through the autonomous agent system.
257
  """
258
- chat_history.append({
259
- "role": "assistant",
260
- "content": final_msg
261
- })
 
 
 
 
 
 
 
 
262
  yield chat_history, "βœ… Pipeline Complete", format_workflow_logs(workflow_logs)
263
 
264
  except Exception as e:
 
243
  # Yield updates
244
  yield chat_history, status, format_workflow_logs(workflow_logs)
245
 
246
+ # Pipeline complete - Retrieve and display all results
247
+ try:
248
+ # Get all prospects from the store
249
+ store_client = mcp_registry.get_store_client()
250
+ all_prospects = await store_client.get_all_prospects()
251
+
252
+ # Display each company's results
253
+ for prospect in all_prospects:
254
+ company_name = prospect.get('company', {}).get('name', 'Unknown')
255
+
256
+ # Build result card
257
+ result_content = f"## 🏒 {company_name}\n\n"
258
+
259
+ # Company info
260
+ company = prospect.get('company', {})
261
+ result_content += f"**Industry:** {company.get('industry', 'N/A')}\n"
262
+ result_content += f"**Size:** {company.get('employee_count', 'N/A')} employees\n"
263
+ result_content += f"**Domain:** {company.get('domain', 'N/A')}\n\n"
264
+
265
+ # Contacts found
266
+ contacts = prospect.get('contacts', [])
267
+ if contacts:
268
+ result_content += f"**πŸ‘₯ Contacts Found:** {len(contacts)}\n"
269
+ for contact in contacts[:3]: # Show first 3
270
+ result_content += f"- {contact.get('name', 'N/A')} - {contact.get('title', 'N/A')}\n"
271
+ if len(contacts) > 3:
272
+ result_content += f"- ... and {len(contacts) - 3} more\n"
273
+ result_content += "\n"
274
+
275
+ # Scoring
276
+ scores = prospect.get('scores', {})
277
+ if scores:
278
+ result_content += f"**πŸ“Š Fit Score:** {scores.get('overall_score', 0):.2f}\n"
279
+ result_content += f"- Industry Fit: {scores.get('fit_score', 0):.2f}\n"
280
+ result_content += f"- Engagement: {scores.get('engagement_score', 0):.2f}\n"
281
+ result_content += f"- Intent: {scores.get('intent_score', 0):.2f}\n\n"
282
+
283
+ # Content generated
284
+ content = prospect.get('content', {})
285
+ if content:
286
+ summary = content.get('summary', '')
287
+ if summary:
288
+ result_content += f"**πŸ“ Summary:**\n{summary}\n\n"
289
+
290
+ email = content.get('email', {})
291
+ if email:
292
+ result_content += f"**βœ‰οΈ Email Draft:**\n"
293
+ result_content += f"*Subject:* {email.get('subject', 'N/A')}\n\n"
294
+ result_content += f"{email.get('body', 'N/A')}\n\n"
295
+
296
+ # Email thread
297
+ thread_id = prospect.get('thread_id')
298
+ if thread_id:
299
+ result_content += f"**πŸ“§ Email Thread:** {thread_id}\n\n"
300
+
301
+ # Handoff packet
302
+ handoff = prospect.get('handoff_packet', {})
303
+ if handoff:
304
+ result_content += f"**πŸ“‹ Handoff Status:** Ready for sales team\n"
305
+
306
+ # Add to chat
307
+ chat_history.append({
308
+ "role": "assistant",
309
+ "content": result_content
310
+ })
311
+
312
+ # Final summary
313
+ final_msg = f"""
314
  βœ… **Pipeline Execution Complete!**
315
 
316
  **Summary:**
317
+ - Companies Processed: {len(all_prospects)}
318
  - Total Events: {len(workflow_logs)}
319
  - MCP Interactions: {sum(1 for log in workflow_logs if 'MCP' in log['action'])}
320
  - Agents Run: {len(set(log['agent'] for log in workflow_logs))}
321
+ - Contacts Discovered: {sum(len(p.get('contacts', [])) for p in all_prospects)}
322
 
323
  All prospects have been enriched, scored, and prepared for outreach through the autonomous agent system.
324
  """
325
+ chat_history.append({
326
+ "role": "assistant",
327
+ "content": final_msg
328
+ })
329
+
330
+ except Exception as e:
331
+ error_msg = f"⚠️ Error retrieving results: {str(e)}\n\nPipeline completed but could not display all results."
332
+ chat_history.append({
333
+ "role": "assistant",
334
+ "content": error_msg
335
+ })
336
+
337
  yield chat_history, "βœ… Pipeline Complete", format_workflow_logs(workflow_logs)
338
 
339
  except Exception as e: