from dotenv import load_dotenv
from langchain import OpenAI 
from langchain.document_loaders.csv_loader import CSVLoader

load_dotenv()

filepath = "academy/academy.csv"
loader = CSVLoader(filepath)
data = loader.load()
print(data)

llm = OpenAI(temperature=0)

from langchain.agents import create_csv_agent
agent = create_csv_agent(llm, filepath, verbose=True)
agent.run("What percentage of the respondents are students versus professionals?")
agent.run("List the top 3 devices that the respondents use to submit their responses")
agent.run("Consider iOS and Android as mobile devices. What is the percentage of respondents that discovered us through social media submitting this from a mobile device?")

langchain.document_loaders.csv_loader.CSVLoader langchain.agents.create_csv_agent langchain.OpenAI
[((122, 135), 'dotenv.load_dotenv', 'load_dotenv', ([], {}), '()\n', (133, 135), False, 'from dotenv import load_dotenv\n'), ((179, 198), 'langchain.document_loaders.csv_loader.CSVLoader', 'CSVLoader', (['filepath'], {}), '(filepath)\n', (188, 198), False, 'from langchain.document_loaders.csv_loader import CSVLoader\n'), ((239, 260), 'langchain.OpenAI', 'OpenAI', ([], {'temperature': '(0)'}), '(temperature=0)\n', (245, 260), False, 'from langchain import OpenAI\n'), ((316, 361), 'langchain.agents.create_csv_agent', 'create_csv_agent', (['llm', 'filepath'], {'verbose': '(True)'}), '(llm, filepath, verbose=True)\n', (332, 361), False, 'from langchain.agents import create_csv_agent\n')]