irmakakin commited on
Commit
c48afa4
·
verified ·
1 Parent(s): 4fe3335

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -51
app.py CHANGED
@@ -11,57 +11,6 @@ theme_citrus = gr.themes.Citrus(
11
  neutral_hue="lime",
12
  )
13
 
14
- # Define the function to change the font based on the dropdown selection.
15
- def change_font(font):
16
- if font == "Open dyslexic":
17
- gr.HTML('''
18
- <style>
19
- @fontface {
20
- font-family: openDyslexic;
21
- src: url(Open_Dyslexic-Regular.otf);
22
- }
23
- body {
24
- font-family: openDyslexic;
25
- }
26
- <style/> ''')
27
- else:
28
- font_family = "Arial"
29
- return
30
- # Define the function to handle chatbot responses and maintain history.
31
- def echo_bot(user_input, history):
32
- history.append((user_input, user_input))
33
- return "", history
34
-
35
- # Create the Gradio app.
36
- with gr.Blocks(theme=theme_citrus) as demo:
37
-
38
-
39
- with gr.Row():
40
- with gr.Column(scale=1):
41
- # Dropdown menu for font selection.
42
- font_dropdown = gr.Dropdown(choices=["Open dyslexic", "Normal"], label="Select Font")
43
- apply_button = gr.Button("Apply Font")
44
- text_output = gr.Markdown("Sample text here")
45
- apply_button.click(fn=change_font, inputs=font_dropdown, outputs=text_output)
46
- with gr.Column(scale=19):
47
- # Image component.
48
- gr.Image('ecosphere.png')
49
-
50
- # Projects section.
51
- with gr.Row(scale=9):
52
- with gr.Column(scale=3):
53
- with gr.Group():
54
- gr.Markdown('GET INVOLVED')
55
- with gr.Group():
56
- gr.HTML('<a href="https://fridaysforfuture.org/" target="_blank">FRIDAYS FOR FUTURE</a>')
57
- gr.HTML('<a href="https://www.sunrisemovement.org/" target="_blank">SUNRISE MOVEMENT</a>')
58
- gr.HTML('<a href="https://thisiszerohour.org/" target="_blank">ZERO HOUR</a>')
59
- gr.Markdown('Outside the US')
60
- gr.HTML('<a href="https://community.youth4climate.info/homepage" target="_blank">Youth4Climate (EU)</a>')
61
- gr.HTML('<a href="https://www.instagram.com/fridaysforfuturemapa/?hl=de" target="_blank">Fridays for Future MAPA (Africa, Latin America, Asia-Pacific) </a>')
62
- with gr.Column(scale=7):
63
- gr.ChatInterface(respond, type="messages")
64
-
65
  #sustainability tips
66
  SUSTAINABILITY_TIPS = [
67
  "Bring your own: Carry a reusable water bottle, coffee cup, and shopping bag.",
@@ -171,6 +120,54 @@ def get_top_chunks(query, chunk_embeddings, text_chunks):
171
  relevant_info = cleaned_chunks[indices]
172
  top_chunks.append(relevant_info)
173
  return top_chunks
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
 
176
  demo.launch()
 
11
  neutral_hue="lime",
12
  )
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  #sustainability tips
15
  SUSTAINABILITY_TIPS = [
16
  "Bring your own: Carry a reusable water bottle, coffee cup, and shopping bag.",
 
120
  relevant_info = cleaned_chunks[indices]
121
  top_chunks.append(relevant_info)
122
  return top_chunks
123
+ # Define the function to change the font based on the dropdown selection.
124
+ def change_font(font):
125
+ if font == "Open dyslexic":
126
+ gr.HTML('''
127
+ <style>
128
+ @fontface {
129
+ font-family: openDyslexic;
130
+ src: url(Open_Dyslexic-Regular.otf);
131
+ }
132
+ body {
133
+ font-family: openDyslexic;
134
+ }
135
+ <style/> ''')
136
+ else:
137
+ font_family = "Arial"
138
+ return
139
+ # Define the function to handle chatbot responses and maintain history.
140
+ def echo_bot(user_input, history):
141
+ history.append((user_input, user_input))
142
+ return "", history
143
 
144
+ # Create the Gradio app.
145
+ with gr.Blocks(theme=theme_citrus) as demo:
146
+
147
+
148
+ with gr.Row():
149
+ with gr.Column(scale=1):
150
+ # Dropdown menu for font selection.
151
+ font_dropdown = gr.Dropdown(choices=["Open dyslexic", "Normal"], label="Select Font")
152
+ apply_button = gr.Button("Apply Font")
153
+ text_output = gr.Markdown("Sample text here")
154
+ apply_button.click(fn=change_font, inputs=font_dropdown, outputs=text_output)
155
+ with gr.Column(scale=19):
156
+ # Image component.
157
+ gr.Image('ecosphere.png')
158
+ # Projects section.
159
+ with gr.Row(scale=9):
160
+ with gr.Column(scale=3):
161
+ with gr.Group():
162
+ gr.Markdown('GET INVOLVED')
163
+ with gr.Group():
164
+ gr.HTML('<a href="https://fridaysforfuture.org/" target="_blank">FRIDAYS FOR FUTURE</a>')
165
+ gr.HTML('<a href="https://www.sunrisemovement.org/" target="_blank">SUNRISE MOVEMENT</a>')
166
+ gr.HTML('<a href="https://thisiszerohour.org/" target="_blank">ZERO HOUR</a>')
167
+ gr.Markdown('Outside the US')
168
+ gr.HTML('<a href="https://community.youth4climate.info/homepage" target="_blank">Youth4Climate (EU)</a>')
169
+ gr.HTML('<a href="https://www.instagram.com/fridaysforfuturemapa/?hl=de" target="_blank">Fridays for Future MAPA (Africa, Latin America, Asia-Pacific) </a>')
170
+ with gr.Column(scale=7):
171
+ gr.ChatInterface(respond, type="messages")
172
 
173
  demo.launch()