Spaces:
Running
Running
feat: add heuristic fallback when LLM review step fails
Browse files
.github/workflows/daily-social-requirements.yml
CHANGED
|
@@ -29,14 +29,13 @@ jobs:
|
|
| 29 |
|
| 30 |
- name: Validate required secrets and vars
|
| 31 |
run: |
|
| 32 |
-
if [ -z "${OPENAI_API_KEY}" ]; then
|
| 33 |
-
echo "Missing required secret: OPENAI_API_KEY"
|
| 34 |
-
exit 1
|
| 35 |
-
fi
|
| 36 |
if [ -z "${SITE_URL}" ]; then
|
| 37 |
echo "Missing required repository variable: DEMANDSOLUTION_SITE_URL"
|
| 38 |
exit 1
|
| 39 |
fi
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
- name: Collect social demand signals (HN + StackOverflow)
|
| 42 |
run: |
|
|
@@ -53,7 +52,12 @@ jobs:
|
|
| 53 |
echo "run_dir=${latest}" >> "${GITHUB_OUTPUT}"
|
| 54 |
|
| 55 |
- name: LLM filter clear requirements
|
|
|
|
| 56 |
run: |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
python -m src.web_user_summary.llm_requirement_filter \
|
| 58 |
--provider openai \
|
| 59 |
--openai-model "${OPENAI_MODEL}" \
|
|
|
|
| 29 |
|
| 30 |
- name: Validate required secrets and vars
|
| 31 |
run: |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
if [ -z "${SITE_URL}" ]; then
|
| 33 |
echo "Missing required repository variable: DEMANDSOLUTION_SITE_URL"
|
| 34 |
exit 1
|
| 35 |
fi
|
| 36 |
+
if [ -z "${OPENAI_API_KEY}" ]; then
|
| 37 |
+
echo "OPENAI_API_KEY is empty. Will continue with heuristic fallback (no LLM review)."
|
| 38 |
+
fi
|
| 39 |
|
| 40 |
- name: Collect social demand signals (HN + StackOverflow)
|
| 41 |
run: |
|
|
|
|
| 52 |
echo "run_dir=${latest}" >> "${GITHUB_OUTPUT}"
|
| 53 |
|
| 54 |
- name: LLM filter clear requirements
|
| 55 |
+
continue-on-error: true
|
| 56 |
run: |
|
| 57 |
+
if [ -z "${OPENAI_API_KEY}" ]; then
|
| 58 |
+
echo "Skipping LLM review due to missing OPENAI_API_KEY."
|
| 59 |
+
exit 0
|
| 60 |
+
fi
|
| 61 |
python -m src.web_user_summary.llm_requirement_filter \
|
| 62 |
--provider openai \
|
| 63 |
--openai-model "${OPENAI_MODEL}" \
|
README.md
CHANGED
|
@@ -91,5 +91,5 @@ This repo includes a daily workflow to collect user requirements from free socia
|
|
| 91 |
|
| 92 |
Required GitHub repository settings:
|
| 93 |
|
| 94 |
-
- Secret: `OPENAI_API_KEY`
|
| 95 |
- Variable: `DEMANDSOLUTION_SITE_URL` (example: `https://jacksuyu-demandsolution-codex.hf.space/`)
|
|
|
|
| 91 |
|
| 92 |
Required GitHub repository settings:
|
| 93 |
|
| 94 |
+
- Secret: `OPENAI_API_KEY` (optional; if invalid/missing, workflow falls back to heuristic acceptance)
|
| 95 |
- Variable: `DEMANDSOLUTION_SITE_URL` (example: `https://jacksuyu-demandsolution-codex.hf.space/`)
|
scripts/post_requirements_to_demandsolution.py
CHANGED
|
@@ -44,11 +44,32 @@ def latest_run_dir(base: Path) -> Path:
|
|
| 44 |
def load_accepted_requirements(run_dir: Path) -> List[Dict]:
|
| 45 |
curated = run_dir / "llm_requirement_accepted_curated.json"
|
| 46 |
raw = run_dir / "llm_requirement_accepted.json"
|
|
|
|
| 47 |
if curated.exists():
|
| 48 |
return json.loads(curated.read_text(encoding="utf-8")).get("accepted", [])
|
| 49 |
if raw.exists():
|
| 50 |
return json.loads(raw.read_text(encoding="utf-8")).get("accepted", [])
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
|
| 54 |
def load_state(path: Path) -> Dict:
|
|
|
|
| 44 |
def load_accepted_requirements(run_dir: Path) -> List[Dict]:
|
| 45 |
curated = run_dir / "llm_requirement_accepted_curated.json"
|
| 46 |
raw = run_dir / "llm_requirement_accepted.json"
|
| 47 |
+
clusters_file = run_dir / "demand_clusters.json"
|
| 48 |
if curated.exists():
|
| 49 |
return json.loads(curated.read_text(encoding="utf-8")).get("accepted", [])
|
| 50 |
if raw.exists():
|
| 51 |
return json.loads(raw.read_text(encoding="utf-8")).get("accepted", [])
|
| 52 |
+
if clusters_file.exists():
|
| 53 |
+
payload = json.loads(clusters_file.read_text(encoding="utf-8"))
|
| 54 |
+
clusters = payload.get("clusters", [])
|
| 55 |
+
accepted = []
|
| 56 |
+
for cluster in clusters[:20]:
|
| 57 |
+
summary = str(cluster.get("summary_demand", "")).strip()
|
| 58 |
+
if not summary:
|
| 59 |
+
continue
|
| 60 |
+
accepted.append(
|
| 61 |
+
{
|
| 62 |
+
"cluster_id": cluster.get("cluster_id", ""),
|
| 63 |
+
"normalized_requirement": summary,
|
| 64 |
+
"requirement": summary,
|
| 65 |
+
"reason": "Fallback acceptance (heuristic) because LLM review output was unavailable.",
|
| 66 |
+
"demand_count": int(cluster.get("demand_count", 1) or 1),
|
| 67 |
+
"examples": cluster.get("examples", [])[:3],
|
| 68 |
+
}
|
| 69 |
+
)
|
| 70 |
+
if accepted:
|
| 71 |
+
return accepted
|
| 72 |
+
raise FileNotFoundError(f"No accepted requirements JSON or demand_clusters fallback found in {run_dir}")
|
| 73 |
|
| 74 |
|
| 75 |
def load_state(path: Path) -> Dict:
|