document_qna / app.py
ssumukh17's picture
Upload app.py
0078cce
raw
history blame
816 Bytes
import pandas as pd
from pandasai import SmartDataframe
from pandasai.llm import OpenAI
import os
from pandasai.llm import Starcoder, Falcon
import gradio as gr
from function import initiate_process
import tempfile
def chatbot(file_upload,message):
file_path = file_upload.name
print(file_path)
extention = file_path.split(".")[1]
print(extention)
output = initiate_process(file_path,extention,message)
if type(output) == str:
path = "/home/aiuser/sumukh/Analyze-Data/analyze_final/empty.jpg"
else:
path = "/home/aiuser/sumukh/Analyze-Data/analyze_final/temp_chart.png"
return output,path
demo = gr.Interface(fn=chatbot, inputs = ['file','text'], outputs = ['text','image'])
demo.queue(max_size=20)
demo.launch(server_name="0.0.0.0",server_port=7870,debug=True)