Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -80,7 +80,7 @@ def load_sql_data(query):
|
|
| 80 |
)
|
| 81 |
df = pd.read_sql_query(query, conn)
|
| 82 |
df = df.drop(['item_doi'], axis=1)
|
| 83 |
-
|
| 84 |
# Close the database connection
|
| 85 |
conn.close()
|
| 86 |
CACHE[SQL_KEY] = df
|
|
@@ -258,4 +258,29 @@ gradio_interface = gradio.Interface(
|
|
| 258 |
article="© ScholarSync 2023"
|
| 259 |
)
|
| 260 |
|
|
|
|
| 261 |
gradio_interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
)
|
| 81 |
df = pd.read_sql_query(query, conn)
|
| 82 |
df = df.drop(['item_doi'], axis=1)
|
| 83 |
+
|
| 84 |
# Close the database connection
|
| 85 |
conn.close()
|
| 86 |
CACHE[SQL_KEY] = df
|
|
|
|
| 258 |
article="© ScholarSync 2023"
|
| 259 |
)
|
| 260 |
|
| 261 |
+
|
| 262 |
gradio_interface.launch()
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
def validation(user_input):
|
| 266 |
+
user_words = set(user_input.lower().split())
|
| 267 |
+
if any(word in stop_words for word in user_words):
|
| 268 |
+
return "valid"
|
| 269 |
+
else:
|
| 270 |
+
return "invalid"
|
| 271 |
+
|
| 272 |
+
validation_interface = gradio.Interface(
|
| 273 |
+
fn=validation,
|
| 274 |
+
inputs="text",
|
| 275 |
+
outputs="text",
|
| 276 |
+
examples=[
|
| 277 |
+
["AI"],
|
| 278 |
+
["Sai"],
|
| 279 |
+
["Rocket Science"]
|
| 280 |
+
],
|
| 281 |
+
title="Sprinkler Article Generator API",
|
| 282 |
+
description="This is a AI powered REST API with Gradio and Huggingface Spaces – for free! Based on [this article](https://www.tomsoderlund.com/ai/building-ai-powered-rest-api). See the **Use via API** link at the bottom of this page.",
|
| 283 |
+
article="© ScholarSync 2023"
|
| 284 |
+
)
|
| 285 |
+
|
| 286 |
+
validation_interface.launch()
|