abhicake commited on
Commit
d6d2575
·
verified ·
1 Parent(s): d16838e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
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
- # Return the top 4 course names as a list
32
- return [det['Course Name'] for det in top_4_dets]
 
 
 
 
 
 
 
 
33
 
34
  # Create the Gradio interface
35
  iface = gr.Interface(fn=search_courses,
36
  inputs="text",
37
- outputs="text",
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