Spaces:
Sleeping
Sleeping
| 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) |