stackConsult commited on
Commit
bfe387a
·
verified ·
1 Parent(s): c6bfd08

Update README.md

Browse files

DOC: Add lead_scoring_agent integration documentation to README

- Add new Pipeline Workflow step 3: Lead Scoring (lead_scoring_agent.py)
- Document scoring integration in Human/Machine Validation step
- Add /score API endpoint documentation
- Document scoring features in UI Dashboard
- Add comprehensive "Lead Scoring Integration (NEW)" section with:
* Overview of scoring features and metadata
* Key features and integration points
* Example usage showing single review and batch review scoring
- Update schema versioning section with LeadReview v2 fields
- Add troubleshooting guidance for scoring failures and module import
- Reference lead_scoring_agent.py in Core Modules section
- Document scoring configuration reference in docs/configs/
- Update Test Case Logic with lead scoring integration tests
- Document scoring metadata passing through agent handoff chain

Files changed (1) hide show
  1. README.md +86 -36
README.md CHANGED
@@ -7,15 +7,11 @@ sdk: gradio
7
  pinned: false
8
  short_description: A simple Gradio app
9
  ---
10
-
11
  # StrategyStack Recovery, Enrichment & Outreach Platform
12
-
13
  **Modular pipeline for automated asset enrichment, engagement, analytics, and agent/handoff orchestration—including API, UI, test logic, upgrade/migration, and troubleshooting.**
14
 
15
  ---
16
-
17
  ## Pipeline Workflow
18
-
19
  1. **Input/Asset Ingestion** (`activity_ingestion.py`):
20
  - Receives assets or lead lists (CSV, API, UI submission).
21
  - Validates schema (see `schema_registry.py`).
@@ -24,93 +20,147 @@ short_description: A simple Gradio app
24
  - Fills gaps: persona, recent posts, complaints, engagement metrics.
25
  - Invokes external APIs as needed or generates synthetic context.
26
  - Handoff to validation agent if enrichment uncertain.
27
- 3. **Human/Machine Validation** (`human_validation_agent.py`):
 
 
 
 
28
  - Receives enriched assets where automated logic lacks confidence.
 
 
29
  - Interactive review and correction (UI or API endpoint).
30
- - Returns enriched/validated assets to pipeline.
31
- 4. **Outreach/Engagement** (`outreach_agent.py`):
32
- - Selects template, personalizes using context fields.
33
  - Delivers via pluggable channels: email, LinkedIn, SMS, browser automation.
34
  - Supports automated social actions and feedback.
35
- 5. **Analytics & Reporting** (`analytics_agent.py`):
36
- - Logs all asset/channel outcomes, engagement stats.
37
  - Computes dashboards, actionable feedback, and improvement triggers.
38
- 6. **Research/Search Integration** (`research_agent.py`, `query_search_agent.py`):
39
  - Supplements enrichment with web or corpus search, updates context/data.
40
  - Used by outreach for deep personalization or compliance needs.
41
 
42
  ---
43
-
44
  ## API Endpoints
45
-
46
  - `/ingest` (**POST**): Upload asset batch (CSV/JSON), triggers validation & enrichment.
47
- - `/validate` (**POST**): Human/machine validation of asset content.
 
48
  - `/enrich` (**POST**): Force re-enrichment or supplemental context fill.
49
  - `/outreach` (**POST**): Initiates personalized outreach actions; returns status/transcript.
50
  - `/analytics` (**GET**): Fetch per-asset, per-campaign, or global reports/statistics.
51
  - **Authentication/Authorization**: All endpoints respect granular role controls, see config in `docs/configs/`.
52
 
53
  ---
54
-
55
  ## UI Dashboard Features
56
-
57
- - Asset ingestion/upload table with schema/state indicators.
58
- - Visualization of validation/enrichment status, gaps, and overrides (human/manual call-outs).
59
- - Outreach composer: preview, edit, and dispatch personalized messages across channels.
60
- - Live stats: engagement rates, delivery status, trigger diagnostics, per-asset and per-campaign.
61
- - Agent handoff log: view/trace enrichment, validation, and outreach chain per asset.
62
 
63
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
 
 
65
  ## Test Case Logic
66
-
67
  - Test scripts: `test_schema_tools.py`, `test_validation.py` (unit tests for all schema/enrichment/validation logic).
 
68
  - CI-friendly: All test scripts runnable standalone or via `pytest`, support fixtures for human/machine edge cases.
