stackConsult commited on
Commit
3549fb6
·
verified ·
1 Parent(s): 2f9afec

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +30 -201
README.md CHANGED
@@ -7,216 +7,45 @@ 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
- ## Runtime Error Diagnostic & Remediation (Nov 2025)
18
-
19
- ### Problem Identified
20
- The Space experienced a `ModuleNotFoundError: No module named 'transformers'` runtime error at startup. The error traceback showed:
21
- ```
22
- File "/app/app.py", line 2, in <module>
23
- from lead_scoring_agent import LeadScoringAgent
24
- File "/app/lead_scoring_agent.py", line 13, in <module>
25
- from transformers import pipeline
26
- ModuleNotFoundError: No module named 'transformers'
27
- ```
28
-
29
- ### Root Cause
30
- The `lead_scoring_agent.py` module imports `from transformers import pipeline` (line 13), which is required for HuggingFace model-based lead scoring functionality. However, the `transformers` library dependency was commented out in `requirements.txt` (line 16: `# transformers>=4.35.0 # Uncomment if using HuggingFace models`).
31
-
32
- ### Remediation
33
- **Action taken:** Uncommented the `transformers>=4.35.0` dependency in `requirements.txt` (commit 2812a465d20a511d453648b52e546bbba1d87532).
34
-
35
- **Explanation:** The `transformers` library is essential for the lead scoring agent's NLP-based analysis capabilities. With the dependency now active, the Space container can install the required package during build, resolving the import error.
36
-
37
- **Verification:** After the fix, the Space should rebuild automatically and transition from "Runtime error" to "Running" state. Monitor build logs to confirm successful installation of transformers and dependencies.
38
-
39
- ### Best Practices Going Forward
40
- - **Dependency Audit:** When adding new agent modules that import external libraries, ensure all dependencies are declared in `requirements.txt`.
41
- - **Import Testing:** Run local imports or CI checks before deploying to catch missing dependencies early.
42
- - **Documentation Alignment:** Keep inline comments in `requirements.txt` synchronized with actual code imports to prevent confusion.
43
-
44
- ---
45
-
46
- ## Pipeline Workflow
47
 
48
- 1. **Input/Asset Ingestion** (`activity_ingestion.py`):
49
- - Receives assets or lead lists (CSV, API, UI submission).
50
- - Validates schema (see `schema_registry.py`).
51
- - Logs activity (`activity_log.csv`).
 
52
 
53
- 2. **Automated Enrichment** (`recovery_enrichment_agent.py`):
54
- - Fills gaps: persona, recent posts, complaints, engagement metrics.
55
- - Invokes external APIs as needed or generates synthetic context.
56
- - Handoff to validation agent if enrichment uncertain.
 
57
 
58
- 3. **Lead Scoring** (`lead_scoring_agent.py`) - NEW:
59
- - Scores lead profiles based on firmographic, behavioral, and engagement signals.
60
- - Enriches profiles with scoring metadata and rationale.
61
- - Integrated into validation workflow at action start for each lead review.
 
62
 
63
- 4. **Human/Machine Validation** (`human_validation_agent.py`):
64
- - Receives enriched assets where automated logic lacks confidence.
65
- - **NEW:** Scores each lead profile at action start using `lead_scoring_agent`.
66
- - **NEW:** Passes scoring results and enrichment data to downstream handlers.
67
- - Interactive review and correction (UI or API endpoint).
68
- - Returns enriched/validated/scored assets to pipeline.
69
-
70
- 5. **Outreach/Engagement** (`outreach_agent.py`):
71
- - Selects template, personalizes using context fields and scoring signals.
72
- - Delivers via pluggable channels: email, LinkedIn, SMS, browser automation.
73
- - Supports automated social actions and feedback.
74
-
75
- 6. **Analytics & Reporting** (`analytics_agent.py`):
76
- - Logs all asset/channel outcomes, engagement stats, and scoring performance.
77
- - Computes dashboards, actionable feedback, and improvement triggers.
78
-
79
- 7. **Research/Search Integration** (`research_agent.py`, `query_search_agent.py`):
80
- - Supplements enrichment with web or corpus search, updates context/data.
81
- - Used by outreach for deep personalization or compliance needs.
82
-
83
- ---
84
-
85
- ## API Endpoints
86
-
87
- - `/ingest` (**POST**): Upload asset batch (CSV/JSON), triggers validation & enrichment.
88
- - `/validate` (**POST**): Human/machine validation of asset content with lead scoring.
89
- - `/score` (**POST**) - NEW: Score lead profiles using lead_scoring_agent; returns scoring metadata.
90
- - `/enrich` (**POST**): Force re-enrichment or supplemental context fill.
91
- - `/outreach` (**POST**): Initiates personalized outreach actions; returns status/transcript.
92
- - `/analytics` (**GET**): Fetch per-asset, per-campaign, or global reports/statistics.
93
- - **Authentication/Authorization**: All endpoints respect granular role controls, see config in `docs/configs/`.
94
-
95
- ---
96
-
97
- ## UI Dashboard Features
98
-
99
- - Asset ingestion/upload table with schema/state indicators and scoring status.
100
- - Visualization of validation/enrichment status, gaps, overrides (human/manual call-outs), and lead scores.
101
- - Outreach composer: preview, edit, and dispatch personalized messages across channels using scoring signals.
102
- - Live stats: engagement rates, delivery status, trigger diagnostics, scoring performance metrics, per-asset and per-campaign.
103
- - Agent handoff log: view/trace enrichment, validation, scoring, and outreach chain per asset.
104
-
105
- ---
106
 
