Spaces:
Sleeping
Sleeping
import gradio as gr | |
import pandas as pd | |
from course_search import CourseSearchSystem | |
# Initialize the search system | |
df = pd.read_csv('course_data.csv') | |
search_system = CourseSearchSystem() | |
search_system.load_and_prepare_data(df) | |
def search_courses(query: str, num_results: int) -> str: | |
"""Search function for Gradio interface""" | |
if not query.strip(): | |
return "Please enter a search query to find relevant courses!" | |
return search_system.search_courses(query, top_k=num_results) | |
# Create Gradio interface | |
with gr.Blocks(title="Analytics Vidhya Free Course Search") as iface: | |
gr.Markdown(""" | |
# π Analytics Vidhya Free Course Search | |
Find the perfect free course from Analytics Vidhya's collection using natural language search. | |
Simply describe what you're looking for! | |
""") | |
with gr.Row(): | |
with gr.Column(): | |
query_input = gr.Textbox( | |
label="What would you like to learn?", | |
placeholder="E.g., 'machine learning for beginners' or 'computer vision projects'", | |
lines=2 | |
) | |
num_results = gr.Slider( | |
minimum=1, | |
maximum=10, | |
value=3, | |
step=1, | |
label="Number of results to show" | |
) | |
search_button = gr.Button("π Search Courses", variant="primary") | |
output = gr.Markdown(label="Search Results") | |
search_button.click( | |
fn=search_courses, | |
inputs=[query_input, num_results], | |
outputs=output | |
) | |
gr.Markdown(""" | |
--- | |
Made with β€οΈ using Sentence Transformers and Gradio | |
""") | |
if __name__ == "__main__": | |
iface.launch() | |