Spaces:
Sleeping
Sleeping
File size: 2,752 Bytes
2820d25 43d9a47 2820d25 2417025 c26e0cc 2417025 c26e0cc 2417025 c26e0cc 2417025 c26e0cc 2417025 c26e0cc 2417025 2fa1a7a 2417025 2820d25 43d9a47 c26e0cc 2417025 14761cb c26e0cc 2417025 c26e0cc 2417025 c26e0cc 2417025 c26e0cc 2417025 c26e0cc 2417025 2fa1a7a c26e0cc 14761cb 2820d25 c26e0cc 2820d25 c26e0cc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
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 "How Can We help you?"
return search_system.search_courses(query, top_k=num_results)
# Custom CSS for better spacing while maintaining visibility
custom_css = """
.gradio-container {
padding: 2rem !important;
}
.footer {
margin-top: 4rem;
text-align: center;
font-size: 1.1em;
}
.title {
margin-bottom: 2rem !important;
text-align: center;
}
.search-box {
margin: 1.5rem 0 !important;
}
.results-container {
margin-top: 2rem !important;
padding: 1rem !important;
background: rgba(0, 0, 0, 0.05);
border-radius: 8px;
}
"""
# Create Gradio interface with improved spacing and visibility
with gr.Blocks(css=custom_css, title="Analytics Vidhya 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!
""",
elem_classes="title"
)
with gr.Row():
with gr.Column():
query_input = gr.Textbox(
label="What would you like to learn?",
placeholder="E.g., 'Assault' or 'Battery' or 'Copyright Infringement'",
lines=2,
elem_classes="search-box"
)
with gr.Row():
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",
scale=0.4,
size="lg"
)
# Results section
output = gr.Markdown(
label="Search Results",
elem_classes="results-container"
)
# Footer
gr.Markdown(
"""
---
Made with Sentence Transformers and Gradio
""",
elem_classes="footer"
)
# Set up the click event
search_button.click(
fn=search_courses,
inputs=[query_input, num_results],
outputs=output
)
if __name__ == "__main__":
iface.launch(
share=False,
debug=False,
show_api=False,
show_error=False
) |