69
- - Example cases cover incomplete asset, fuzzy enrichment, validation override, pipeline/integration chain.
70
 
71
  ---
72
-
73
  ## Agent & Asset Wiring
74
-
75
- - Each module is pluggable: you can sub in new enrichment, validation, or channel handler without altering others.
76
- - Agent handoff: all context (original, intermediate states) passes via in-memory or file-based serialization; reference logic in `enrichment_handoff_simulation.py` (`docs/`).
77
- - Asset state maintained through pipeline, logging all hops. Schemas upgradable (see `SCHEMA_VERSIONING.md`).
78
 
79
  ---
80
-
81
  ## Upgrade & Migration Guide
82
-
83
  - **Schema Versioning**: Asset, enrichment, and analytics schema tracked with incremental migrations (`SCHEMA_VERSIONING.md`).
 
 
84
  - **Future DB Integration**: Swap out CSV with SQL/NoSQL backend by implementing new state store hooks in `app.py` and updating config in `docs/configs/`.
85
  - Migration scripts: Provided for legacy log/asset conversion.
86
 
87
  ---
88
-
89
  ## Best Practices: Setup, Usage, Troubleshooting
90
-
91
  - **Setup**: `pip install -r requirements.txt`; run `app.py` to launch UI and API.
92
- - **Usage**: Ingest assets via UI or API, follow pipeline in dashboard, manually validate flagged inputs.
93
  - **Troubleshooting**:
94
  - Logs/errors to console and CSV.
95
  - Validation steps highlight schema mismatches.
96
  - Check agent handoff logs for stuck or dropped assets.
 
 
97
  - Update configs/schemas via `docs/configs/` for custom needs.
98
 
99
  ---
100
-
101
  ## Module, Config, Script, and Logic Reference
102
-
103
  - **Core Modules**:
104
  - `activity_ingestion.py`, `outreach_agent.py`, `recovery_enrichment_agent.py`, `analytics_agent.py`, `research_agent.py`, `human_validation_agent.py`, `query_search_agent.py`
 
105
  - **Config Files**:
106
  - All YAML/JSON in `docs/configs/`, plus channel/handler settings in each agent.
 
107
  - **Schema & Versioning**:
108
  - `schema_registry.py`, `SCHEMA_VERSIONING.md`
 
109
  - **Test Scripts**:
110
  - `test_schema_tools.py`, `test_validation.py`
 
111
  - **Agent Handoff Logic**:
112
  - `docs/enrichment_handoff_simulation.py`
 
113
 
114
  ---
115
-
116
  For further explanation, workflows, and custom case studies—see full documentation and module-level docstrings.
 
7
  pinned: false
8
  short_description: A simple Gradio app
9
  ---
 
10
  # StrategyStack Recovery, Enrichment & Outreach Platform
 
11
  **Modular pipeline for automated asset enrichment, engagement, analytics, and agent/handoff orchestration—including API, UI, test logic, upgrade/migration, and troubleshooting.**
12
 
13
  ---
 
14
  ## Pipeline Workflow
 
15
  1. **Input/Asset Ingestion** (`activity_ingestion.py`):
16
  - Receives assets or lead lists (CSV, API, UI submission).
17
  - Validates schema (see `schema_registry.py`).
 
20
  - Fills gaps: persona, recent posts, complaints, engagement metrics.
21
  - Invokes external APIs as needed or generates synthetic context.
22
  - Handoff to validation agent if enrichment uncertain.
23
+ 3. **Lead Scoring** (`lead_scoring_agent.py`) - NEW:
24
+ - Scores lead profiles based on firmographic, behavioral, and engagement signals.
25
+ - Enriches profiles with scoring metadata and rationale.
26
+ - Integrated into validation workflow at action start for each lead review.
27
+ 4. **Human/Machine Validation** (`human_validation_agent.py`):
28
  - Receives enriched assets where automated logic lacks confidence.
29
+ - **NEW:** Scores each lead profile at action start using `lead_scoring_agent`.
30
+ - **NEW:** Passes scoring results and enrichment data to downstream handlers.
31
  - Interactive review and correction (UI or API endpoint).
32
+ - Returns enriched/validated/scored assets to pipeline.
33
+ 5. **Outreach/Engagement** (`outreach_agent.py`):
34
+ - Selects template, personalizes using context fields and scoring signals.
35
  - Delivers via pluggable channels: email, LinkedIn, SMS, browser automation.
36
  - Supports automated social actions and feedback.
