"""
Test for getting overall score of your model
"""

from .cover_test import cover_test
from .pos_test import pos_test
from .winner_test import winner_test


def overall_test(
    client,
    response,
    expected_response,
    concept_set,
    model="gpt-3.5-turbo",
    temperature: float = 0,
    max_tokens: int = 512,
):
    """
    Provides overall score which is product of pos_test, cover_test and winner_test output.

    Args:
        response (str): response generated by your model.
        Pass below instruction to your LLM and ask it to generate output. Refer below example.
        instruction: "# Instruction\n\nGiven several concepts (i.e., nouns or verbs), write a short and simple sentence that contains *all* the required words.\nThe sentence should describe a common scene in daily life, and the concepts should be used in a natural way.\n\n# Examples\n\n## Example 1\n- Concepts: \"dog(noun), frisbee(noun), catch(verb), throw(verb)\"\n- Sentence: The dog catches the frisbee when the boy throws it into the air.\n\n## Example 2\n- Concepts: \"apple(noun), place(verb), tree(noun), pick(verb)\"\n- Sentence: A girl picks some apples from a tree and places them into her basket.\n\n# Your Task \n\n- Concepts: \"catch(verb), dog(noun), frisbee(noun), throw(verb)\"\n- Sentence: ",
        example_response: [
        "The dog catches the frisbee when someone throws it."
        ]

        expected_response (str): It can be human_annotation or output from some other model.
        concept_set (list): Refer below form
            concept_set: [
            "catch_V",
            "dog_N",
            "frisbee_N",
            "throw_V"
            ]
        model (str, optional): The name of the language model to be used for task of evaluating your model. Defaults to "gpt-3.5-turbo".
        temperature (float,optional): This parameter allows you to adjust the randomness of the response generated by the specified model.
        max_tokens  (int,optional): This parameter allows you to specify the maximum length of the generated response.
        
        NOTE: Concept_set should always conatin words in their root form.

    Returns:
        dict: A dictionary containing the evaluation results.
    """

    win_count = winner_test(
        client, response, expected_response, concept_set, model, temperature, max_tokens
    )["score"]
    pos_score = pos_test(response, concept_set)["score"]
    cover_score = cover_test(response, concept_set)["score"]
    overall_score = win_count * pos_score * cover_score

    result = {
        "response": response,
        "expected_response": expected_response,
        "concept_set": concept_set,
        "score": overall_score,
        "evaluated_with": {"model": model},
    }

    return result
