rxhulshxrmx commited on
Commit
c26e0cc
·
verified ·
1 Parent(s): d77165f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +82 -60
app.py CHANGED
@@ -14,77 +14,99 @@ def search_courses(query: str, num_results: int) -> str:
14
 
15
  return search_system.search_courses(query, top_k=num_results)
16
 
17
- # Create Gradio interface with light theme
18
- with gr.Blocks(
19
- title="Analytics Vidhya Free Course Search",
20
- theme=gr.themes.Soft(
21
- primary_hue="blue",
22
- secondary_hue="gray",
23
- neutral_hue="gray",
24
- text_size="lg"
25
- )
26
- ) as iface:
27
- gr.Markdown("""
28
- # Analytics Vidhya Free Course Search
29
- Find the perfect free course from Analytics Vidhya's collection using natural language search.
30
- Simply describe what you're looking for!
31
- """)
32
-
33
- with gr.Row():
34
- with gr.Column():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  query_input = gr.Textbox(
36
  label="What would you like to learn?",
37
  placeholder="E.g., 'machine learning for beginners' or 'computer vision projects'",
38
- lines=2
39
- )
40
- num_results = gr.Slider(
41
- minimum=1,
42
- maximum=10,
43
- value=3,
44
- step=1,
45
- label="Number of results to show"
46
- )
47
- search_button = gr.Button(
48
- "🔍 Search Courses",
49
- variant="primary"
50
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
- output = gr.Markdown(
53
- label="Search Results",
54
- elem_classes="search-results"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  )
56
 
 
57
  search_button.click(
58
  fn=search_courses,
59
  inputs=[query_input, num_results],
60
  outputs=output
61
  )
62
-
63
- # Add custom CSS for better light mode appearance
64
- gr.Markdown("""
65
- <style>
66
- .search-results {
67
- background-color: #ffffff;
68
- padding: 20px;
69
- border-radius: 8px;
70
- border: 1px solid #e0e0e0;
71
- }
72
- .gradio-container {
73
- background-color: #f8f9fa;
74
- }
75
- .footer {
76
- margin-top: 2rem;
77
- text-align: center;
78
- color: #666;
79
- }
80
- </style>
81
- """)
82
-
83
- gr.Markdown("""
84
- <div class="footer">
85
- Made with Sentence Transformers and Gradio
86
- </div>
87
- """)
88
 
89
  if __name__ == "__main__":
90
- iface.launch()
 
 
 
 
 
 
14
 
15
  return search_system.search_courses(query, top_k=num_results)
16
 
17
+ # Custom CSS for better spacing and minimalistic design
18
+ custom_css = """
19
+ #component-0 {
20
+ max-width: 800px;
21
+ margin: 0 auto;
22
+ padding: 2rem;
23
+ }
24
+ .gradio-container {
25
+ max-width: 850px !important;
26
+ }
27
+ .footer {
28
+ margin-top: 3rem;
29
+ padding-top: 1rem;
30
+ border-top: 1px solid #eee;
31
+ text-align: center;
32
+ font-size: 0.9em;
33
+ color: #666;
34
+ }
35
+ .container {
36
+ margin: 1rem auto;
37
+ padding: 1.5rem;
38
+ border-radius: 12px;
39
+ background: #ffffff;
40
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
41
+ }
42
+ """
43
+
44
+ # Create Gradio interface with improved design
45
+ with gr.Blocks(css=custom_css, title="Analytics Vidhya Course Search") as iface:
46
+ with gr.Column(elem_classes="container"):
47
+ gr.Markdown(
48
+ """
49
+ # Analytics Vidhya Course Search
50
+
51
+ Find the perfect free course from Analytics Vidhya's collection using natural language search.
52
+ Simply describe what you're looking for in plain English!
53
+ """
54
+ )
55
+
56
+ with gr.Column(scale=1):
57
  query_input = gr.Textbox(
58
  label="What would you like to learn?",
59
  placeholder="E.g., 'machine learning for beginners' or 'computer vision projects'",
60
+ lines=2,
61
+ container=False
 
 
 
 
 
 
 
 
 
 
62
  )
63
+
64
+ with gr.Row():
65
+ num_results = gr.Slider(
66
+ minimum=1,
67
+ maximum=10,
68
+ value=3,
69
+ step=1,
70
+ label="Number of results",
71
+ container=False
72
+ )
73
+ search_button = gr.Button(
74
+ "🔍 Search",
75
+ variant="primary",
76
+ size="lg"
77
+ )
78
 
79
+ # Add some spacing
80
+ gr.Markdown("")
81
+
82
+ # Results section with better formatting
83
+ with gr.Column():
84
+ output = gr.Markdown(
85
+ label="Search Results",
86
+ elem_classes="results-container"
87
+ )
88
+
89
+ # Footer with subtle styling
90
+ gr.Markdown(
91
+ """
92
+ <div class="footer">
93
+ Made with ❤️ using Sentence Transformers and Gradio
94
+ </div>
95
+ """,
96
+ elem_classes="footer"
97
  )
98
 
99
+ # Set up the click event
100
  search_button.click(
101
  fn=search_courses,
102
  inputs=[query_input, num_results],
103
  outputs=output
104
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
  if __name__ == "__main__":
107
+ iface.launch(
108
+ share=False,
109
+ debug=False,
110
+ show_api=False,
111
+ show_error=False
112
+ )