37
+ 6. **Analytics & Reporting** (`analytics_agent.py`):
38
+ - Logs all asset/channel outcomes, engagement stats, and scoring performance.
39
  - Computes dashboards, actionable feedback, and improvement triggers.
40
+ 7. **Research/Search Integration** (`research_agent.py`, `query_search_agent.py`):
41
  - Supplements enrichment with web or corpus search, updates context/data.
42
  - Used by outreach for deep personalization or compliance needs.
43
 
44
  ---
 
45
  ## API Endpoints
 
46
  - `/ingest` (**POST**): Upload asset batch (CSV/JSON), triggers validation & enrichment.
47
+ - `/validate` (**POST**): Human/machine validation of asset content with lead scoring.
48
+ - `/score` (**POST**) - NEW: Score lead profiles using lead_scoring_agent; returns scoring metadata.
49
  - `/enrich` (**POST**): Force re-enrichment or supplemental context fill.
50
  - `/outreach` (**POST**): Initiates personalized outreach actions; returns status/transcript.
51
  - `/analytics` (**GET**): Fetch per-asset, per-campaign, or global reports/statistics.
52
  - **Authentication/Authorization**: All endpoints respect granular role controls, see config in `docs/configs/`.
53
 
54
  ---
 
55
  ## UI Dashboard Features
56
+ - Asset ingestion/upload table with schema/state indicators and scoring status.
57
+ - Visualization of validation/enrichment status, gaps, overrides (human/manual call-outs), and lead scores.
58
+ - Outreach composer: preview, edit, and dispatch personalized messages across channels using scoring signals.
59
+ - Live stats: engagement rates, delivery status, trigger diagnostics, scoring performance metrics, per-asset and per-campaign.
60
+ - Agent handoff log: view/trace enrichment, validation, scoring, and outreach chain per asset.
 
61
 
62
  ---
63
+ ## Lead Scoring Integration (NEW)
64
+ ### Overview
65
+ The `lead_scoring_agent` module scores lead profiles based on multiple signals and enriches them with contextual metadata. The `human_validation_agent` integrates lead scoring at the point of action start—each lead review now includes:
66
+ - Score result (numeric or categorical)
67
+ - Scoring rationale and signal breakdown
68
+ - Enriched profile data
69
+ - Scoring metadata for downstream use
70
+
71
+ ### Key Features
72
+ - **Import & Initialization**: `human_validation_agent` imports `LeadScoringAgent` and initializes it on instantiation.
73
+ - **Action-Start Scoring**: `process_review_action()` scores the lead profile before action execution.
74
+ - **Schema Updates**: `LeadReview` schema extended with `scoring_result` and `enrichment_data` fields.
75
+ - **Batch Scoring**: `process_batch_review()` scores all leads in the batch, passing metadata downstream.
76
+ - **History Export**: Review history JSON export includes scoring metadata for each review.
77
+ - **Error Handling**: Scoring failures logged and tracked without blocking review actions.
78
+
79
+ ### Integration Points
80
+ - **LeadReview Schema**: New optional fields: `scoring_result` (Dict), `enrichment_data` (Dict).
81
+ - **HumanValidationAgent.score_lead_profile()**: Calls `lead_scoring_agent.score_lead()` and retrieves enrichment data.
82
+ - **HumanValidationAgent.process_review_action()**: Scores profile at action start; stores metadata with review.
83
+ - **HumanValidationAgent.process_batch_review()**: Iterates batch reviews, scoring each and collecting results.
84
+ - **API & UI**: `/validate` endpoint receives and returns scoring metadata; dashboard displays scores and rationale.
85
+
86
+ ### Example Usage
87
+ ```python
88
+ from human_validation_agent import HumanValidationAgent, BatchReviewRequest
89
+
90
+ agent = HumanValidationAgent()
91
+
92
+ # Single review with scoring
93
+ review_data = {
94
+ "lead_id": "lead_001",
95
+ "action": "approve",
96
+ "reviewer_id": "reviewer_123"
97
+ }
98
+ result = agent.process_review_action(LeadReview(**review_data))
99
+ print(result) # Includes scoring_metadata with score_result and enrichment_data
100
+
101
+ # Batch review with scoring for each lead
102
+ batch_request = BatchReviewRequest(
103
+ reviews=[
104
+ LeadReview(lead_id="lead_001", action="approve", reviewer_id="reviewer_123"),
105
+ LeadReview(lead_id="lead_002", action="edit", edited_data={...}, reviewer_id="reviewer_123"),
106
+ LeadReview(lead_id="lead_003", action="scrub", reason="competitor", reviewer_id="reviewer_123")
107
+ ]
108
+ )
109
+ results = agent.process_batch_review(batch_request)
110
+ print(results) # All results include scoring metadata
111
+ ```
112
 
