# Install dependencies:
# pip install ollama matplotlib
# Install Ollama locally and run: ollama pull llama3.2
#
# Analyzes subject marks, asks Ollama for a reflection, and creates a bar graph.

import ollama
import matplotlib.pyplot as plt

data = {
    "Python": 85,
    "Java": 72,
    "C": 65,
    "AI": 90,
}


def main():
    print("DATA")
    for subject, marks in data.items():
        print(f"{subject}: {marks}")

    prompt = f"""
You are a reflection agent. Analyze this data: {data}
Provide:
1. Key observations
2. Highest value
3. Lowest value
4. Suggestions based on the data
5. A short final reflection

Use only the given values. Do not make assumptions about students.
"""
    print("\nREFLECTION AGENT OUTPUT")
    response = ollama.chat(
        model="llama3.2",
        messages=[{"role": "user", "content": prompt}],
    )
    print(response["message"]["content"].strip())

    plt.bar(data.keys(), data.values())
    plt.xlabel("Subjects")
    plt.ylabel("Marks")
    plt.title("Marks by Subject")
    plt.ylim(0, 100)
    plt.tight_layout()
    plt.savefig("marks_by_subject.png", dpi=150)
    print("\nBar graph saved as marks_by_subject.png")
    plt.show()


if __name__ == "__main__":
    main()
