File size: 5,137 Bytes
bdbcb36
 
5d54c7e
bdbcb36
f17eb40
bdbcb36
 
f17eb40
ce8c2d2
f17eb40
 
71a77a6
77e357b
28003f3
 
 
bdbcb36
 
8bc932f
bdbcb36
 
ae8b5c2
31bf486
f17eb40
bc01de5
bdbcb36
 
 
f5b8aa7
 
 
369e5bc
babb003
df37481
 
634fbf2
babb003
bdbcb36
 
 
bee6540
6da491c
bee6540
6da491c
 
bee6540
 
6da491c
 
c85aadf
3a2ad41
 
df37481
634fbf2
 
d5b2d5a
634fbf2
 
 
48ff132
 
98eaec6
bee6540
6da491c
bdbcb36
 
 
 
df37481
634fbf2
df37481
01b139c
 
 
 
 
827278a
3c8df63
 
 
98eaec6
3c8df63
 
 
 
 
bdbcb36
 
 
 
 
 
 
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import streamlit as st
import os
import time
import pandas as pd
from pandasai import SmartDatalake
from pandasai import SmartDataframe
from pandasai.responses.streamlit_response import StreamlitResponse
import numpy as np
#from pandasai import Agent
import json
import matplotlib.pyplot as plt



os.environ['PANDASAI_API_KEY'] = "$2a$10$2s0v3C29vItNS2CO4QX10OV51/OONFCUNa4e9EU90w2Gozw88f4vK"
st.set_page_config(page_title="SAP Data Analysis", layout="wide")
st.image('Pandas-AI-Logo.png', caption=None)
uploaded_file = st.file_uploader("Upload CSV data for analysis", type=['csv'])

df1 = ""
sdf = ""
data = [{"Feb 24":"","1.":"Do","2.":"Fr","3.":"Sa","4.":"So","5.":"Mo","6.":"Di","7.":"Mi","8.":"Do","9.":"Fr","10.":"Sa","11.":"So","12.":"Mo","13.":"Di","14.":"Mi","15.":"Do","16.":"Fr","17.":"Sa","18.":"So","19.":"Mo","20.":"Di","21.":"Mi","22.":"Do","23.":"Fr","24.":"Sa","25.":"So","26.":"Mo","27.":"Di","28.":"Mi","29.":"Do"},{"Feb 24":"Standke Steffen","1.":"F","2.":"F","3.":"","4.":"","5.":"","6.":"","7.":"","8.":"","9.":"","10.":"","11.":"","12.":"","13.":"","14.":"UA","15.":"UA","16.":"","17.":"SD","18.":"SD","19.":"","20.":"","21.":"","22.":"","23.":"","24.":"","25.":"","26.":"","27.":"","28.":"","29.":""},{"Feb 24":"Will Susanne","1.":"","2.":"TZ","3.":"","4.":"","5.":"UA","6.":"","7.":"","8.":"","9.":"TZ","10.":"","11.":"","12.":"","13.":"","14.":"","15.":"","16.":"TZ","17.":"","18.":"","19.":"","20.":"","21.":"","22.":"","23.":"TZ","24.":"","25.":"","26.":"","27.":"","28.":"","29.":""},{"Feb 24":"Raab Julia","1.":"TZ","2.":"TZ","3.":"","4.":"","5.":"","6.":"","7.":"","8.":"TZ","9.":"TZ","10.":"BLOCKER","11.":"","12.":"Ü","13.":"Ü","14.":"Ü","15.":"TZ","16.":"TZ","17.":"BLOCKER","18.":"","19.":"","20.":"","21.":"","22.":"TZ","23.":"TZ","24.":"","25.":"SD","26.":"","27.":"","28.":"","29.":"TZ"},{"Feb 24":"Eckert Marion","1.":"","2.":"","3.":"","4.":"","5.":"","6.":"","7.":"","8.":"","9.":"Ü","10.":"","11.":"","12.":"S","13.":"S","14.":"S","15.":"S","16.":"S","17.":"","18.":"","19.":"","20.":"","21.":"","22.":"","23.":"","24.":"","25.":"","26.":"S","27.":"S","28.":"S","29.":"S"},{"Feb 24":"Meder, Milena","1.":"","2.":"","3.":"","4.":"","5.":"","6.":"","7.":"","8.":"","9.":"","10.":"","11.":"","12.":"F","13.":"F","14.":"","15.":"F","16.":"F","17.":"","18.":"","19.":"","20.":"","21.":"","22.":"","23.":"","24.":"","25.":"","26.":"Voloreise","27.":"","28.":"","29.":""},{"Feb 24":"Despang Angelika","1.":"","2.":"","3.":"SD","4.":"","5.":"","6.":"","7.":"","8.":"","9.":"","10.":"","11.":"","12.":"UA","13.":"UA","14.":"UA","15.":"","16.":"","17.":"","18.":"","19.":"F","20.":"F","21.":"F","22.":"F","23.":"F","24.":"","25.":"","26.":"","27.":"","28.":"","29.":""},{"Feb 24":"Heike Beudert","1.":"TZ","2.":"0,5 U","3.":"","4.":"","5.":"TZ","6.":"","7.":"","8.":"","9.":"","10.":"SD","11.":"SD","12.":"UA","13.":"UA","14.":"TZ","15.":"TZ","16.":"TZ","17.":"","18.":"","19.":"TZ","20.":"TZ","21.":"TZ","22.":"TZ","23.":"TZ","24.":"","25.":"","26.":"F","27.":"F","28.":"F","29.":"F"},{"Feb 24":"Borst Benedikt","1.":"","2.":"","3.":"","4.":"SD","5.":"F","6.":"F","7.":"F","8.":"F","9.":"F","10.":"BLOCKER","11.":"","12.":"UA","13.":"UA","14.":"F","15.":"","16.":"","17.":"","18.":"","19.":"","20.":"","21.":"","22.":"","23.":"","24.":"BLOCKER","25.":"","26.":"","27.":"","28.":"","29.":""}]
df1 = pd.DataFrame(data)
#df

