File size: 926 Bytes
3f026df
 
a627724
3f026df
 
 
9fc36aa
e446843
2a4df7b
3f026df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
import torch
from transformers import pipeline
from pandasai import SmartDataframe

#llm =  pipeline("text-generation", model="microsoft/Phi-3-mini-128k-instruct", trust_remote_code=True)
#llm = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
llm = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")

st.title("Data Analysis with Pandas AI")

uploader_file = st.file_uploader("Upload a excel file", type = ["xlsx"] )

if uploader_file is not None:
    data = pd.read_excel(uploader_file)
    st.write(data.head(3))
    df = SmartDataframe(data, config={"llm": llm})
    prompt = st.text_area("Enter your Prompt:")

    if st.button("Generate"):
        if prompt:
            with st.spinner("Generative response ...."):
                st.write(df.chat(prompt))
        else:
            st.warning("Please enter a Prompt")