def generate_pr_summary()

in devai-api/app/github_utils.py [0:0]


def generate_pr_summary(existing_source_code: str, new_source_code: str) -> str:
    """Generates a summary for a GitHub pull request based on the changes between 
    the existing and new source code.

    Args:
        existing_source_code (str): The original source code.
        new_source_code (str): The modified source code.

    Returns:
        str: A string containing the pull request title and description, 
             separated by a newline character. Returns None if an error occurs.
    """
    pr_summary_template = """
    Summarize the changes between old and new source code and return summary for GitHub pull request. 
    Response format: PR Name\nnPR description
    Example format: Test PR\nnThis is a test PR.

    OLD SOURCE CODE:
    {}

    NEW SOURCE CODE:
    {}
    """

    try:
        with telemetry.tool_context_manager(USER_AGENT):
            code_chat = model.start_chat(response_validation=False)
            pr_response = code_chat.send_message(
                pr_summary_template.format(existing_source_code, new_source_code)
            )
            return pr_response.text
    except Exception as e:
        print(f"Error generating pull request summary: {e}")
        return