if uploaded_file is not None:

    df1 = pd.read_csv(uploaded_file)
    #st.table(df1)
    df1 = pd.DataFrame(df1)
    df1
    sdf = SmartDataframe(df1)

bild = st.empty()     
bild.subheader("Datenanalyse & Datenvisualisierung")
c = st.container(border=True)
prompt = st.text_area("Enter your prompt:")
if st.button("Generate"):

        if prompt:
            #c.text("Generating response...") 
            with st.spinner("Generating response..."):
            #spin = st.spinner
                with bild:
                    #with st.spinner("Generating response..."):
                    bar = st.progress(20)
                    #time.sleep(5)
                    sdf.chat(prompt)
                    st.success('Done!')
            
                #c.write(bar)
                #c.write(st.spinner)
                #bild.empty()
            if os.path.isfile('./exports/charts/temp_chart.png'):
                    # Löschen Sie die Datei
                os.remove('./exports/charts/temp_chart.png')
            bild.write(sdf.chat(prompt)) 
                
            if os.path.isfile('./exports/charts/temp_chart.png'):
                with bild:
                    st.image('./exports/charts/temp_chart.png',caption=None)
                #st.write(sdf.chat(prompt))            
            #bar.progress(100)
            

        else:

            st.error("Please enter a prompt.")



#with placeholder.container():
    #st.write("This is one element")
    #st.write("This is another")



#agent = Agent(df)
#result = agent.chat("erstelle balkendiagramm")
#st.write(result)
#sdf = SmartDataframe(df)
#sdf.chat("draw chart")
#pandas_ai = PandasAI(llm, verbose=True, save_charts=True)
#st.write(sdf.chat("Plot a chart"))
#st.write(st.bar_chart(data))