Adam
Make description of interest shorter
5f66163
import json
import time
import os
from datetime import datetime
import gradio as gr
import requests
url = os.environ.get('URL')
def process_and_render(prompt, name, type, gender, nationality, min_age, max_age, major, interest):
payload = {
"prompt": prompt,
"name": name,
"type": type,
"gender": gender,
"nationality": nationality,
"min_age": min_age,
"max_age": max_age,
"major": major,
"interest": interest
}
response = requests.post(url, json=payload)
if response.status_code == 200:
print("Success!")
# print(response.json())
return response.json()['data']
else:
print(f"Failed with status code: {response.status_code}")
print(response.text)
return response.text
with gr.Blocks() as demo:
gr.Markdown("# SNU Buddy Spring 2024 Search Engine")
prompt = gr.Textbox(label="Enter your prompt", placeholder="Who is the most out going?")
with gr.Row():
name = gr.Textbox(label="Name")
type = gr.CheckboxGroup(label="Student Type", choices=["SNU", "Exchange"])
gender = gr.CheckboxGroup(label="Gender", choices=["Male", "Female"])
with gr.Row():
min_age = gr.Number(label="Minimum Age", value=0)
max_age = gr.Number(label="Maximum Age", value=100)
with gr.Row():
nationality = gr.CheckboxGroup(label="Nationality", choices=["South Korea", "United States of America", "Australia", "Canada", "China", "France", "Germany", "Ireland", "Japan", "New Zealand", "Norway", "Singapore", "Sweden", "Switzerland", "United Kingdom"])
major = gr.CheckboxGroup(label="Major", choices=["Asia", "Art", "Business", "Bio", "Computer Science", "Economics", "Engineering", "Film", "History", "International", "Korea", "Law", "Linguistics", "Math", "Media", "Medicine", "Philosophy", "Politic"])
interest = gr.Textbox(label="Interests & Hobbies (Separate each keyword with a comma)", placeholder="sports, music, movie")
submit = gr.Button("Search")
html_output = gr.HTML() # Output as HTML
submit.click(process_and_render, inputs=[prompt, name, type, gender, nationality, min_age, max_age, major, interest], outputs=[html_output])
# This line is key for generating a public URL
demo.launch()