maahikachitagi commited on
Commit
37fb8e6
Β·
verified Β·
1 Parent(s): 2e48300

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -14
app.py CHANGED
@@ -1,11 +1,11 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
4
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta") # Use actual model
5
 
6
  def set_type(choice, user_profile):
7
  user_profile["interview_type"] = choice.lower()
8
- return "Great! What’s your background and what field/role are you aiming for?", user_profile
9
 
10
  def save_background(info, user_profile):
11
  user_profile["field"] = info
@@ -28,7 +28,7 @@ def respond(message, history, user_profile):
28
  response = client.chat_completion(
29
  messages,
30
  max_tokens=150,
31
- stream=False # Make sure streaming is OFF
32
  )
33
 
34
  return response.choices[0].message.content
@@ -38,7 +38,7 @@ with gr.Blocks() as demo:
38
  user_profile = gr.State({"interview_type": "", "field": ""})
39
 
40
  gr.Markdown("# 🎀 Welcome to Intervu")
41
-
42
  # Step 1
43
  gr.Markdown("### Step 1: Choose Interview Type")
44
  with gr.Row():
@@ -47,26 +47,27 @@ with gr.Blocks() as demo:
47
  btn3 = gr.Button("College / Scholarship")
48
  type_out = gr.Textbox(label="Bot", interactive=False)
49
 
50
- btn1.click(set_type, inputs=[gr.Textbox(value="Behavioral", visible=False), user_profile], outputs=[type_out, user_profile])
51
- btn2.click(set_type, inputs=[gr.Textbox(value="Technical", visible=False), user_profile], outputs=[type_out, user_profile])
52
- btn3.click(set_type, inputs=[gr.Textbox(value="College", visible=False), user_profile], outputs=[type_out, user_profile])
53
 
54
  # Step 2
55
  gr.Markdown("### Step 2: Enter Your Background")
56
  background = gr.Textbox(label="Your background and field/goal")
57
- background_btn = gr.Button("Submit")
58
  background_out = gr.Textbox(label="Bot", interactive=False)
59
 
60
  background_btn.click(save_background, inputs=[background, user_profile], outputs=[background_out, user_profile])
61
 
62
- # Step 3: Interview
63
  gr.Markdown("### Step 3: Start Interview")
64
  chatbot = gr.ChatInterface(
65
- lambda msg, hist: respond(msg, hist, user_profile.value),
66
- title="Intervu - AI Interview Practice",
67
- type="messages" # Important to fix the warning
68
- )
69
-
 
70
 
71
  demo.launch()
72
 
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
4
+ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
5
 
6
  def set_type(choice, user_profile):
7
  user_profile["interview_type"] = choice.lower()
8
+ return f"Great! What’s your background and what field/role are you aiming for?", user_profile
9
 
10
  def save_background(info, user_profile):
11
  user_profile["field"] = info
 
28
  response = client.chat_completion(
29
  messages,
30
  max_tokens=150,
31
+ stream=False
32
  )
33
 
34
  return response.choices[0].message.content
 
38
  user_profile = gr.State({"interview_type": "", "field": ""})
39
 
40
  gr.Markdown("# 🎀 Welcome to Intervu")
41
+
42
  # Step 1
43
  gr.Markdown("### Step 1: Choose Interview Type")
44
  with gr.Row():
 
47
  btn3 = gr.Button("College / Scholarship")
48
  type_out = gr.Textbox(label="Bot", interactive=False)
49
 
50
+ btn1.click(set_type, inputs=["Behavioral", user_profile], outputs=[type_out, user_profile])
51
+ btn2.click(set_type, inputs=["Technical", user_profile], outputs=[type_out, user_profile])
52
+ btn3.click(set_type, inputs=["College", user_profile], outputs=[type_out, user_profile])
53
 
54
  # Step 2
55
  gr.Markdown("### Step 2: Enter Your Background")
56
  background = gr.Textbox(label="Your background and field/goal")
57
+ background_btn = gr.Button("Submit Background")
58
  background_out = gr.Textbox(label="Bot", interactive=False)
59
 
60
  background_btn.click(save_background, inputs=[background, user_profile], outputs=[background_out, user_profile])
61
 
62
+ # Step 3
63
  gr.Markdown("### Step 3: Start Interview")
64
  chatbot = gr.ChatInterface(
65
+ fn=lambda msg, hist: respond(msg, hist, user_profile.value),
66
+ title="Intervu - AI Interview Practice",
67
+ chatbot=gr.Chatbot(label="Interview Bot"),
68
+ input_textbox=gr.Textbox(placeholder="Type your answer here..."),
69
+ type="messages"
70
+ )
71
 
72
  demo.launch()
73