Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,21 +13,26 @@ def save_background(info, user_profile):
|
|
| 13 |
|
| 14 |
def respond(message, history, user_profile):
|
| 15 |
if not user_profile["interview_type"] or not user_profile["field"]:
|
| 16 |
-
|
| 17 |
-
return
|
| 18 |
|
| 19 |
messages = [
|
| 20 |
-
{
|
|
|
|
|
|
|
|
|
|
| 21 |
]
|
| 22 |
if history:
|
| 23 |
messages.extend(history)
|
| 24 |
messages.append({"role": "user", "content": message})
|
| 25 |
|
| 26 |
-
response =
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
with gr.Blocks() as demo:
|
| 33 |
user_profile = gr.State({"interview_type": "", "field": ""})
|
|
@@ -56,7 +61,12 @@ with gr.Blocks() as demo:
|
|
| 56 |
|
| 57 |
# Step 3: Interview
|
| 58 |
gr.Markdown("### Step 3: Start Interview")
|
| 59 |
-
chatbot = gr.ChatInterface(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
demo.launch()
|
| 62 |
|
|
|
|
| 13 |
|
| 14 |
def respond(message, history, user_profile):
|
| 15 |
if not user_profile["interview_type"] or not user_profile["field"]:
|
| 16 |
+
return "Please finish steps 1 and 2 before starting the interview."
|
|
|
|
| 17 |
|
| 18 |
messages = [
|
| 19 |
+
{
|
| 20 |
+
"role": "system",
|
| 21 |
+
"content": f"You are a professional interviewer conducting a {user_profile['interview_type']} interview for a candidate in the {user_profile['field']} field."
|
| 22 |
+
}
|
| 23 |
]
|
| 24 |
if history:
|
| 25 |
messages.extend(history)
|
| 26 |
messages.append({"role": "user", "content": message})
|
| 27 |
|
| 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
|
| 35 |
+
|
| 36 |
|
| 37 |
with gr.Blocks() as demo:
|
| 38 |
user_profile = gr.State({"interview_type": "", "field": ""})
|
|
|
|
| 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 |
|