Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,64 +1,64 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
| 3 |
|
|
|
|
|
|
|
| 4 |
"""
|
| 5 |
-
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
| 6 |
-
"""
|
| 7 |
-
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
def respond(
|
| 11 |
-
message,
|
| 12 |
-
history: list[tuple[str, str]],
|
| 13 |
-
system_message,
|
| 14 |
-
max_tokens,
|
| 15 |
-
temperature,
|
| 16 |
-
top_p,
|
| 17 |
-
):
|
| 18 |
-
messages = [{"role": "system", "content": system_message}]
|
| 19 |
-
|
| 20 |
-
for val in history:
|
| 21 |
-
if val[0]:
|
| 22 |
-
messages.append({"role": "user", "content": val[0]})
|
| 23 |
-
if val[1]:
|
| 24 |
-
messages.append({"role": "assistant", "content": val[1]})
|
| 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 |
-
minimum=0.1,
|
| 54 |
-
maximum=1.0,
|
| 55 |
-
value=0.95,
|
| 56 |
-
step=0.05,
|
| 57 |
-
label="Top-p (nucleus sampling)",
|
| 58 |
-
),
|
| 59 |
-
],
|
| 60 |
-
)
|
| 61 |
|
| 62 |
|
| 63 |
if __name__ == "__main__":
|
| 64 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
import time
|
| 4 |
+
import pandas as pd
|
| 5 |
+
from datetime import datetime
|
| 6 |
|
| 7 |
+
DEFAULT_SYSTEM_PROMPT = """
|
| 8 |
+
This is Banyan Group's Ads Checker, the tool guides you to the different possible paid ads a brand is sponsoring.
|
| 9 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
results = []
|
| 12 |
+
results.append(['Website','Speed in Seconds'])
|
| 13 |
+
vLogDate = datetime.today().strftime('%Y/%m/%d')
|
| 14 |
|
| 15 |
+
websites = [
|
| 16 |
+
"https://www.banyantree.com",
|
| 17 |
+
"https://www.angsana.com",
|
| 18 |
+
"https://www.cassia.com",
|
| 19 |
+
"https://www.dhawa.com",
|
| 20 |
+
"https://www.garrya.com",
|
| 21 |
+
"https://www.hommhotels.com",
|
| 22 |
+
"https://www.foliohotels.com",
|
| 23 |
+
"https://www.raffles.com",
|
| 24 |
+
"https://www.aman.com",
|
| 25 |
+
"https://www.rosewoodhotels.com",
|
| 26 |
+
"https://www.fourseasons.com",
|
| 27 |
+
"https://www.radissonhotels.com",
|
| 28 |
+
"https://www.millenniumhotels.com",
|
| 29 |
+
"https://www.mandarinoriental.com",
|
| 30 |
+
"https://www.ritzcarlton.com",
|
| 31 |
+
"https://www.hyatt.com",
|
| 32 |
+
"https://www.ihg.com"
|
| 33 |
+
]
|
| 34 |
|
| 35 |
+
def check_site_speed(url):
|
| 36 |
+
try:
|
| 37 |
+
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"}
|
| 38 |
+
start_time = time.time()
|
| 39 |
+
response = requests.get(url, headers=headers, timeout=10)
|
| 40 |
+
response.raise_for_status()
|
| 41 |
+
end_time = time.time()
|
| 42 |
+
return round(end_time - start_time, 5) # Response time in seconds
|
| 43 |
+
except requests.exceptions.RequestException as e:
|
| 44 |
+
print(f"Error checking {url}: {e}")
|
| 45 |
+
return None
|
| 46 |
|
| 47 |
+
def runchecks(message,history):
|
| 48 |
+
for site in websites:
|
| 49 |
+
print(f"Checking site speed for {site}...")
|
| 50 |
+
speed = check_site_speed(site)
|
| 51 |
+
time.sleep(11)
|
| 52 |
+
if speed is not None:
|
| 53 |
+
print(f"Response time for {site}: {speed} seconds")
|
| 54 |
+
results.append([site,speed])
|
| 55 |
+
df_log = pd.DataFrame(results)
|
| 56 |
+
return df_log
|
| 57 |
+
|
| 58 |
+
Conversing = gr.ChatInterface(runchecks, chatbot=gr.Chatbot(height=600,label = "Enter Domain to evaluate (no 'https://www')"), theme=gr.themes.Monochrome(),
|
| 59 |
+
title = 'BT ECommerce AdsChecker Tool', description = DEFAULT_SYSTEM_PROMPT, css='footer {visibility: hidden}').launch()
|
| 60 |
+
#"Algorithm for this site is based on Readability Wiki - https://en.wikipedia.org/wiki/Readability "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
|
| 63 |
if __name__ == "__main__":
|
| 64 |
+
Conversing.launch()
|