├── requirements.txt ├── README.md └── app.py /requirements.txt: -------------------------------------------------------------------------------- 1 | pandas 2 | pandasai 3 | streamlit 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Mutiple CSV Chat APP using Ollama,llama3 and PandasAI(FULLY LOCAL) 2 | image 3 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from pandasai.llm.local_llm import LocalLLM ## Importing LocalLLM for local Meta Llama 3 model 2 | import streamlit as st 3 | import pandas as pd # Pandas for data manipulation 4 | from pandasai import SmartDataframe # SmartDataframe for interacting with data using LLM 5 | 6 | 7 | 8 | # Function to chat with CSV data 9 | def chat_with_csv(df,query): 10 | # Initialize LocalLLM with Meta Llama 3 model 11 | llm = LocalLLM( 12 | api_base="http://localhost:11434/v1", 13 | model="llama3") 14 | # Initialize SmartDataframe with DataFrame and LLM configuration 15 | pandas_ai = SmartDataframe(df, config={"llm": llm}) 16 | # Chat with the DataFrame using the provided query 17 | result = pandas_ai.chat(query) 18 | return result 19 | 20 | # Set layout configuration for the Streamlit page 21 | st.set_page_config(layout='wide') 22 | # Set title for the Streamlit application 23 | st.title("Multiple-CSV ChatApp powered by LLM") 24 | 25 | # Upload multiple CSV files 26 | input_csvs = st.sidebar.file_uploader("Upload your CSV files", type=['csv'], accept_multiple_files=True) 27 | 28 | # Check if CSV files are uploaded 29 | if input_csvs: 30 | # Select a CSV file from the uploaded files using a dropdown menu 31 | selected_file = st.selectbox("Select a CSV file", [file.name for file in input_csvs]) 32 | selected_index = [file.name for file in input_csvs].index(selected_file) 33 | 34 | #load and display the selected csv file 35 | st.info("CSV uploaded successfully") 36 | data = pd.read_csv(input_csvs[selected_index]) 37 | st.dataframe(data.head(3),use_container_width=True) 38 | 39 | #Enter the query for analysis 40 | st.info("Chat Below") 41 | input_text = st.text_area("Enter the query") 42 | 43 | #Perform analysis 44 | if input_text: 45 | if st.button("Chat with csv"): 46 | st.info("Your Query: "+ input_text) 47 | result = chat_with_csv(data,input_text) 48 | st.success(result) 49 | 50 | 51 | 52 | 53 | 54 | --------------------------------------------------------------------------------