muzakkirhussain011 commited on
Commit
3bf0768
Β·
1 Parent(s): ffd4367

Add application files

Browse files
Files changed (2) hide show
  1. BUGFIX_SUMMARY.md +136 -0
  2. app.py +14 -14
BUGFIX_SUMMARY.md ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Bug Fix Summary - WebSearchService Integration
2
+
3
+ ## πŸ› Issue
4
+
5
+ ```
6
+ ❌ Error: WebSearchService.search() got an unexpected keyword argument 'num_results'
7
+ ```
8
+
9
+ ## πŸ” Root Cause
10
+
11
+ The `B2BSalesAgent` class was using incorrect parameter names and missing `await` keywords when calling the asynchronous `WebSearchService.search()` method.
12
+
13
+ ### Problems Identified:
14
+
15
+ 1. **Wrong parameter name**: Used `num_results` instead of `max_results`
16
+ 2. **Missing await**: Didn't use `await` for async method calls
17
+ 3. **Wrong field names**: Used `'snippet'` and `'link'` instead of `'body'` and `'url'`
18
+
19
+ ## βœ… Fixes Applied
20
+
21
+ ### 1. Parameter Name Corrections (4 instances)
22
+
23
+ **Before:**
24
+ ```python
25
+ results = self.web_search.search(query, num_results=5)
26
+ ```
27
+
28
+ **After:**
29
+ ```python
30
+ results = await self.web_search.search(query, max_results=5)
31
+ ```
32
+
33
+ **Files affected:**
34
+ - `app.py` lines 431, 447, 457, 475, 495
35
+
36
+ ### 2. Field Name Corrections
37
+
38
+ **Before:**
39
+ ```python
40
+ client_profile['website'] = result['link'] # ❌ Wrong
41
+ snippet = result.get('snippet', '') # ❌ Wrong
42
+ ```
43
+
44
+ **After:**
45
+ ```python
46
+ client_profile['website'] = result['url'] # βœ… Correct
47
+ body = result.get('body', '') # βœ… Correct
48
+ ```
49
+
50
+ ## πŸ“‹ WebSearchService Return Format
51
+
52
+ The `WebSearchService.search()` method returns results with these keys:
53
+
54
+ ```python
55
+ {
56
+ 'title': 'Result title',
57
+ 'body': 'Result snippet/description', # NOT 'snippet'
58
+ 'url': 'https://example.com', # NOT 'link'
59
+ 'source': 'example.com'
60
+ }
61
+ ```
62
+
63
+ ## πŸ”§ Complete Change List
64
+
65
+ ### `app.py` - B2BSalesAgent class
66
+
67
+ 1. **Line 431** - `research_client()`:
68
+ - βœ… Changed `num_results=5` β†’ `max_results=5`
69
+ - βœ… Added `await`
70
+
71
+ 2. **Line 443** - `research_client()`:
72
+ - βœ… Changed `result.get('link')` β†’ `result.get('url')`
73
+
74
+ 3. **Line 447** - `research_client()`:
75
+ - βœ… Changed `num_results=3` β†’ `max_results=3`
76
+ - βœ… Added `await`
77
+
78
+ 4. **Line 457** - `find_prospects()`:
79
+ - βœ… Changed `num_results=num_prospects * 2` β†’ `max_results=num_prospects * 2`
80
+ - βœ… Added `await`
81
+
82
+ 5. **Lines 463-464** - `find_prospects()`:
83
+ - βœ… Changed `result.get('link')` β†’ `result.get('url')`
84
+ - βœ… Changed `result.get('snippet')` β†’ `result.get('body')`
85
+
86
+ 6. **Line 475** - `research_prospect()`:
87
+ - βœ… Changed `num_results=5` β†’ `max_results=5`
88
+ - βœ… Added `await`
89
+
90
+ 7. **Line 487** - `research_prospect()`:
91
+ - βœ… Changed `result.get('snippet')` β†’ `result.get('body')`
92
+
93
+ 8. **Line 495** - `find_contacts()`:
94
+ - βœ… Changed `num_results=5` β†’ `max_results=5`
95
+ - βœ… Added `await`
96
+
97
+ 9. **Lines 501, 510** - `find_contacts()`:
98
+ - βœ… Changed `result.get('snippet')` β†’ `result.get('body')`
99
+ - βœ… Changed `result.get('link')` β†’ `result.get('url')`
100
+
101
+ ## βœ… Verification
102
+
103
+ All fixes have been applied and syntax verified:
104
+
105
+ ```bash
106
+ βœ… python -m py_compile app.py # No errors
107
+ ```
108
+
109
+ ## πŸš€ Status
110
+
111
+ **RESOLVED** - The B2B Sales Agent now correctly integrates with WebSearchService.
112
+
113
+ The application should now work without errors when:
114
+ 1. Running the B2B Sales pipeline
115
+ 2. Researching client companies
116
+ 3. Finding prospects
117
+ 4. Finding contacts
118
+ 5. Generating emails
119
+
120
+ ## πŸ§ͺ Testing Checklist
121
+
122
+ After deploying these fixes, verify:
123
+
124
+ - [ ] B2B Sales pipeline runs without errors
125
+ - [ ] Client company research completes
126
+ - [ ] Prospects are discovered
127
+ - [ ] Contacts are found at prospect companies
128
+ - [ ] Emails are generated successfully
129
+ - [ ] AI Reply Handler simulation works
130
+ - [ ] No "unexpected keyword argument" errors
131
+
132
+ ---
133
+
134
+ **Fixed by:** Claude Code AI Assistant
135
+ **Date:** 2025-11-16
136
+ **Files Modified:** `app.py` (9 changes)
app.py CHANGED
@@ -428,7 +428,7 @@ class B2BSalesAgent:
428
  async def research_client(self, client_name: str):
