File size: 1,520 Bytes
6bce3a4 402f4b1 6bce3a4 402f4b1 6bce3a4 402f4b1 6bce3a4 402f4b1 6bce3a4 402f4b1 6bce3a4 402f4b1 6bce3a4 5ba0237 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | from __future__ import annotations
from typing import Any, List, Optional
def _clean_bullets(value: Any) -> List[str]:
if not value:
return []
if isinstance(value, str):
parts = [line.strip() for line in value.splitlines()]
return [p for p in parts if p and not p.startswith("#")]
if isinstance(value, list):
out: List[str] = []
for item in value:
if isinstance(item, str):
s = item.strip()
if s and not s.startswith("#"):
out.append(s)
return out
return []
def compile_surveyor_attributes_overlay(attributes: Any) -> str:
"""Compile surveyor attributes (plain bullet lines) into a prompt overlay."""
items = _clean_bullets(attributes)
if not items:
return ""
lines: List[str] = []
lines.append("Surveyor attributes (follow these):")
for item in items:
lines.append(f"- {item}")
return "\n".join(lines).strip()
def compile_question_bank_overlay(question_bank_text: Optional[str]) -> str:
if not isinstance(question_bank_text, str):
return ""
raw = [line.strip() for line in question_bank_text.splitlines()]
items = [line for line in raw if line and not line.startswith("#")]
if not items:
return ""
lines: List[str] = []
lines.append("Question bank (targets to cover):")
for idx, item in enumerate(items, start=1):
lines.append(f"- q{idx:02d}: {item}")
return "\n".join(lines).strip()
|