File size: 6,557 Bytes
b42b16e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c7f4c63
b42b16e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c1a66b8
b42b16e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225288b
dfbf8f6
 
 
225288b
dfbf8f6
 
 
 
 
 
 
 
bc4eb2f
 
 
b42b16e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d9da15c
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
import streamlit as st 
from streamlit_option_menu import option_menu
import openai
from streamlit_chat import message
#importation des librairies 
import pandas as pd

st.set_page_config(layout='wide')
st.markdown("""
        <style>
               .block-container {
                    padding-top: 2rem;
                    padding-bottom: 0rem;
                    padding-left: 1rem;
                    padding-right: 1rem;
                }
        </style>
        """, unsafe_allow_html=True)

openai.api_key = "sk-proj-RExBXqnjaTYCWwB3aQOOT3BlbkFJJf9S2nbyQj11VfArtjjo"
 
def api_calling(prompt):
    completions = openai.Completion.create(
        engine="gpt-3.5-turbo-instruct",
        prompt=prompt,
        max_tokens=1024,
        n=1,
        stop=None,
        temperature=0.5,
    )
    message = completions.choices[0].text
    return message
header , menu = st.columns(2)

with header:
    st.image('static/img/bot.PNG')

with menu:
    # option_menu(menu_title=None,
    #     options=['Visualisation','Prédiction'],
    #     icons=["house","book",'envelope'],
    #     default_index=0,
    #     orientation="horizontal"
    #     )
    selecte=option_menu(None, ["Accueil", "Se déconnecter"], 
    icons=['house', 'cloud-upload'], 
    menu_icon="cast", default_index=0, orientation="horizontal",
    styles={
        "container": {"padding": "0!important", "background-color": "#fafafa","font-family": "Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif"},
        "icon": {"color": "orange", "font-size": "25px" }, 
        "nav-link": {"font-size": "20px", "text-align": "left", "margin":"0px", "--hover-color": "#eee"},
        "nav-link-selected": {"background-color": "#70ad46","color":"white"},
        "menu-title":{"color":"#424143"}
    }
)
    

if selecte == "Accueil":
    st.title(f"Bienvenu au cours d'informatique de la classe de 3ieme")
    sect1_col1=st.container()
    sect1_col2 = st.container()
    

    with open('static/css/style.css') as f:
            st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
    with sect1_col1.container(height=700):

        st.selectbox("Quelle UE voulez-vous preparer?",("Architecture, Maintenance et taleur"))
        st.selectbox("De quel UA s'agit-il?",("Decrire les peripheriques","Decrire les logiciels","Assurer le bon fonctionnement de l'ordinateur","utiliser les fonctions d'un tableur"))
        if 'user_input' not in st.session_state:
            st.session_state['user_input'] = []
 
        if 'openai_response' not in st.session_state:
            st.session_state['openai_response'] = []
        
        def get_text():
            input_text = st.text_input("Quelles sont les objectifs du programme concerné?", key="input")
            return input_text
        
        user_input = get_text()
        
        if user_input:
            output = api_calling(user_input)
            output = output.lstrip("\n")
        
            # Store the output
            st.session_state.openai_response.append(user_input)
            st.session_state.user_input.append(output)
        
        message_history = st.empty()
        
        if st.session_state['user_input']:
            for i in range(len(st.session_state['user_input']) - 1, -1, -1):
                # This function displays user input
                message(st.session_state["user_input"][i], 
                        key=str(i),avatar_style="icons")
                # This function displays OpenAI response
                message(st.session_state['openai_response'][i], 
                        avatar_style="miniavs",is_user=True,
                        key=str(i) + 'data_by_user')

        
        st.markdown("""
        <style>
        # div[data-testid="stMetric"] {
        #     background-color: rgba(187, 216, 158, 0.59);
        #     border: 1px solid rgba(28, 131, 225, 0.1);
            padding:-10px;
        #     border-radius: 5px;
        #     color: rgb(30, 103, 119);
        #     overflow-wrap: break-word;
        #     font-weight:bold;
            
            
        # }
        
        [data-testid="stMetricValue"]{
            font-size: 45px;
            color: #2FB56B;
            font-weight:bold;
            text-align:center;
            margin-top:-33px;
            
            
            
        }

        /* breakline for metric text */
        [data-testid="stMetricLabel"] {
            word-wrap: break-word;
            color: #ef8451;
            font-size:40px;
            font-weight:bold;
                
            }
                    
                    
        [data-testid ="stVerticalBlock"]{
            #background-color: rgba(187, 216, 158, 0.59);
            #border: 1px solid rgba(28, 131, 225, 0.1);
            text-align:center;
        }
        [data-v-5af006b8]{
            background-color:black;
        }
        .st-emotion-cache-sr3x2q{
            width:80%;
            margin-left:10%;
            margin-right:10%;
            height: 50% !important;
        }
        .st-emotion-cache-7ym5gk{
            background-color: #70ad46;
            color:white;    
        }
        .st-emotion-cache-1jmvea6 p {
            font-size: 20px;
            color: black;
        }
        .st-emotion-cache-1jmvea6 p{
            font-size: 20px;
        }
        .st-emotion-cache-1wrcr25{
           background-color: #b1d1a0;
        }
        .st-emotion-cache-18ni7ap{
            background-color: #b1d1a0;
        }
        .st-emotion-cache-1yiq2ps{
            background-color: #b1d1a0;
        }
        </style>
    """
    , unsafe_allow_html=True)
    footer = st.container()
    with footer:
        st.markdown("---")
        st.markdown(
            """
            <style>
                p {
                    font-size: 16px;
                    text-align: center;
                }
                a {
                    text-decoration: none;
                    color: #00a;
                    font-weight: 600;
                }
            </style>
            <p>
                &copy; Designed by <a href="#"></a>.
            </p>
            """, unsafe_allow_html=True
            )


    
    

if selecte == "Données":
    


    st.title(f"Les Capteurs en NAIROBI,KENYA")
    st_folium(map,width=2000,height=600)
    st.title(f"DATA")
    moi = st.columns(1)
     
    placeholder = st.empty()
    df_all_concatenated_transform_daily= df_all_concatenated_transform_daily[df_all_concatenated_transform_daily["Moi"] ==moi_filtre]