Pijush2023 commited on
Commit
ee7a3d2
·
verified ·
1 Parent(s): fd9c54a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -176
app.py CHANGED
@@ -147,74 +147,7 @@ def fetch_local_events():
147
  else:
148
  return "<p>Failed to fetch local events</p>"
149
 
150
- # def fetch_local_weather():
151
- # try:
152
- # api_key = os.environ['WEATHER_API']
153
- # url = f'https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/omaha?unitGroup=metric&include=events%2Calerts%2Chours%2Cdays%2Ccurrent&key={api_key}'
154
- # response = requests.get(url)
155
- # response.raise_for_status()
156
- # jsonData = response.json()
157
-
158
- # current_conditions = jsonData.get("currentConditions", {})
159
- # temp_celsius = current_conditions.get("temp", "N/A")
160
-
161
- # if temp_celsius != "N/A":
162
- # temp_fahrenheit = int((temp_celsius * 9/5) + 32)
163
- # else:
164
- # temp_fahrenheit = "N/A"
165
-
166
- # condition = current_conditions.get("conditions", "N/A")
167
- # humidity = current_conditions.get("humidity", "N/A")
168
-
169
- # weather_html = f"""
170
- # <div class="weather-theme">
171
- # <h2 style="font-family: 'Georgia', serif; color: #4CAF50; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Local Weather</h2>
172
- # <div class="weather-content">
173
- # <div class="weather-icon">
174
- # <img src="https://www.weatherbit.io/static/img/icons/{get_weather_icon(condition)}.png" alt="{condition}" style="width: 100px; height: 100px;">
175
- # </div>
176
- # <div class="weather-details">
177
- # <p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Temperature: {temp_fahrenheit}°F</p>
178
- # <p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Condition: {condition}</p>
179
- # <p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Humidity: {humidity}%</p>
180
- # </div>
181
- # </div>
182
- # </div>
183
- # <style>
184
- # .weather-theme {{
185
- # animation: backgroundAnimation 10s infinite alternate;
186
- # border: 1px solid #ddd;
187
- # border-radius: 10px;
188
- # padding: 10px;
189
- # margin-bottom: 15px;
190
- # background: linear-gradient(45deg, #ffcc33, #ff6666, #ffcc33, #ff6666);
191
- # background-size: 400% 400%;
192
- # box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
193
- # transition: box-shadow 0.3s ease, background-color 0.3s ease;
194
- # }}
195
- # .weather-theme:hover {{
196
- # box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
197
- # background-position: 100% 100%;
198
- # }}
199
- # @keyframes backgroundAnimation {{
200
- # 0% {{ background-position: 0% 50%; }}
201
- # 100% {{ background-position: 100% 50%; }}
202
- # }}
203
- # .weather-content {{
204
- # display: flex;
205
- # align-items: center;
206
- # }}
207
- # .weather-icon {{
208
- # flex: 1;
209
- # }}
210
- # .weather-details {{
211
- # flex: 3;
212
- # }}
213
- # </style>
214
- # """
215
- # return weather_html
216
- # except requests.exceptions.RequestException as e:
217
- # return f"<p>Failed to fetch local weather: {e}</p>"
218
  def fetch_local_weather():
219
  try:
220
  api_key = os.environ['WEATHER_API']
@@ -674,111 +607,3 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
674
  demo.queue()
675
  demo.launch(share=True)
676
 
