Adam commited on
Commit
9b3ff22
1 Parent(s): e8ee793
Files changed (3) hide show
  1. .gitignore +4 -0
  2. app.py +59 -0
  3. requirements.txt +3 -0
.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ .env
2
+ .dist
3
+ .ipynb_checkpoints
4
+ __pycache__
app.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import time
3
+ import os
4
+ from datetime import datetime
5
+
6
+ import gradio as gr
7
+ import requests
8
+
9
+ url = os.environ.get('URL')
10
+
11
+ def process_and_render(prompt, name, type, gender, nationality, min_age, max_age, major, interest):
12
+ payload = {
13
+ "prompt": prompt,
14
+ "name": name,
15
+ "type": type,
16
+ "gender": gender,
17
+ "nationality": nationality,
18
+ "min_age": min_age,
19
+ "max_age": max_age,
20
+ "major": major,
21
+ "interest": interest
22
+ }
23
+ response = requests.post(url, json=payload)
24
+
25
+ if response.status_code == 200:
26
+ print("Success!")
27
+ # print(response.json())
28
+ return response.json()['data']
29
+ else:
30
+ print(f"Failed with status code: {response.status_code}")
31
+ print(response.text)
32
+ return response.text
33
+
34
+
35
+ with gr.Blocks() as demo:
36
+ gr.Markdown("# SNU Buddy Spring 2024 Search Engine")
37
+
38
+ prompt = gr.Textbox(label="Enter your prompt", placeholder="Who is the most out going?")
39
+
40
+ with gr.Row():
41
+ name = gr.Textbox(label="Name")
42
+ type = gr.CheckboxGroup(label="Student Type", choices=["SNU", "Exchange"])
43
+ gender = gr.CheckboxGroup(label="Gender", choices=["Male", "Female"])
44
+ with gr.Row():
45
+ min_age = gr.Number(label="Minimum Age", value=0)
46
+ max_age = gr.Number(label="Maximum Age", value=100)
47
+ with gr.Row():
48
+ nationality = gr.CheckboxGroup(label="Nationality", choices=["South Korea", "United States of America", "Australia", "Canada", "France", "Germany", "New Zealand", "Norway", "Singapore", "Sweden", "Switzerland", "United Kingdom"])
49
+ major = gr.CheckboxGroup(label="Major", choices=["Art", "Business", "Bio", "Computer Science", "Economics", "Engineering", "History", "Korea", "Math", "Medicine"])
50
+ interest = gr.Textbox(label="Interest & Hobbies (Query multiple interests with a comma (,) separator)", placeholder="sports, music, movie")
51
+
52
+ submit = gr.Button("Search")
53
+
54
+ html_output = gr.HTML() # Output as HTML
55
+
56
+ submit.click(process_and_render, inputs=[prompt, name, type, gender, nationality, min_age, max_age, major, interest], outputs=[html_output])
57
+
58
+ # This line is key for generating a public URL
59
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ scipy
3
+ requests