maahikachitagi commited on
Commit
512a608
Β·
verified Β·
1 Parent(s): 35691fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -23
app.py CHANGED
@@ -30,27 +30,24 @@ def save_background(info):
30
  user_profile["field"] = info
31
  return "Awesome! Type 'start' below to begin your interview."
32
 
33
- # Step 3: Launch chat interface with interview context
34
- def chat_bot():
35
- def respond(message, history):
36
- messages = [
37
- {"role": "system", "content": f"You are a professional interviewer for a {user_profile['interview_type']} interview in the {user_profile['field']} field."}
38
- ]
39
- if history:
40
- messages.extend(history)
41
- messages.append({"role": "user", "content": message})
42
-
43
- response = ""
44
- for msg in client.chat_completion(
45
- messages,
46
- max_tokens=100,
47
- stream=True
48
- ):
49
- token = msg.choices[0].delta.content
50
- response += token
51
- yield response
52
-
53
- gr.ChatInterface(respond, title="Intervu - AI Interview Practice").launch()
54
 
55
  # Build UI
56
  with gr.Blocks() as demo:
@@ -75,8 +72,8 @@ with gr.Blocks() as demo:
75
  background_btn.click(save_background, inputs=background, outputs=background_out)
76
 
77
  gr.Markdown("### Step 3: Start Your Interview")
78
- start_btn = gr.Button("Launch Chat Interview")
79
- start_btn.click(fn=chat_bot, inputs=[], outputs=[])
80
 
81
  demo.launch()
82
 
 
 
30
  user_profile["field"] = info
31
  return "Awesome! Type 'start' below to begin your interview."
32
 
33
+ # Step 3: Response logic for embedded Chatbot
34
+ def respond(message, history):
35
+ messages = [
36
+ {"role": "system", "content": f"You are a professional interviewer for a {user_profile['interview_type']} interview in the {user_profile['field']} field."}
37
+ ]
38
+ if history:
39
+ messages.extend(history)
40
+ messages.append({"role": "user", "content": message})
41
+
42
+ response = ""
43
+ for msg in client.chat_completion(
44
+ messages,
45
+ max_tokens=100,
46
+ stream=True
47
+ ):
48
+ token = msg.choices[0].delta.content
49
+ response += token
50
+ yield response
 
 
 
51
 
52
  # Build UI
53
  with gr.Blocks() as demo:
 
72
  background_btn.click(save_background, inputs=background, outputs=background_out)
73
 
74
  gr.Markdown("### Step 3: Start Your Interview")
75
+ chatbot = gr.ChatInterface(respond, title="Intervu - AI Interview Practice")
 
76
 
77
  demo.launch()
78
 
79
+