File size: 2,164 Bytes
a43aaf6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""Utilities for formatting task data for LLM consumption."""

from typing import Dict, List, Any


def _format_standards_section(standards: List[Dict[str, str]]) -> str:
    """
    Format a list of standards into LLM-readable text.

    Args:
        standards: List of dicts with 'code' and 'text' keys

    Returns:
        Formatted string with one standard per line
    """
    if not standards:
        return ""

    lines = []
    for standard in standards:
        code = standard.get('code', '')
        text = standard.get('text', '')
        lines.append(f"  - {code}: {text}")

    return "\n".join(lines)


def serialize_task_metadata_for_llm(task_metadata: Dict[str, Any]) -> str:
    """
    Serialize task metadata into LLM-readable text format.

    Converts array-based standards fields into formatted text blocks
    suitable for inclusion in LLM prompts.

    Args:
        task_metadata: Dict containing task metadata with standards arrays

    Returns:
        Formatted multi-line string suitable for LLM consumption
    """
    sections = []

    # Title
    title = task_metadata.get('title', 'Untitled Task')
    sections.append(f"Title: {title}")

    # Performance Expectations
    pe_standards = task_metadata.get('pe_standards', [])
    if pe_standards:
        sections.append("\nPerformance Expectations:")
        sections.append(_format_standards_section(pe_standards))

    # Disciplinary Core Ideas
    dci_standards = task_metadata.get('dci_standards', [])
    if dci_standards:
        sections.append("\nDisciplinary Core Ideas (DCI):")
        sections.append(_format_standards_section(dci_standards))

    # Science & Engineering Practices
    sep_standards = task_metadata.get('sep_standards', [])
    if sep_standards:
        sections.append("\nScience & Engineering Practices (SEP):")
        sections.append(_format_standards_section(sep_standards))

    # Crosscutting Concepts
    ccc_standards = task_metadata.get('ccc_standards', [])
    if ccc_standards:
        sections.append("\nCrosscutting Concepts (CCC):")
        sections.append(_format_standards_section(ccc_standards))

    return "\n".join(sections)