107
- ## Lead Scoring Integration (NEW)
108
-
109
- ### Overview
110
- 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:
111
- - Score result (numeric or categorical)
112
- - Scoring rationale and signal breakdown
113
- - Enriched profile data
114
- - Scoring metadata for downstream use
115
-
116
- ### Key Features
117
- - **Import & Initialization**: `human_validation_agent` imports `LeadScoringAgent` and initializes it on instantiation.
118
- - **Action-Start Scoring**: `process_review_action()` scores the lead profile before action execution.
119
- - **Schema Updates**: `LeadReview` schema extended with `scoring_result` and `enrichment_data` fields.
120
- - **Batch Scoring**: `process_batch_review()` scores all leads in the batch, passing metadata downstream.
121
- - **History Export**: Review history JSON export includes scoring metadata for each review.
122
- - **Error Handling**: Scoring failures logged and tracked without blocking review actions.
123
-
124
- ### Integration Points
125
- - **LeadReview Schema**: New optional fields: `scoring_result` (Dict), `enrichment_data` (Dict).
126
- - **HumanValidationAgent.score_lead_profile()**: Calls `lead_scoring_agent.score_lead()` and retrieves enrichment data.
127
- - **HumanValidationAgent.process_review_action()**: Scores profile at action start; stores metadata with review.
128
- - **HumanValidationAgent.process_batch_review()**: Iterates batch reviews, scoring each and collecting results.
129
- - **API & UI**: `/validate` endpoint receives and returns scoring metadata; dashboard displays scores and rationale.
130
-
131
- ### Example Usage
132
- ```python
133
- from human_validation_agent import HumanValidationAgent, BatchReviewRequest
134
-
135
- agent = HumanValidationAgent()
136
-
137
- # Single review with scoring
138
- review_data = {
139
- "lead_id": "lead_001",
140
- "action": "approve",
141
- "reviewer_id": "reviewer_123"
142
- }
143
- result = agent.process_review_action(LeadReview(**review_data))
144
- print(result) # Includes scoring_metadata with score_result and enrichment_data
145
-
146
- # Batch review with scoring for each lead
147
- batch_request = BatchReviewRequest(
148
- reviews=[
149
- LeadReview(lead_id="lead_001", action="approve", reviewer_id="reviewer_123"),
150
- LeadReview(lead_id="lead_002", action="edit", edited_data={...}, reviewer_id="reviewer_123"),
151
- LeadReview(lead_id="lead_003", action="scrub", reason="competitor", reviewer_id="reviewer_123")
152
- ]
153
- )
154
- results = agent.process_batch_review(batch_request)
155
- print(results) # All results include scoring metadata
156
- ```
157
-
158
- ---
159
-
160
- ## Test Case Logic
161
-
162
- - Test scripts: `test_schema_tools.py`, `test_validation.py` (unit tests for all schema/enrichment/validation logic).
163
- - **NEW**: Test lead scoring integration in `test_validation.py`; verify scoring metadata in reviews.
164
- - CI-friendly: All test scripts runnable standalone or via `pytest`, support fixtures for human/machine edge cases.
165
- - Example cases cover incomplete asset, fuzzy enrichment, validation override, lead scoring, pipeline/integration chain.
166
-
167
- ---
168
-
169
- ## Agent & Asset Wiring
170
-
171
- - Each module is pluggable: you can sub in new enrichment, validation, scoring, or channel handler without altering others.
172
- - **NEW**: Lead scoring agent decoupled from validation—can be swapped or augmented independently.
173
- - 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/`).
174
- - Asset state maintained through pipeline, logging all hops including scoring. Schemas upgradable (see `SCHEMA_VERSIONING.md`).
175
-
176
- ---
177
-
178
- ## Upgrade & Migration Guide
179
-
180
- - **Schema Versioning**: Asset, enrichment, and analytics schema tracked with incremental migrations (`SCHEMA_VERSIONING.md`).
181
- - **NEW**: `LeadReview` schema v2 includes `scoring_result` and `enrichment_data` fields (backward compatible).
182
- - **Lead Scoring Integration**: Ensure `lead_scoring_agent.py` is available in the same namespace; import validated on `HumanValidationAgent` instantiation.
183
- - **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/`.
184
- - Migration scripts: Provided for legacy log/asset conversion.
185
-
186
- ---
187
-
188
- ## Best Practices: Setup, Usage, Troubleshooting
189
-
190
- - **Setup**: `pip install -r requirements.txt`; run `app.py` to launch UI and API.
191
- - **Usage**: Ingest assets via UI or API, follow pipeline in dashboard, review and score leads, manually validate flagged inputs.
192
- - **Troubleshooting**:
193
- - Logs/errors to console and CSV.
194
- - Validation steps highlight schema mismatches.
195
- - Check agent handoff logs for stuck or dropped assets.
196
- - **NEW**: If scoring fails, error logged in `validation_errors`; review continues without score.
197
- - Verify `lead_scoring_agent` module is importable; check namespace and dependencies.
198
- - Update configs/schemas via `docs/configs/` for custom needs.
199
-
200
- ---
201
 
