File size: 1,990 Bytes
59cbda6 b690278 59cbda6 b690278 2568a5f d7e3980 b690278 2568a5f b690278 59cbda6 b690278 59cbda6 b690278 59cbda6 b690278 59cbda6 | 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 48 49 50 51 52 53 54 | from __future__ import annotations
from typing import Any, List, Optional
DEFAULT_BOTTOM_UP_INSTRUCTIONS: str = (
"You are performing bottom-up thematic analysis. Identify the most prominent themes in the conversation, with no a priori concepts; the themes are emergent from the text."
)
DEFAULT_TOP_DOWN_INSTRUCTIONS: str = (
"You are performing top-down coding using the provided codebook categories. For each category, extract the most relevant codes/items supported by evidence."
)
DEFAULT_RUBRIC_INSTRUCTIONS: str = (
"You are performing a care experience rubric analysis. Summarize the overall experience and list the key reasons for each bucket."
)
DEFAULT_BOTTOM_UP_ATTRIBUTES: List[str] = [
"Prefer fewer, higher-confidence items.",
"For themes: include a short code label (1-3 words) in addition to the longer summary.",
]
DEFAULT_RUBRIC_ATTRIBUTES: List[str] = [
"Prefer fewer, higher-confidence items.",
"For care experience: do not duplicate the same evidence_id across positive/negative/mixed/neutral. If a sentence supports both positive and negative interpretations, put it in care_experience.mixed.",
]
DEFAULT_TOP_DOWN_ATTRIBUTES: List[str] = [
"Prefer fewer, higher-confidence items.",
"For top_down_codebook categories: include a short code label (1-3 words) and cite evidence.",
]
def normalize_analysis_attributes(attributes: Any) -> List[str]:
if not isinstance(attributes, list):
return []
cleaned = []
for item in attributes:
if not isinstance(item, str):
continue
stripped = item.strip()
if stripped:
cleaned.append(stripped)
return cleaned
def compile_analysis_rules_block(attributes: Any, *, defaults: Optional[List[str]] = None) -> str:
rules = normalize_analysis_attributes(attributes)
if not rules:
rules = list(defaults or [])
bullets = "\n".join(f"- {line}" for line in rules)
return "Rules:\n" + bullets + "\n"
|