Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -230,6 +230,8 @@ def get_article_recommendations(user_input):
|
|
230 |
|
231 |
|
232 |
def get_links(user_input):
|
|
|
|
|
233 |
recommendations = get_article_recommendations(user_input)
|
234 |
links = []
|
235 |
for article in recommendations:
|
@@ -244,38 +246,22 @@ def get_links(user_input):
|
|
244 |
return links
|
245 |
|
246 |
|
247 |
-
gradio_interface = gradio.Interface(
|
248 |
-
fn=get_links,
|
249 |
-
inputs="text",
|
250 |
-
outputs=gradio.outputs.JSON(),
|
251 |
-
examples=[
|
252 |
-
["AI"],
|
253 |
-
["Biochemicals"],
|
254 |
-
["Rocket Science"]
|
255 |
-
],
|
256 |
-
title="Sprinkler Article Generator API",
|
257 |
-
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.",
|
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 |
-
|
273 |
-
fn=validation,
|
274 |
-
inputs="
|
275 |
-
|
|
|
276 |
examples=[
|
277 |
["AI"],
|
278 |
-
["Sai"],
|
279 |
["Rocket Science"]
|
280 |
],
|
281 |
title="Sprinkler Article Generator API",
|
@@ -283,4 +269,7 @@ validation_interface = gradio.Interface(
|
|
283 |
article="© ScholarSync 2023"
|
284 |
)
|
285 |
|
286 |
-
|
|
|
|
|
|
|
|
230 |
|
231 |
|
232 |
def get_links(user_input):
|
233 |
+
if(validation(user_input)=="invalid"):
|
234 |
+
return "invalid"
|
235 |
recommendations = get_article_recommendations(user_input)
|
236 |
links = []
|
237 |
for article in recommendations:
|
|
|
246 |
return links
|
247 |
|
248 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
def validation(user_input):
|
250 |
user_words = set(user_input.lower().split())
|
251 |
if any(word in stop_words for word in user_words):
|
252 |
return "valid"
|
253 |
else:
|
254 |
return "invalid"
|
255 |
+
|
256 |
|
257 |
+
gradio_interface = gradio.Interface(
|
258 |
+
fn=[get_links,validation],
|
259 |
+
inputs=[ gradio.inputs.Textbox(label="get links"),
|
260 |
+
gradio.inputs.Textbox(label="validation")],
|
261 |
+
outputs=[ gradio.outputs.JSON(),gradio.outputs.JSON()],
|
262 |
examples=[
|
263 |
["AI"],
|
264 |
+
["Sai sahoo"],
|
265 |
["Rocket Science"]
|
266 |
],
|
267 |
title="Sprinkler Article Generator API",
|
|
|
269 |
article="© ScholarSync 2023"
|
270 |
)
|
271 |
|
272 |
+
|
273 |
+
gradio_interface.launch()
|
274 |
+
|
275 |
+
|