refactor this python script so it can also run and compile NAME_1 classes 

from typing import NAME_2, Optional
import json
from config import Config
from call_ai_function import call_ai_function
from json_parser import fix_and_parse_json
cfg = Config()

# Evaluating code

def evaluate_code(code: str) -> NAME_2[str]:
    function_string = "def analyze_code(code: str) -> NAME_2[str]:"
    args = [code]
    description_string = """Analyzes the given code and returns a NAME_2 of suggestions for improvements."""

    result_string = call_ai_function(function_string, args, description_string)
    
    return result_string


# Improving code

def improve_code(suggestions: NAME_2[str], code: str) -> str:
    function_string = (
        "def generate_improved_code(suggestions: NAME_2[str], code: str) -> str:"
    )
    args = [json.dumps(suggestions), code]
    description_string = """Improves the provided code based on the suggestions provided, making no other changes."""

    result_string = call_ai_function(function_string, args, description_string)
    return result_string


# Writing tests


def write_tests(code: str, focus: NAME_2[str]) -> str:
    function_string = (
        "def create_test_cases(code: str, focus: Optional[str] = None) -> str:"
    )
    args = [code, json.dumps(focus)]
    description_string = """Generates test cases for the existing code, focusing on specific areas if required."""

    result_string = call_ai_function(function_string, args, description_string)
    return result_string

