-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.py
34 lines (28 loc) · 914 Bytes
/
App.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pandas as pd
data = pd.read_csv("data.csv")
import json
from dotenv import load_dotenv
load_dotenv()
from langchain_groq.chat_models import ChatGroq
import os
llm = ChatGroq(
model_name="llama3-8b-8192",
api_key=os.environ["GROQ_API_KEY"]
)
from pandasai import SmartDataframe
df = SmartDataframe(data, config={"llm": llm})
def ai_interaction_loop():
print("AI Interaction Loop. Type 'exit' to quit.")
while True:
user_input = input("Enter your query (or type 'exit' to quit): ")
if user_input.lower() == 'exit':
break
else:
try:
# Interact with the SmartDataframe
response = df.chat(user_input)
print(f"{response}")
except Exception as e:
print(f"An error occurred: {e}")
# Start the AI interaction loop
ai_interaction_loop()