Update app.py
Browse files
app.py
CHANGED
|
@@ -28,13 +28,21 @@ def search_courses(user_query):
|
|
| 28 |
# Get the top 4 courses
|
| 29 |
top_4_dets = [item[1] for item in similarity_scores[:4]]
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
# Create the Gradio interface
|
| 35 |
iface = gr.Interface(fn=search_courses,
|
| 36 |
inputs="text",
|
| 37 |
-
outputs="
|
| 38 |
title="Course Search with Sentence Transformers",
|
| 39 |
description="Enter a query to find the top 4 most similar courses.")
|
| 40 |
|
|
|
|
| 28 |
# Get the top 4 courses
|
| 29 |
top_4_dets = [item[1] for item in similarity_scores[:4]]
|
| 30 |
|
| 31 |
+
# Get the final result to display to the user
|
| 32 |
+
results = []
|
| 33 |
+
for det in top_4_dets:
|
| 34 |
+
course_info = f"**Category**: {det['Course Category']}\n" \
|
| 35 |
+
f"**Course Name**: {det['Course Name']}\n" \
|
| 36 |
+
f"**Course URL**: {det['Course Url']}\n" \
|
| 37 |
+
f"**Description**: {det['Course Description']}\n"
|
| 38 |
+
results.append(course_info)
|
| 39 |
+
|
| 40 |
+
return "\n\n".join(results)
|
| 41 |
|
| 42 |
# Create the Gradio interface
|
| 43 |
iface = gr.Interface(fn=search_courses,
|
| 44 |
inputs="text",
|
| 45 |
+
outputs="markdown",
|
| 46 |
title="Course Search with Sentence Transformers",
|
| 47 |
description="Enter a query to find the top 4 most similar courses.")
|
| 48 |
|