429
  """Step 1: Research the CLIENT company"""
430
  query = f"{client_name} company what they offer products services target customers"
431
- results = self.web_search.search(query, num_results=5)
432
 
433
  client_profile = {
434
  "name": client_name,
@@ -440,11 +440,11 @@ class B2BSalesAgent:
440
  }
441
 
442
  for result in results:
443
- if not client_profile['website'] and result.get('link'):
444
- client_profile['website'] = result['link']
445
 
446
  offering_query = f"{client_name} products services features benefits"
447
- offering_results = self.web_search.search(offering_query, num_results=3)
448
 
449
  client_profile['summary'] = f"Research on {client_name} compiled from web search"
450
  return client_profile
@@ -454,14 +454,14 @@ class B2BSalesAgent:
454
  client_name = client_profile['name']
455
  prospect_query = f"companies that could use {client_name} potential customers businesses"
456
 
457
- results = self.web_search.search(prospect_query, num_results=num_prospects * 2)
458
 
459
  prospects = []
460
  for result in results[:num_prospects]:
461
  prospect = {
462
  "name": result.get('title', 'Unknown Company'),
463
- "domain": result.get('link', ''),
464
- "snippet": result.get('snippet', ''),
465
  "industry": "",
466
  "size": "Unknown"
467
  }
@@ -472,7 +472,7 @@ class B2BSalesAgent:
472
  async def research_prospect(self, prospect_name: str):
473
  """Step 3: Research a PROSPECT company"""
474
  query = f"{prospect_name} company business model challenges pain points"
475
- results = self.web_search.search(query, num_results=5)
476
 
477
  prospect_profile = {
478
  "name": prospect_name,
@@ -484,30 +484,30 @@ class B2BSalesAgent:
484
  }
485
 
486
  for result in results:
487
- snippet = result.get('snippet', '')
488
- prospect_profile['pain_points'].append(snippet)
489
 
490
  return prospect_profile
491
 
492
  async def find_contacts(self, prospect_name: str, prospect_domain: str):
493
  """Step 4: Find decision-maker contacts at PROSPECT company"""
494
  query = f"{prospect_name} CEO VP director contact linkedin"
495
- results = self.web_search.search(query, num_results=5)
496
 
497
  contacts = []
498
  titles_to_find = ["CEO", "VP", "Director", "Head of", "Chief"]
499
 
500
  for result in results:
501
- snippet = result.get('snippet', '')
502
  title_result = result.get('title', '')
503
 
504
  for title_keyword in titles_to_find:
505
- if title_keyword in snippet or title_keyword in title_result:
506
  contact = {
507
  "name": "Contact Name (from search)",
508
  "title": title_keyword,
509
  "company": prospect_name,
510
- "linkedin": result.get('link', ''),
511
  "email": f"contact@{prospect_domain}" if prospect_domain else "unknown"
512
  }
513
  contacts.append(contact)
 
428
  async def research_client(self, client_name: str):
429
  """Step 1: Research the CLIENT company"""
430
  query = f"{client_name} company what they offer products services target customers"
431
+ results = await self.web_search.search(query, max_results=5)
432
 
433
  client_profile = {
434
  "name": client_name,
 
440
  }
441
 
442
  for result in results:
443
+ if not client_profile['website'] and result.get('url'):
444
+ client_profile['website'] = result['url']
445
 
446
  offering_query = f"{client_name} products services features benefits"
447
+ offering_results = await self.web_search.search(offering_query, max_results=3)
448
 
449
  client_profile['summary'] = f"Research on {client_name} compiled from web search"
450
  return client_profile
 
454
  client_name = client_profile['name']
455
  prospect_query = f"companies that could use {client_name} potential customers businesses"
456
 
457
+ results = await self.web_search.search(prospect_query, max_results=num_prospects * 2)
458
 
459
  prospects = []
460
  for result in results[:num_prospects]:
461
  prospect = {
462
  "name": result.get('title', 'Unknown Company'),
463
+ "domain": result.get('url', ''),
464
+ "snippet": result.get('body', ''),
465
  "industry": "",
466
  "size": "Unknown"
467
  }
 
472
  async def research_prospect(self, prospect_name: str):
473
  """Step 3: Research a PROSPECT company"""
474
  query = f"{prospect_name} company business model challenges pain points"
475
+ results = await self.web_search.search(query, max_results=5)
476
 
477
  prospect_profile = {
478
  "name": prospect_name,
 
484
  }
485
 
486
  for result in results:
487
+ body = result.get('body', '')
488
+ prospect_profile['pain_points'].append(body)
489
 
490
  return prospect_profile
491
 
492
  async def find_contacts(self, prospect_name: str, prospect_domain: str):
493
  """Step 4: Find decision-maker contacts at PROSPECT company"""
494
  query = f"{prospect_name} CEO VP director contact linkedin"
495
+ results = await self.web_search.search(query, max_results=5)
496
 
497
  contacts = []
498
  titles_to_find = ["CEO", "VP", "Director", "Head of", "Chief"]
499
 
500
  for result in results:
501
+ body = result.get('body', '')
502
  title_result = result.get('title', '')
503
 
504
  for title_keyword in titles_to_find:
505
+ if title_keyword in body or title_keyword in title_result:
506
  contact = {
507
  "name": "Contact Name (from search)",
508
  "title": title_keyword,
509
  "company": prospect_name,
510
+ "linkedin": result.get('url', ''),
511
  "email": f"contact@{prospect_domain}" if prospect_domain else "unknown"
512
  }
513
  contacts.append(contact)