stackConsult commited on
Commit
f9178b3
·
verified ·
1 Parent(s): 2812a46

Document runtime error fix and remediation

Browse files

Added Runtime Error Diagnostic & Remediation section documenting the ModuleNotFoundError for transformers library, root cause analysis, and the fix applied to requirements.txt. Includes best practices for dependency management going forward.

Files changed (1) hide show
  1. README.md +56 -0
README.md CHANGED
@@ -7,42 +7,83 @@ sdk: gradio
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`).
18
  - Logs activity (`activity_log.csv`).
 
19
  2. **Automated Enrichment** (`recovery_enrichment_agent.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.
@@ -52,7 +93,9 @@ short_description: A simple Gradio app
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.
@@ -60,7 +103,9 @@ short_description: A simple Gradio app
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)
@@ -111,21 +156,27 @@ 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.
@@ -133,7 +184,9 @@ print(results) # All results include scoring metadata
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**:
@@ -145,7 +198,9 @@ print(results) # All results include scoring metadata
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)
@@ -163,4 +218,5 @@ print(results) # All results include scoring metadata
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.
 
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.
 
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.
 
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)
 
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.
 
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**:
 
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)
 
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.