Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data-Analysis bot for all the data analysis tasks #127

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Demo Video Link.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://drive.google.com/file/d/1WFIKclcQH5kTULKddP5UvWFSciUQUCP4/view?usp=sharing
39 changes: 39 additions & 0 deletions examples/data_analysis_bot/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from textbase import bot, Message
from typing import List
import pandas as pd
import matplotlib
matplotlib.use('agg')
from pandasai import PandasAI
import os
from pandasai.llm.openai import OpenAI


#os.environ['OPENAI_API_KEY']="sk-****"
df=pd.read_csv("C:/Users/varun/Documents/vscode python/USA_cars_datasets.csv") #sample csv file

@bot()
def on_message(message_history: List[Message], state: dict = None):

#read csv file as pandas dataframe when user uploads a file:- df=pd.read_csv("C:/Users/varun/Documents/vscode python/USA_cars_datasets.csv")

llm=OpenAI(temperature=0)
pandas_ai=PandasAI(llm=llm,conversational=True,save_charts=True)
res=pandas_ai.run(df,prompt=message_history[-1]["content"][0]["value"])
bot_response = [{"data_type":"STRING","value":str(res)}]

response = {
"data": {
"messages": bot_response,
"state": state
},
"errors": [
{
"message": ""
}
]
}

return {
"status_code": 200,
"response": response
}
4 changes: 4 additions & 0 deletions requirements.txt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pandas = "*"
pandasai="*"
matplotlib= "*"
bs4 = "^0.0.1"