Pijush2023 commited on
Commit
3ae1693
·
verified ·
1 Parent(s): 9323902

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -528
app.py CHANGED
@@ -24,10 +24,7 @@ from langchain.agents import Tool, initialize_agent
24
  from huggingface_hub import login
25
 
26
 
27
- import requests
28
- from requests_oauthlib import OAuth2Session
29
- from oauthlib.oauth2 import BackendApplicationClient
30
- import os
31
 
32
  # Check if the token is already set in the environment variables
33
  hf_token = os.getenv("HF_TOKEN")
@@ -837,26 +834,6 @@ def update_images():
837
  return image_1, image_2, image_3
838
 
839
 
840
- # OAuth 2.0 endpoints for Google
841
- authorization_base_url = 'https://accounts.google.com/o/oauth2/auth'
842
- token_url = 'https://accounts.google.com/o/oauth2/token'
843
- scope = ['https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/userinfo.email']
844
-
845
- GOOGLE_CLIENT_ID=os.environ(['GOOGLE_CLIENT_ID'])
846
-
847
- # Function to initiate the OAuth flow
848
- def login():
849
- google = OAuth2Session(GOOGLE_CLIENT_ID, scope=scope, redirect_uri=REDIRECT_URI)
850
- authorization_url, state = google.authorization_url(authorization_base_url, access_type="offline", prompt="select_account")
851
- return f'<a href="{authorization_url}" target="_self">Login with Google</a>'
852
-
853
- # Function to handle the callback
854
- def oauth_callback(url):
855
- google = OAuth2Session(GOOGLE_CLIENT_ID, redirect_uri=REDIRECT_URI, scope=scope)
856
- google.fetch_token(token_url, client_secret=GOOGLE_CLIENT_SECRET, authorization_response=url)
857
- userinfo = google.get('https://www.googleapis.com/oauth2/v1/userinfo').json()
858
- return f"Logged in as: {userinfo['name']} ({userinfo['email']})"
859
-
860
 
861
  with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
862
 
@@ -898,511 +875,8 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
898
 
899
  refresh_button = gr.Button("Refresh Images")
900
  refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
901
- with gr.Column():
902
- login_button = gr.HTML(login)
903
- oauth_callback_url = gr.Textbox(label="Callback URL")
904
- user_info = gr.HTML()
905
-
906
- oauth_callback_url.submit(oauth_callback, inputs=[oauth_callback_url], outputs=[user_info])
907
  demo.queue()
908
  demo.launch(share=True)
909
 
910
 