202
- ## Module, Config, Script, and Logic Reference
 
 
203
 
204
- - **Core Modules**:
205
- - `activity_ingestion.py`, `outreach_agent.py`, `recovery_enrichment_agent.py`, `analytics_agent.py`, `research_agent.py`, `human_validation_agent.py`, `query_search_agent.py`
206
- - **NEW**: `lead_scoring_agent.py` (lead profile scoring and enrichment)
207
- - **Config Files**:
208
- - All YAML/JSON in `docs/configs/`, plus channel/handler settings in each agent.
209
- - **NEW**: Lead scoring configuration in `docs/configs/scoring_config.yaml` (signal weights, thresholds, etc.)
210
- - **Schema & Versioning**:
211
- - `schema_registry.py`, `SCHEMA_VERSIONING.md`
212
- - **NEW**: Updated `LeadReview` schema with scoring fields in v2
213
- - **Test Scripts**:
214
- - `test_schema_tools.py`, `test_validation.py`
215
- - **NEW**: Lead scoring integration tests in `test_validation.py`
216
- - **Agent Handoff Logic**:
217
- - `docs/enrichment_handoff_simulation.py`
218
- - **NEW**: Scoring metadata passed through handoff chain
219
 
220
  ---
 
221
 
222
- 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
 
12
+ ## Granular UI Features (Nov 2025)
13
+ ### New Compliance, Audit, Branching & Diagnostics Widgets
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
+ #### 1. Consent/Event Audit Panel
16
+ Shows all consent events, opt-outs, and compliance flags per contact and batch.
17
+ - **Backend mapping:** Receives list of consent events (JSON, e.g. {contact_id, event_type, opt_out, compliance_flag}) per contact or batch.
18
+ - **UI mapping:** Gradio panel renders event history per contact, batch aggregation, flags out-of-policy events.
19
+ - **State schema:** See /docs/configs/compliance_schema.json.
20
 
21
+ #### 2. Dynamic Cadence Branching Composer
22
+ Visual builder for editing & previewing cadence sequences (multi-step outreach flows with conditional logic)
23
+ - **Backend mapping:** Mirrored to cadence state JSON (see cadence_agent.py / docs/configs/cadence_tree.json)
24
+ - **UI mapping:** Interactive tabular/tree UI shows each step, transition, and condition (see new app.py logic).
25
+ - **Inline code:** Each logic widget/function takes the backend structure as argument.
26
 
27
+ #### 3. Live Diagnostics Panel (Incidents/Health)
28
+ Shows real-time and historical such as error, warning, info events for cadence or batch operations.
29
+ - **Backend mapping:** List of incidents/events from backend diagnostics state (event objects: {timestamp, type, message, level})
30
+ - **UI mapping:** Gradio Markdown log renders type/level/message per event.
31
+ - **Config:** Event/incident schema in docs/configs/diagnostics_schema.json
32
 
33
+ #### 4. Exportable Audit Trail (Compliance/Debug)
34
+ CSV/text export of event history (compliance and debug records)
35
+ - **Backend mapping:** Batch history as list of per-event dicts, same as consent_audit schema.
36
+ - **UI mapping:** Text/csv box (downloadable) shows organized history—maps to regulatory & support request export needs.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
+ #### Usage & API Mapping
39
+ - All widgets assume backend compliance/cadence events via standardized JSON from respective APIs (see /api/diagnostics, /api/cadence, /api/compliance, etc).
40
+ - See app.py for inline documentation on each panel/component; argument signatures require the backend state JSON (typically list[dict]).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
+ #### Inline Documentation Examples (app.py)
43
+ - Each widget (audit, diagnostics, branching, export) is documented inline for both UI and state/JSON structure.
44
+ - You can customize backend structure via docs/configs/ files and panel logic will adopt new schemas as format evolves.
45
 
46
+ ## Example Panel Usage
47
+ Example construction is provided in app.py showing default data structures and rendering each widget in a Gradio tab.
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
  ---
50
+ (legacy platform and API docs retained below)
51