Spaces:
Sleeping
Sleeping
Gateston Johns
commited on
Commit
•
a6e254b
1
Parent(s):
b2c4fea
add internet checker
Browse files
app.py
CHANGED
@@ -9,11 +9,24 @@ from query_pipeline.evaluation_engine import EvaluationEngine
|
|
9 |
from proto.chunk_pb2 import Chunk, ChunkType
|
10 |
from datetime import datetime
|
11 |
import os
|
|
|
12 |
|
13 |
os.environ['NEO4J_USER'] = "neo4j"
|
14 |
os.environ['NEO4J_PASSWORD'] = "dOIZwzF_GImgwjF-smChe60QGQgicq8ER8RUlZvornU"
|
15 |
os.environ['NEO4J_URI'] = "neo4j+s://2317ae21.databases.neo4j.io"
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
def thesis_evaluation(thesis: str) -> str:
|
18 |
thesis_document_d = DocumentD(file_path="",
|
19 |
authors="user",
|
@@ -50,8 +63,13 @@ with gr.Blocks(theme=theme) as demo:
|
|
50 |
submit = gr.Button(scale=1, value="Evaluate")
|
51 |
with gr.Row():
|
52 |
out = gr.HTML()
|
|
|
|
|
|
|
|
|
53 |
|
54 |
submit.click(thesis_evaluation, inputs=inp, outputs=out)
|
|
|
55 |
|
56 |
demo.launch(
|
57 |
auth=('athena-admin', 'athena')
|
|
|
9 |
from proto.chunk_pb2 import Chunk, ChunkType
|
10 |
from datetime import datetime
|
11 |
import os
|
12 |
+
import requests
|
13 |
|
14 |
os.environ['NEO4J_USER'] = "neo4j"
|
15 |
os.environ['NEO4J_PASSWORD'] = "dOIZwzF_GImgwjF-smChe60QGQgicq8ER8RUlZvornU"
|
16 |
os.environ['NEO4J_URI'] = "neo4j+s://2317ae21.databases.neo4j.io"
|
17 |
|
18 |
+
def check_internet_connection():
|
19 |
+
try:
|
20 |
+
response = requests.get('http://www.google.com', timeout=5)
|
21 |
+
if response.status_code == 200:
|
22 |
+
return "Internet connection is available."
|
23 |
+
else:
|
24 |
+
return f"Received a response but not a successful status code: {response.status_code}"
|
25 |
+
except requests.ConnectionError:
|
26 |
+
return "No internet connection available."
|
27 |
+
except requests.Timeout:
|
28 |
+
return "The request timed out."
|
29 |
+
|
30 |
def thesis_evaluation(thesis: str) -> str:
|
31 |
thesis_document_d = DocumentD(file_path="",
|
32 |
authors="user",
|
|
|
63 |
submit = gr.Button(scale=1, value="Evaluate")
|
64 |
with gr.Row():
|
65 |
out = gr.HTML()
|
66 |
+
with gr.Row():
|
67 |
+
checkInetButton = gr.Button(value="Check Internet Connection")
|
68 |
+
with gr.Row():
|
69 |
+
status = gr.Textbox(placeholder="", scale=1, lines=1, show_label=False)
|
70 |
|
71 |
submit.click(thesis_evaluation, inputs=inp, outputs=out)
|
72 |
+
checkInetButton.click(check_internet_connection, outputs=status)
|
73 |
|
74 |
demo.launch(
|
75 |
auth=('athena-admin', 'athena')
|