File size: 1,000 Bytes
b42a568
 
ba0cd05
 
 
 
126e7b9
 
 
ba0cd05
 
 
 
 
 
 
b42a568
 
ba0cd05
 
b42a568
ba0cd05
 
b42a568
ba0cd05
 
 
b42a568
ba0cd05
 
b42a568
ba0cd05
b42a568
ba0cd05
 
 
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
35
36
import streamlit as st
import pandas as pd
from pandasai import SmartDataframe
from dotenv import load_dotenv
import os
from langchain_groq.chat_models import ChatGroq
import warnings
warnings.filterwarnings("ignore", message="numpy.dtype size changed")
warnings.filterwarnings("ignore", message="numpy.ufunc size changed")
# Load environment variables
load_dotenv()

# Initialize LLM
llm = ChatGroq(
    model_name="mixtral-8x7b-32768", 
    api_key=os.environ["GROQ_API_KEY"]
)

# Streamlit app
st.title("Interactive Data Analysis with Pandas AI and Groq")

# File uploader
uploaded_file = st.file_uploader("Choose a CSV file", type="csv")

if uploaded_file is not None:
    data = pd.read_csv(uploaded_file)
    st.write("### Data Preview", data.head())

    # Convert to SmartDataframe
    df = SmartDataframe(data, config={"llm": llm})

    query = st.text_input("Ask a question about the dataset")

    if st.button("Ask"):
        result = df.chat(query)
        st.write("### Result", result)