113
+ ---
114
  ## Test Case Logic
 
115
  - Test scripts: `test_schema_tools.py`, `test_validation.py` (unit tests for all schema/enrichment/validation logic).
116
+ - **NEW**: Test lead scoring integration in `test_validation.py`; verify scoring metadata in reviews.
117
  - CI-friendly: All test scripts runnable standalone or via `pytest`, support fixtures for human/machine edge cases.
118
+ - Example cases cover incomplete asset, fuzzy enrichment, validation override, lead scoring, pipeline/integration chain.
119
 
120
  ---
 
121
  ## Agent & Asset Wiring
122
+ - Each module is pluggable: you can sub in new enrichment, validation, scoring, or channel handler without altering others.
123
+ - **NEW**: Lead scoring agent decoupled from validation—can be swapped or augmented independently.
124
+ - Agent handoff: all context (original, intermediate states, **scoring metadata**) passes via in-memory or file-based serialization; reference logic in `enrichment_handoff_simulation.py` (`docs/`).
125
+ - Asset state maintained through pipeline, logging all hops including scoring. Schemas upgradable (see `SCHEMA_VERSIONING.md`).
126
 
127
  ---
 
128
  ## Upgrade & Migration Guide
 
129
  - **Schema Versioning**: Asset, enrichment, and analytics schema tracked with incremental migrations (`SCHEMA_VERSIONING.md`).
130
+ - **NEW**: `LeadReview` schema v2 includes `scoring_result` and `enrichment_data` fields (backward compatible).
131
+ - **Lead Scoring Integration**: Ensure `lead_scoring_agent.py` is available in the same namespace; import validated on `HumanValidationAgent` instantiation.
132
  - **Future DB Integration**: Swap out CSV with SQL/NoSQL backend by implementing new state store hooks in `app.py` and updating config in `docs/configs/`.
133
  - Migration scripts: Provided for legacy log/asset conversion.
134
 
135
  ---
 
136
  ## Best Practices: Setup, Usage, Troubleshooting
 
137
  - **Setup**: `pip install -r requirements.txt`; run `app.py` to launch UI and API.
138
+ - **Usage**: Ingest assets via UI or API, follow pipeline in dashboard, review and score leads, manually validate flagged inputs.
139
  - **Troubleshooting**:
140
  - Logs/errors to console and CSV.
141
  - Validation steps highlight schema mismatches.
142
  - Check agent handoff logs for stuck or dropped assets.
143
+ - **NEW**: If scoring fails, error logged in `validation_errors`; review continues without score.
144
+ - Verify `lead_scoring_agent` module is importable; check namespace and dependencies.
145
  - Update configs/schemas via `docs/configs/` for custom needs.
146
 
147
  ---
 
148
  ## Module, Config, Script, and Logic Reference
 
149
  - **Core Modules**:
150
  - `activity_ingestion.py`, `outreach_agent.py`, `recovery_enrichment_agent.py`, `analytics_agent.py`, `research_agent.py`, `human_validation_agent.py`, `query_search_agent.py`
151
+ - **NEW**: `lead_scoring_agent.py` (lead profile scoring and enrichment)
152
  - **Config Files**:
153
  - All YAML/JSON in `docs/configs/`, plus channel/handler settings in each agent.
154
+ - **NEW**: Lead scoring configuration in `docs/configs/scoring_config.yaml` (signal weights, thresholds, etc.)
155
  - **Schema & Versioning**:
156
  - `schema_registry.py`, `SCHEMA_VERSIONING.md`
157
+ - **NEW**: Updated `LeadReview` schema with scoring fields in v2
158
  - **Test Scripts**:
159
  - `test_schema_tools.py`, `test_validation.py`
160
+ - **NEW**: Lead scoring integration tests in `test_validation.py`
161
  - **Agent Handoff Logic**:
162
  - `docs/enrichment_handoff_simulation.py`
163
+ - **NEW**: Scoring metadata passed through handoff chain
164
 
165
  ---
 
166
  For further explanation, workflows, and custom case studies—see full documentation and module-level docstrings.