Spaces:
Sleeping
Sleeping
First Commit for App
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ class URLValidator:
|
|
15 |
def __init__(self):
|
16 |
# SerpAPI Key
|
17 |
# This api key is acquired from SerpAPI website.
|
18 |
-
self.serpapi_key =
|
19 |
|
20 |
# Load models once to avoid redundant API calls
|
21 |
self.similarity_model = SentenceTransformer('sentence-transformers/all-mpnet-base-v2')
|
@@ -146,7 +146,6 @@ class URLValidator:
|
|
146 |
},
|
147 |
"explanation": explanation
|
148 |
}
|
149 |
-
|
150 |
st.write("LEVEL1 TITLE: APP")
|
151 |
st.write ("This is my first app")
|
152 |
|
@@ -156,14 +155,14 @@ url_to_check = "https://www.mayoclinic.org/healthy-lifestyle/infant-and-toddler-
|
|
156 |
|
157 |
# Run validation when the button is clicked
|
158 |
if st.button("Validate URL"):
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
|
167 |
# Display results in JSON format
|
168 |
-
st.subheader(
|
169 |
-
st.json(result)
|
|
|
15 |
def __init__(self):
|
16 |
# SerpAPI Key
|
17 |
# This api key is acquired from SerpAPI website.
|
18 |
+
self.serpapi_key = SERPAPI_KEY
|
19 |
|
20 |
# Load models once to avoid redundant API calls
|
21 |
self.similarity_model = SentenceTransformer('sentence-transformers/all-mpnet-base-v2')
|
|
|
146 |
},
|
147 |
"explanation": explanation
|
148 |
}
|
|
|
149 |
st.write("LEVEL1 TITLE: APP")
|
150 |
st.write ("This is my first app")
|
151 |
|
|
|
155 |
|
156 |
# Run validation when the button is clicked
|
157 |
if st.button("Validate URL"):
|
158 |
+
if not user_prompt.strip() or not url_to_check.strip():
|
159 |
+
st-warning("Please enter both a search query and a URL.")
|
160 |
+
else:
|
161 |
+
with st.spinner("Validating URL..."):
|
162 |
+
# Instantiate the URLValidator class
|
163 |
+
validator = URLValidator
|
164 |
+
result - validator.rate_url_validity(user_prompt, url_to_check)
|
165 |
|
166 |
# Display results in JSON format
|
167 |
+
st.subheader (Validation Results")
|
168 |
+
st. json(result)
|