Spaces:
Runtime error
Runtime error
| import gradio | |
| import gradio as gr | |
| import requests | |
| def process(file, role, complexity): | |
| try: | |
| file_upload_api_url = "https://app.interview-buddy.live/uploadFile" | |
| query_api_url = "https://app.interview-buddy.live/query" | |
| files = {'file': open(file, 'rb')} | |
| file_upload_response = requests.post(file_upload_api_url, files=files, verify=False) | |
| print(file_upload_response.status_code) | |
| if file_upload_response.status_code != 200 and file_upload_response.status_code != 204: | |
| raise gr.Error('Uploading resume FAILED!!') | |
| query_response = requests.get(query_api_url, params={'text': f'You are an expert interviewer. Generate few {complexity} interview questions for the role {role} based on the resume given'}, verify=False) | |
| print(query_response.status_code) | |
| if query_response.status_code != 200 and query_response.status_code != 204: | |
| raise gr.Error('Unable to generate questions!!') | |
| return query_response.text | |
| except Exception as err: | |
| return err | |
| roles_dropdown = gradio.Dropdown( | |
| choices=[ | |
| "UI Developer", | |
| "Fullstack Developer", | |
| "Backend Developer", | |
| "Engineering Manager", | |
| "Devops" | |
| ], | |
| value="Backend Developer" | |
| ) | |
| complexity_radio = gradio.Radio( | |
| choices=["Beginner", "Intermediate", "Advanced"], | |
| value="Intermediate" | |
| ) | |
| file_upload = gradio.File( | |
| file_types=['.pdf'], | |
| label='Choose a resume' | |
| ) | |
| output = gr.Textbox(label="Interview Questions") | |
| demo = gr.Interface( | |
| title="Interview Buddy", | |
| submit_btn="Upload & Generate Questions", | |
| fn=process, | |
| inputs=[file_upload, roles_dropdown, complexity_radio], | |
| outputs=[output], | |
| allow_flagging="never" | |
| ) | |
| demo.launch(auth=[("arvind", "!abcd1234"), ("srikkanth", "!abcd1234")], root_path='/interview_buddy_ui', server_port=7860) | |