677
- #**************************************************************************************************************************************************************************
678
- # def setup_ui():
679
- # state = gr.State()
680
- # with gr.Row():
681
- # with gr.Column():
682
- # gr.Markdown("<h1>Select Style</h1>", elem_id="prompt-markdown")
683
- # choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
684
- # with gr.Column(): # Larger scale for the right column
685
- # gr.Markdown("<h1>Ask Radar !!!</h1>", elem_id="query-markdown")
686
-
687
- #chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!")
688
- #chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input])
689
- # bot_msg = chat_msg.then(bot, [chatbot, choice], [chatbot, gr.Audio(interactive=False, autoplay=True)])
690
- # bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
691
- # chatbot.like(print_like_dislike, None, None)
692
- # clear_button = gr.Button("Clear")
693
- # clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
694
-
695
- # with gr.Column(): # Smaller scale for the left column
696
- # gr.Markdown("<h1>Talk to RADAR</h1>", elem_id="voice-markdown")
697
- # audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
698
- # audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="SAMLOne_real_time")
699
-
700
- # with gr.Row():
701
- # with gr.Column():
702
- # gr.Markdown("<h1>Map</h1>", elem_id="location-markdown")
703
- # location_output = gr.HTML()
704
- # bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output])
705
-
706
- # do not uncomment
707
- # with gr.Column():
708
- # gr.Markdown("<h1>Listen to the audio</h1>", elem_id="audio-markdown")
709
- # audio_output = gr.Audio()
710
- # bot_msg_audio = bot_msg.then(lambda history: generate_audio_elevenlabs(history[-1][1]), chatbot, audio_output)
711
- # with gr.Row():
712
-
713
- # with gr.Column():
714
- # gr.Markdown("<h1>Suggested Events</h1>", elem_id="events-markdown")
715
- # news_output = gr.HTML(value=fetch_local_events())
716
-
717
- # with gr.Column():
718
-
719
-
720
- # setup_ui()
721
-
722
- # with gr.Blocks(theme='rawrsor1/Everforest') as demo:
723
- # with gr.Row():
724
- # with gr.Column(scale=2):
725
- # chatbot = gr.Chatbot([], elem_id="chatbot", bubble_full_width=False)
726
-
727
- # with gr.Column(scale=1):
728
- # gr.Markdown("<h1>Weather</h1>", elem_id="weather-sponsored-section")
729
- # weather_output = gr.HTML(value=fetch_local_weather())
730
- # with gr.Column(scale=1):
731
- # gr.Markdown("<h2>Sponsored</h2>", elem_id="image-markdown")
732
- # image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=300, height=300)
733
- # image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=300, height=300)
734
- # image_output_3 = gr.Image(value=generate_image(hardcoded_prompt_3), width=300, height=300)
735
-
736
- # def setup_ui():
737
- # state = gr.State()
738
- # with gr.Row():
739
- # with gr.Column(scale=1):
740
- # gr.Markdown("<h1>Select Style</h1>", elem_id="prompt-markdown")
741
- # choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
742
-
743
- # with gr.Column(scale=2): # Larger scale for the right column
744
- # gr.Markdown("<h1>Ask Radar !!!</h1>", elem_id="query-markdown")
745
- # chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!")
746
- # chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input])
747
- # bot_msg = chat_msg.then(bot, [chatbot, choice], [chatbot, gr.Audio(interactive=False, autoplay=True)])
748
- # bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
749
- # chatbot.like(print_like_dislike, None, None)
750
- # clear_button = gr.Button("Clear")
751
- # clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
752
-
753
- # with gr.Column(scale=1):
754
- # gr.Markdown("<h1>Talk to RADAR</h1>", elem_id="voice-markdown")
755
- # audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
756
- # audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="SAMLOne_real_time")
757
-
758
- # with gr.Row():
759
- # with gr.Column(scale=1):
760
- # gr.Markdown("<h1>Map</h1>", elem_id="location-markdown")
761
- # location_output = gr.HTML()
762
- # bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output])
763
-
764
- # with gr.Row():
765
- # with gr.Column(scale=1):
766
- # gr.Markdown("<h1>Suggested Events</h1>", elem_id="events-markdown")
767
- # events_output = gr.HTML(value=fetch_local_events())
768
-
769
- # with gr.Column(scale=1):
770
- # gr.Markdown("<h1>Omaha Today Headlines</h1>", elem_id="news-markdown")
771
- # news_output = gr.HTML(value=fetch_local_news())
772
-
773
- # setup_ui()
774
-
775
- # demo.queue()
776
- # demo.launch(share=True)
777
-
778
- #*************************************************************************************************************************************************************************
779
-
780
-
781
-
782
-
783
-
784
-
 
147
  else:
148
  return "<p>Failed to fetch local events</p>"
149
 
150
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  def fetch_local_weather():
152
  try:
153
  api_key = os.environ['WEATHER_API']
 
607
  demo.queue()
608
  demo.launch(share=True)
609