def concat_subqs_and_subas(
    solution_trace: Dict[int, Dict[str, str]], question_index: int
) -> Tuple[str, int]:
    """Return: concatenated subqs and suba, next subquestion id"""
    solution_trace_str = ""

    for subquestion_id, solution_step in solution_trace.items():
        if subquestion_id == 0:
            continue

        assert subquestion_id > 0
        assert (
            "subquestion" in solution_step.keys()
            and "subanswer" in solution_step.keys()
        )

        solution_trace_str += (
            f"Question {question_index}."
            + str(subquestion_id)
            + ": "
            + solution_step["subquestion"]
        )
        solution_trace_str += "\n"
        solution_trace_str += (
            f"Answer {question_index}."
            + str(subquestion_id)
            + ": "
            + solution_step["subanswer"]["text"]
        )
        solution_trace_str += "\n"

    next_subquestion_id = int(sorted(solution_trace.keys())[-1]) + 1
    return solution_trace_str, next_subquestion_id
Return: concatenated subqs and suba, next subquestion id
envs/rstar/rstar_utils.py