Spaces:
Runtime error
Runtime error
Update app.py
Browse files12 unmodified lines1314151617161718201920212223242526272627282930282930313233343536373822 unmodified lines6162635964656667686970717212 unmodified lines
def respond(message, history, user_profile): if not user_profile["interview_type"] or not user_profile["field"]: yield "Please finish steps 1 and 2 before starting the interview." return return "Please finish steps 1 and 2 before starting the interview."
messages = [ {"role": "system", "content": f"You are a professional interviewer conducting a {user_profile['interview_type']} interview for a candidate in the {user_profile['field']} field."} { "role": "system", "content": f"You are a professional interviewer conducting a {user_profile['interview_type']} interview for a candidate in the {user_profile['field']} field." } ] if history: messages.extend(history) messages.append({"role": "user", "content": message})
response = "" for msg in client.chat_completion(messages, max_tokens=100, stream=True): token = msg.choices[0].delta.content or "" response += token yield response response = client.chat_completion( messages, max_tokens=150, stream=False # Make sure streaming is OFF )
return response.choices[0].message.content
with gr.Blocks() as demo: user_profile = gr.State({"interview_type": "", "field": ""})22 unmodified lines
# Step 3: Interview gr.Markdown("### Step 3: Start Interview") chatbot = gr.ChatInterface(lambda msg, hist: respond(msg, hist, user_profile.value), title="Intervu - AI Interview Practice") chatbot = gr.ChatInterface( lambda msg, hist: respond(msg, hist, user_profile.value), title="Intervu - AI Interview Practice", type="messages" # Important to fix the warning)
demo.launch()
app.py+19-9