def _extract_partial_list_progress(
    content: str,
    output_cls: Type[Model],
    cur_object: Optional[Union[Model, FlexibleModel]],
    partial_output_cls: Type[FlexibleModel],
) -> Optional[FlexibleModel]:
    """
    Try to extract partial list progress from incomplete JSON.

    This attempts to build upon the current object by detecting partial
    list additions even when JSON is malformed.
    """
    if not isinstance(content, str) or cur_object is None:
        return None

    try:
        import re

        # Try to extract list patterns from incomplete JSON
        # Look for patterns like: "jokes": [{"setup": "...", "punchline": "..."}
        list_pattern = r'"(\w+)":\s*\[([^\]]*)'
        matches = re.findall(list_pattern, content)

        if not matches:
            return None

        # Start with current object data
        current_data = (
            cur_object.model_dump() if hasattr(cur_object, "model_dump") else {}
        )

        for field_name, list_content in matches:
            if (
                hasattr(output_cls, "model_fields")
                and field_name in output_cls.model_fields
            ):
                # Try to parse individual items from the list content
                items = _parse_partial_list_items(list_content, field_name, output_cls)
                if items:
                    current_data[field_name] = items

        # Try to create object with updated data
        return partial_output_cls.model_validate(current_data)

    except Exception:
        return None

    Try to extract partial list progress from incomplete JSON.

    This attempts to build upon the current object by detecting partial
    list additions even when JSON is malformed.
    
llama-index-core/llama_index/core/program/streaming_utils.py