File size: 1,875 Bytes
1dc86e7
 
65c2970
1dc86e7
 
 
65c2970
51542f4
 
65c2970
 
 
 
51542f4
 
 
 
 
 
 
65c2970
 
 
1dc86e7
 
 
51542f4
 
 
 
 
 
 
eb27f3a
1dc86e7
 
 
51542f4
1dc86e7
 
 
51542f4
 
 
 
 
 
 
1dc86e7
eb27f3a
 
1dc86e7
51542f4
 
1dc86e7
 
 
51542f4
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
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)