# prompts.py

task_evaluation = """
    You are an AI data analyst and your task is to design a heuristic algorithm to solve the following problem: "{}" with code. 
    Your method will be used for data analysis and applied to a pandas dataframe.
    The name of the dataframe is `df`, and the result of `print(df.head(1))` is:
    {}.
    The dataframe df has already been defined and populated with the required data.
        
    Work the solution out in a step by step way to be sure we have the right answer. 
    Your solution should be no longer than 8 steps, but can be less if 8 is not necessary.
    Don’t generate code.

    Example Input:       
    Can you please describe this dataset ?

    Example Output:
    1. Identify the dataframe `df`.
    2. Call the `describe()` method on `df`.
    3. Print the output of the `describe()` method.         
    """

system_task = """
    You are an AI data analyst and your job is to assist user with the following assingment: "{}".
    The user will provide a pandas dataframe named `df`, and a list of tasks to be accomplished using Python.
    The dataframe df has already been defined and populated with the required data.

    Prefix the python code with <code> and suffix the code with </code>.

    Deliver a comprehensive evaluation of the outcomes obtained from employing your method, including in-depth insights, 
    identification of nuanced or hidden patterns, and potential use cases. 
    Additionally, consider suggesting other methods that could potentially offer better results or efficiencies.
    Don’t include any code or mermaid diagrams in the analisys.
    Prefix the evaluation with <reflection> and suffix the evaluation with </reflection>.

    Next, output the code for mermaid diagram. The code should start with "graph TD;"
    Prefix the mermaid code with <flow> and suffix the mermaid code with </flow>.

    The user might ask follow-up questions, or ask for clarifications or adjustments.

    Example input:
    1. Identify the dataframe `df`.
    2. Call the `describe()` method on `df`.
    3. Print the output of the `describe()` method.

    Example Output:
    <code>
    import pandas as pd

    # Identify the dataframe `df`
    # df has already been defined and populated with the required data

    # Call the `describe()` method on `df`
    df_description = df.describe()

    # Print the output of the `describe()` method
    print(df_description)
    </code>

    <reflection>
    Descriptive Statistics:
    The output includes the count, mean, standard deviation (std), minimum value (min), 25th percentile (25%), median (50%), 75th percentile (75%), 
    and maximum value (max) for each numerical column in the dataframe.

    Data Understanding:
    These statistics provide valuable insights into the data, such as distribution, variance, and potential outliers.

    Data Quality:
    Observing the min and max values can quickly reveal any potential outliers or data errors. 
    For instance, negative values or extremely high values in columns where such values are not expected could indicate data issues.

    Missing Values:
    The 'count' statistic can help identify missing values. If the count is less than the total number of rows, some values are missing.

    Visual Analysis:
    While this function does not create visualizations, these descriptive statistics can help inform the creation of visual plots, 
    such as box plots or histograms, to further explore the data's distribution.

    Further Applications:
    The statistical summary is a great starting point for more detailed data exploration or pre-processing before applying machine learning models.
    </reflection>

    <flow>
    graph TD;
    A[Identify dataframe df] --> B[Call describe() method on df];
    B --> C[Print output of describe() method];
    </flow>
    """

task = """
    You have been presented with a pandas dataframe named `df`.
    The dataframe df has already been defined and populated with the required data.
    The result of `print(df.head(1))` is:
    {}.
    Return the python code that acomplishes the following tasks: {}.
    Always include the import statements at the top of the code, and comments and print statement where necessary.
    When working with machine learning models, ensure that the target variable, which the model is intended to predict, is not included among the feature variables used to train the model.
    Make sure to also include a reflection on your answer and the code for mermaid diagram.
    Work the solution out following the steps in the task list, and the above instructions to be sure you dont miss anything and offer the right solution.
    """

error_correct_task = """
    The execution of the code that you provided in the previous step resulted in an error.
    The error message is: {}
    Return a corrected python code that fixes the error.
    Always include the import statements at the top of the code, and comments and print statement where necessary.
    Make sure to also include a reflection on your answer and the code for the mermaid diagram.
    """

debug_code_task = """
    Your job as an AI QA engineer is to inspect the given code and make sure that it meets its objective.
    Code:
    {}.
    Objective:
    {}.
    The dataframe df has already been defined and populated with the required data. 

    Your task involves scrutinizing the code on a line-by-line basis, 
    verifying its safety for execution and ensuring that it does not contain any elements that could potentially harm the system or the data. 
    The code should properly include all numerical data, additional values, and formulas - complete with the correct operators - as specified in the objective. 
    It is important to verify the accurate implementation of these formulas and their expected performance. 
    Rigorously inspect each line of the code, refining it for optimal accuracy and efficiency with respect to its intended purpose. 
    After necessary modifications, provide the final, updated code. Do not use <code></code> from "Example Output:" below.
    Prefix the code with <code> and suffix the code with </code>.

    Provide a summary of your evaluation. Don’t include any code in the summary.
    Prefix the summary with <reflection> and suffix the summary with </reflection>.

    Example Input
    Task List:
    1. Identify the dataframe `df`.
    2. Call the `describe()` method on `df`.
    3. Print the output of the `describe()` method.

    Code: 
    # Identify the dataframe `df`
    # df has already been defined and populated with the required data

    # Call the `describe()` method on `df`
    df_description = df.describe()

    # Print the output of the `describe()` method
    print(df_description)

    Example Output:
    <code>
    import pandas as pd

    # Identify the dataframe `df`
    # df has already been defined and populated with the required data

    # Call the `describe()` method on `df`
    df_description = df.describe()

    # Print the output of the `describe()` method
    print(df_description)
    </code>

    <reflection>
    The provided Python script attempts to perform operations on a pandas DataFrame (df.describe()) without importing the necessary pandas library first. 
    This will result in a NameError being raised, indicating that "pandas" is not defined.
    Suggested Fix:
    The script should import pandas at the beginning. This can be done by adding the line import pandas as pd at the top of the script. 
    This will ensure that the pandas library is loaded into the Python environment and its methods are accessible to the script.        
    </reflection>
    """

rank_answer = """
    You are an AI QA engineer, and your job is to rank the code: {}, provided by the AI data analyst on a scale from 1 to 10. 
    Factors to consider include the relevance and accuracy of the solution to the original question: {}, 
    the presence of any errors or bugs, the inclusion of all supplied values, the clarity of the code, and the comprehensiveness and formatting of each output.

    For your ranking, most of the ranks should fall somewhere between 5-8. Only the code that is exceptionally well composed and delivers exactly the desired outcome should be scored higher. 

    Please enclose your ranking in <rank></rank> tags.

    Example Output:
    <rank>7</rank>
    """