911
- # import os
912
- # import re
913
- # import time
914
- # import requests
915
- # import logging
916
- # import folium
917
- # import gradio as gr
918
- # import tempfile
919
- # import torch
920
- # from datetime import datetime
921
- # import numpy as np
922
- # from gtts import gTTS
923
- # from googlemaps import Client as GoogleMapsClient
924
- # import concurrent.futures
925
- # from PIL import Image
926
- # from huggingface_hub import login
927
-
928
- # # Check if the token is already set in the environment variables
929
- # hf_token = os.getenv("HF_TOKEN")
930
-
931
- # if hf_token is None:
932
- # # If the token is not set, prompt for it (this should be done securely)
933
- # print("Please set your Hugging Face token in the environment variables.")
934
- # else:
935
- # # Login using the token
936
- # login(token=hf_token)
937
-
938
- # # Your application logic goes here
939
- # print("Logged in successfully to Hugging Face Hub!")
940
-
941
- # # Set up logging
942
- # logging.basicConfig(level=logging.DEBUG)
943
-
944
- # # Initialize OpenAI embeddings
945
- # from langchain_openai import OpenAIEmbeddings, ChatOpenAI
946
- # from langchain_pinecone import PineconeVectorStore
947
- # from langchain.prompts import PromptTemplate
948
- # from langchain.chains import RetrievalQA
949
- # from langchain.chains.conversation.memory import ConversationBufferWindowMemory
950
- # from langchain.agents import Tool, initialize_agent
951
-
952
- # embeddings = OpenAIEmbeddings(api_key=os.environ['OPENAI_API_KEY'])
953
-
954
- # # Initialize Pinecone
955
- # from pinecone import Pinecone
956
- # pc = Pinecone(api_key=os.environ['PINECONE_API_KEY'])
957
-
958
- # index_name = "omaha-details"
959
- # vectorstore = PineconeVectorStore(index_name=index_name, embedding=embeddings)
960
- # retriever = vectorstore.as_retriever(search_kwargs={'k': 5})
961
-
962
- # chat_model = ChatOpenAI(api_key=os.environ['OPENAI_API_KEY'], temperature=0, model='gpt-4o')
963
-
964
- # conversational_memory = ConversationBufferWindowMemory(
965
- # memory_key='chat_history',
966
- # k=10,
967
- # return_messages=True
968
- # )
969
-
970
- # # Define function to get current time and date
971
- # def get_current_time_and_date():
972
- # now = datetime.now()
973
- # return now.strftime("%Y-%m-%d %H:%M:%S")
974
-
975
- # current_time_and_date = get_current_time_and_date()
976
-
977
- # # Define functions for fetching events, weather, and news
978
- # def fetch_local_events():
979
- # api_key = os.environ['SERP_API']
980
- # url = f'https://serpapi.com/search.json?engine=google_events&q=Events+in+Omaha&hl=en&gl=us&api_key={api_key}'
981
- # response = requests.get(url)
982
- # if response.status_code == 200:
983
- # events_results = response.json().get("events_results", [])
984
- # events_html = """
985
- # <h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Local Events</h2>
986
- # <style>
987
- # .event-item {
988
- # font-family: 'Verdana', sans-serif;
989
- # color: #333;
990
- # margin-bottom: 15px;
991
- # padding: 10px;
992
- # font-weight: bold;
993
- # }
994
- # .event-item a {
995
- # color: #1E90FF;
996
- # text-decoration: none;
997
- # }
998
- # .event-item a:hover {
999
- # text-decoration: underline;
1000
- # }
1001
- # </style>
1002
- # """
1003
- # for index, event in enumerate(events_results):
1004
- # title = event.get("title", "No title")
1005
- # date = event.get("date", "No date")
1006
- # location = event.get("address", "No location")
1007
- # link = event.get("link", "#")
1008
- # events_html += f"""
1009
- # <div class="event-item">
1010
- # <a href='{link}' target='_blank'>{index + 1}. {title}</a>
1011
- # <p>Date: {date}<br>Location: {location}</p>
1012
- # </div>
1013
- # """
1014
- # return events_html
1015
- # else:
1016
- # return "<p>Failed to fetch local events</p>"
1017
-
1018
- # def fetch_local_weather():
1019
- # try:
1020
- # api_key = os.environ['WEATHER_API']
1021
- # url = f'https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/omaha?unitGroup=metric&include=events%2Calerts%2Chours%2Cdays%2Ccurrent&key={api_key}'
1022
- # response = requests.get(url)
1023
- # response.raise_for_status()
1024
- # jsonData = response.json()
1025
- # current_conditions = jsonData.get("currentConditions", {})
1026
- # temp_celsius = current_conditions.get("temp", "N/A")
1027
- # if temp_celsius != "N/A":
1028
- # temp_fahrenheit = int((temp_celsius * 9/5) + 32)
1029
- # else:
1030
- # temp_fahrenheit = "N/A"
1031
- # condition = current_conditions.get("conditions", "N/A")
1032
- # humidity = current_conditions.get("humidity", "N/A")
1033
-
1034
- # weather_html = f"""
1035
- # <div class="weather-theme">
1036
- # <h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Local Weather</h2>
1037
- # <div class="weather-content">
1038
- # <div class="weather-icon">
1039
- # <img src="https://www.weatherbit.io/static/img/icons/{get_weather_icon(condition)}.png" alt="{condition}" style="width: 100px; height: 100px;">
1040
- # </div>
1041
- # <div class="weather-details">
1042
- # <p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Temperature: {temp_fahrenheit}°F</p>
1043
- # <p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Condition: {condition}</p>
1044
- # <p style="font-family: 'Verdana', sans-serif; color: #333; font-size: 1.2em;">Humidity: {humidity}%</p>
1045
- # </div>
1046
- # </div>
1047
- # </div>
1048
- # <style>
1049
- # .weather-theme {{
1050
- # animation: backgroundAnimation 10s infinite alternate;
1051
- # border-radius: 10px;
1052
- # padding: 10px;
1053
- # margin-bottom: 15px;
1054
- # background: linear-gradient(45deg, #ffcc33, #ff6666, #ffcc33, #ff6666);
1055
- # background-size: 400% 400%;
1056
- # box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
1057
- # transition: box-shadow 0.3s ease, background-color 0.3s ease;
1058
- # }}
1059
- # .weather-theme:hover {{
1060
- # box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
1061
- # background-position: 100% 100%;
1062
- # }}
1063
- # @keyframes backgroundAnimation {{
1064
- # 0% {{ background-position: 0% 50%; }}
1065
- # 100% {{ background-position: 100% 50%; }}
1066
- # }}
1067
- # .weather-content {{
1068
- # display: flex;
1069
- # align-items: center;
1070
- # }}
1071
- # .weather-icon {{
1072
- # flex: 1;
1073
- # }}
1074
- # .weather-details {{
1075
- # flex: 3;
1076
- # }}
1077
- # </style>
1078
- # """
1079
- # return weather_html
1080
- # except requests.exceptions.RequestException as e:
1081
- # return f"<p>Failed to fetch local weather: {e}</p>"
1082
-
1083
- # def get_weather_icon(condition):
1084
- # condition_map = {
1085
- # "Clear": "c01d",
1086
- # "Partly Cloudy": "c02d",
1087
- # "Cloudy": "c03d",
1088
- # "Overcast": "c04d",
1089
- # "Mist": "a01d",
1090
- # "Patchy rain possible": "r01d",
1091
- # "Light rain": "r02d",
1092
- # "Moderate rain": "r03d",
1093
- # "Heavy rain": "r04d",
1094
- # "Snow": "s01d",
1095
- # "Thunderstorm": "t01d",
1096
- # "Fog": "a05d",
1097
- # }
1098
- # return condition_map.get(condition, "c04d")
1099
-
1100
- # def fetch_local_news():
1101
- # api_key = os.environ['SERP_API']
1102
- # url = f'https://serpapi.com/search.json?engine=google_news&q=omaha headline&api_key={api_key}'
1103
- # response = requests.get(url)
1104
- # if response.status_code == 200:
1105
- # results = response.json().get("news_results", [])
1106
- # news_html = """
1107
- # <h2 style="font-family: 'Georgia', serif; color: #ff0000; background-color: #f8f8f8; padding: 10px; border-radius: 10px;">Omaha Today</h2>
1108
- # <style>
1109
- # .news-item {
1110
- # font-family: 'Verdana', sans-serif;
1111
- # color: #333;
1112
- # background-color: #f0f8ff;
1113
- # margin-bottom: 15px;
1114
- # padding: 10px;
1115
- # border-radius: 5px;
1116
- # transition: box-shadow 0.3s ease, background-color 0.3s ease;
1117
- # font-weight: bold;
1118
- # }
1119
- # .news-item:hover {
1120
- # box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
1121
- # background-color: #e6f7ff;
1122
- # }
1123
- # .news-item a {
1124
- # color: #1E90FF;
1125
- # text-decoration: none;
1126
- # font-weight: bold;
1127
- # }
1128
- # .news-item a:hover {
1129
- # text-decoration: underline;
1130
- # }
1131
- # .news-preview {
1132
- # position: absolute;
1133
- # display: none;
1134
- # border: 1px solid #ccc;
1135
- # border-radius: 5px;
1136
- # box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
1137
- # background-color: white;
1138
- # z-index: 1000;
1139
- # max-width: 300px;
1140
- # padding: 10px;
1141
- # font-family: 'Verdana', sans-serif;
1142
- # color: #333;
1143
- # }
1144
- # </style>
1145
- # <script>
1146
- # function showPreview(event, previewContent) {
1147
- # var previewBox = document.getElementById('news-preview');
1148
- # previewBox.innerHTML = previewContent;
1149
- # previewBox.style.left = event.pageX + 'px';
1150
- # previewBox.style.top = event.pageY + 'px';
1151
- # previewBox.style.display = 'block';
1152
- # }
1153
- # function hidePreview() {
1154
- # var previewBox = document.getElementById('news-preview');
1155
- # previewBox.style.display = 'none';
1156
- # }
1157
- # </script>
1158
- # <div id="news-preview" class="news-preview"></div>
1159
- # """
1160
- # for index, result in enumerate(results[:7]):
1161
- # title = result.get("title", "No title")
1162
- # link = result.get("link", "#")
1163
- # snippet = result.get("snippet", "")
1164
- # news_html += f"""
1165
- # <div class="news-item" onmouseover="showPreview(event, '{snippet}')" onmouseout="hidePreview()">
1166
- # <a href='{link}' target='_blank'>{index + 1}. {title}</a>
1167
- # <p>{snippet}</p>
1168
- # </div>
1169
- # """
1170
- # return news_html
1171
- # else:
1172
- # return "<p>Failed to fetch local news</p>"
1173
-
1174
- # # Define prompt templates
1175
- # template1 = """You are an expert concierge who is helpful and a renowned guide for Omaha, Nebraska. Based on weather being a sunny bright day and today's date is 20th June 2024, use the following pieces of context,
1176
- # memory, and message history, along with your knowledge of perennial events in Omaha, Nebraska, to answer the question at the end. If you don't know the answer, just say "Homie, I need to get more data for this," and don't try to make up an answer.
1177
- # Use fifteen sentences maximum. Keep the answer as detailed as possible. Always include the address, time, date, and
1178
- # event type and description. Always say "It was my pleasure!" at the end of the answer.
1179
- # {context}
1180
- # Question: {question}
1181
- # Helpful Answer:"""
1182
-
1183
- # template2 = """You are an expert concierge who is helpful and a renowned guide for Omaha, Nebraska. Based on today's weather being a sunny bright day and today's date is 20th June 2024, take the location or address but don't show the location or address on the output prompts. Use the following pieces of context,
1184
- # memory, and message history, along with your knowledge of perennial events in Omaha, Nebraska, to answer the question at the end. If you don't know the answer, just say "Homie, I need to get more data for this," and don't try to make up an answer.
1185
- # Keep the answer short and sweet and crisp. Always say "It was my pleasure!" at the end of the answer.
1186
- # {context}
1187
- # Question: {question}
1188
- # Helpful Answer:"""
1189
-
1190
- # QA_CHAIN_PROMPT_1 = PromptTemplate(input_variables=["context", "question"], template=template1)
1191
- # QA_CHAIN_PROMPT_2 = PromptTemplate(input_variables=["context", "question"], template=template2)
1192
-
1193
- # def build_qa_chain(prompt_template):
1194
- # qa_chain = RetrievalQA.from_chain_type(
1195
- # llm=chat_model,
1196
- # chain_type="stuff",
1197
- # retriever=retriever,
1198
- # chain_type_kwargs={"prompt": prompt_template}
1199
- # )
1200
- # tools = [
1201
- # Tool(
1202
- # name='Knowledge Base',
1203
- # func=qa_chain,
1204
- # description='Use this tool when answering general knowledge queries to get more information about the topic'
1205
- # )
1206
- # ]
1207
- # return qa_chain, tools
1208
-
1209
- # def initialize_agent_with_prompt(prompt_template):
1210
- # qa_chain, tools = build_qa_chain(prompt_template)
1211
- # agent = initialize_agent(
1212
- # agent='chat-conversational-react-description',
1213
- # tools=tools,
1214
- # llm=chat_model,
1215
- # verbose=False,
1216
- # max_iteration=5,
1217
- # early_stopping_method='generate',
1218
- # memory=conversational_memory
1219
- # )
1220
- # return agent
1221
-
1222
- # def generate_answer(message, choice):
1223
- # logging.debug(f"generate_answer called with prompt_choice: {choice}")
1224
- # if choice == "Details":
1225
- # agent = initialize_agent_with_prompt(QA_CHAIN_PROMPT_1)
1226
- # elif choice == "Conversational":
1227
- # agent = initialize_agent_with_prompt(QA_CHAIN_PROMPT_2)
1228
- # else:
1229
- # logging.error(f"Invalid prompt_choice: {choice}. Defaulting to 'Conversational'")
1230
- # agent = initialize_agent_with_prompt(QA_CHAIN_PROMPT_2)
1231
- # response = agent(message)
1232
- # addresses = extract_addresses(response['output'])
1233
- # return response['output'], addresses
1234
-
1235
- # def bot(history, choice):
1236
- # if not history:
1237
- # return history
1238
- # response, addresses = generate_answer(history[-1][0], choice)
1239
- # history[-1][1] = ""
1240
- # with concurrent.futures.ThreadPoolExecutor() as executor:
1241
- # audio_future = executor.submit(generate_audio_elevenlabs, response)
1242
- # for character in response:
1243
- # history[-1][1] += character
1244
- # time.sleep(0.05)
1245
- # yield history, None
1246
- # audio_path = audio_future.result()
1247
- # yield history, audio_path
1248
-
1249
- # def add_message(history, message):
1250
- # history.append((message, None))
1251
- # return history, gr.Textbox(value="", interactive=True, placeholder="Enter message or upload file...", show_label=False)
1252
-
1253
- # def print_like_dislike(x: gr.LikeData):
1254
- # print(x.index, x.value, x.liked)
1255
-
1256
- # def extract_addresses(response):
1257
- # if not isinstance(response, str):
1258
- # response = str(response)
1259
- # address_patterns = [
1260
- # r'([A-Z].*,\sOmaha,\sNE\s\d{5})',
1261
- # r'(\d{4}\s.*,\sOmaha,\sNE\s\d{5})',
1262
- # r'([A-Z].*,\sNE\s\d{5})',
1263
- # r'([A-Z].*,.*\sSt,\sOmaha,\sNE\s\d{5})',
1264
- # r'([A-Z].*,.*\sStreets,\sOmaha,\sNE\s\d{5})',
1265
- # r'(\d{2}.*\sStreets)',
1266
- # r'([A-Z].*\s\d{2},\sOmaha,\sNE\s\d{5})'
1267
- # ]
1268
- # addresses = []
1269
- # for pattern in address_patterns:
1270
- # addresses.extend(re.findall(pattern, response))
1271
- # return addresses
1272
-
1273
- # all_addresses = []
1274
-
1275
- # def generate_map(location_names):
1276
- # global all_addresses
1277
- # all_addresses.extend(location_names)
1278
- # api_key = os.environ['GOOGLEMAPS_API_KEY']
1279
- # gmaps = GoogleMapsClient(key=api_key)
1280
- # m = folium.Map(location=[41.2565, -95.9345], zoom_start=12)
1281
- # for location_name in all_addresses:
1282
- # geocode_result = gmaps.geocode(location_name)
1283
- # if geocode_result:
1284
- # location = geocode_result[0]['geometry']['location']
1285
- # folium.Marker(
1286
- # [location['lat'], location['lng']],
1287
- # tooltip=f"{geocode_result[0]['formatted_address']}"
1288
- # ).add_to(m)
1289
- # map_html = m._repr_html_()
1290
- # return map_html
1291
-
1292
- # def update_map_with_response(history):
1293
- # if not history:
1294
- # return ""
1295
- # response = history[-1][1]
1296
- # addresses = extract_addresses(response)
1297
- # return generate_map(addresses)
1298
-
1299
- # def clear_textbox():
1300
- # return ""
1301
-
1302
- # def show_map_if_details(history, choice):
1303
- # if choice in ["Details", "Conversational"]:
1304
- # return gr.update(visible=True), update_map_with_response(history)
1305
- # else:
1306
- # return gr.update(visible=False), ""
1307
-
1308
- # def generate_audio_elevenlabs(text):
1309
- # XI_API_KEY = os.environ['ELEVENLABS_API']
1310
- # VOICE_ID = 'd9MIrwLnvDeH7aZb61E9'
1311
- # tts_url = f"https://api.elevenlabs.io/v1/text-to-speech/{VOICE_ID}/stream"
1312
- # headers = {
1313
- # "Accept": "application/json",
1314
- # "xi-api-key": XI_API_KEY
1315
- # }
1316
- # data = {
1317
- # "text": str(text),
1318
- # "model_id": "eleven_multilingual_v2",
1319
- # "voice_settings": {
1320
- # "stability": 1.0,
1321
- # "similarity_boost": 0.0,
1322
- # "style": 0.60,
1323
- # "use_speaker_boost": False
1324
- # }
1325
- # }
1326
- # response = requests.post(tts_url, headers=headers, json=data, stream=True)
1327
- # if response.ok:
1328
- # with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as f:
1329
- # for chunk in response.iter_content(chunk_size=1024):
1330
- # f.write(chunk)
1331
- # temp_audio_path = f.name
1332
- # logging.debug(f"Audio saved to {temp_audio_path}")
1333
- # return temp_audio_path
1334
- # else:
1335
- # logging.error(f"Error generating audio: {response.text}")
1336
- # return None
1337
-
1338
- # # Stable Diffusion setup
1339
- # import torch
1340
- # from diffusers import StableDiffusion3Pipeline
1341
-
1342
- # pipe = StableDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3-medium-diffusers", torch_dtype=torch.float16)
1343
- # pipe = pipe.to("cuda")
1344
-
1345
- # def generate_image(prompt):
1346
- # image = pipe(
1347
- # prompt,
1348
- # negative_prompt="",
1349
- # num_inference_steps=28,
1350
- # guidance_scale=3.0,
1351
- # ).images[0]
1352
- # return image
1353
-
1354
- # hardcoded_prompt_1 = "Give a high quality photograph of a great looking red 2026 toyota coupe against a skyline setting in the night, michael mann style in omaha enticing the consumer to buy this product"
1355
- # hardcoded_prompt_2 = "A vibrant and dynamic football game scene in the style of Peter Paul Rubens, showcasing the intense match between Alabama and Nebraska. The players are depicted with the dramatic, muscular physiques and expressive faces typical of Rubens' style. The Alabama team is wearing their iconic crimson and white uniforms, while the Nebraska team is in their classic red and white attire. The scene is filled with action, with players in mid-motion, tackling, running, and catching the ball. The background features a grand stadium filled with cheering fans, banners, and the natural landscape in the distance. The colors are rich and vibrant, with a strong use of light and shadow to create depth and drama. The overall atmosphere captures the intensity and excitement of the game, infused with the grandeur and dynamism characteristic of Rubens' work."
1356
- # hardcoded_prompt_3 = "Create a high-energy scene of a DJ performing on a large stage with vibrant lights, colorful lasers, a lively dancing crowd, and various electronic equipment in the background."
1357
-
1358
- # def update_images():
1359
- # image_1 = generate_image(hardcoded_prompt_1)
1360
- # image_2 = generate_image(hardcoded_prompt_2)
1361
- # image_3 = generate_image(hardcoded_prompt_3)
1362
- # return image_1, image_2, image_3
1363
-
1364
- # def login_with_google():
1365
- # response = requests.get('http://localhost:5000/login')
1366
- # return response.url
1367
-
1368
- # with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
1369
- # with gr.Row():
1370
- # with gr.Column():
1371
- # state = gr.State()
1372
- # chatbot = gr.Chatbot([], elem_id="RADAR:Channel 94.1", bubble_full_width=False)
1373
- # choice = gr.Radio(label="Select Style", choices=["Details", "Conversational"], value="Conversational")
1374
- # gr.Markdown("<h1 style='color: red;'>Talk to RADAR</h1>", elem_id="voice-markdown")
1375
- # chat_input = gr.Textbox(show_copy_button=True, interactive=True, show_label=False, label="ASK Radar !!!")
1376
- # chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input])
1377
- # bot_msg = chat_msg.then(bot, [chatbot, choice], [chatbot, gr.Audio(interactive=False, autoplay=True)])
1378
- # bot_msg.then(lambda: gr.Textbox(value="", interactive=True, placeholder="Ask Radar!!!...", show_label=False), None, [chat_input])
1379
- # chatbot.like(print_like_dislike, None, None)
1380
- # clear_button = gr.Button("Clear")
1381
- # clear_button.click(fn=clear_textbox, inputs=None, outputs=chat_input)
1382
- # audio_input = gr.Audio(sources=["microphone"], streaming=True, type='numpy')
1383
- # audio_input.stream(transcribe_function, inputs=[state, audio_input], outputs=[state, chat_input], api_name="SAMLOne_real_time")
1384
- # gr.Markdown("<h1 style='color: red;'>Map</h1>", elem_id="location-markdown")
1385
- # location_output = gr.HTML()
1386
- # bot_msg.then(show_map_if_details, [chatbot, choice], [location_output, location_output])
1387
- # with gr.Column():
1388
- # weather_output = gr.HTML(value=fetch_local_weather())
1389
- # news_output = gr.HTML(value=fetch_local_news())
1390
- # events_output = gr.HTML(value=fetch_local_events())
1391
- # with gr.Column():
1392
- # image_output_1 = gr.Image(value=generate_image(hardcoded_prompt_1), width=400, height=400)
1393
- # image_output_2 = gr.Image(value=generate_image(hardcoded_prompt_2), width=400, height=400)
1394
- # image_output_3 = gr.Image(value=generate_image(hardcoded_prompt_3), width=400, height=400)
1395
- # refresh_button = gr.Button("Refresh Images")
1396
- # refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
1397
- # with gr.Column():
1398
- # login_button = gr.Button("Login with Google")
1399
- # login_button.click(fn=login_with_google)
1400
-
1401
- # demo.queue()
1402
- # demo.launch(share=True)
1403
-
1404
-
1405
-
1406
-
1407
-
1408
-
 
24
  from huggingface_hub import login
25
 
26
 
27
+
 
 
 
28
 
29
  # Check if the token is already set in the environment variables
30
  hf_token = os.getenv("HF_TOKEN")
 
834
  return image_1, image_2, image_3
835
 
836
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
837
 
838
  with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
839
 
 
875
 
876
  refresh_button = gr.Button("Refresh Images")
877
  refresh_button.click(fn=update_images, inputs=None, outputs=[image_output_1, image_output_2, image_output_3])
878
+
 
 
 
 
 
879
  demo.queue()
880
  demo.launch(share=True)
881
 
882