Spaces:
Runtime error
Runtime error
Update app.py
Browse files12 unmodified lines13141516171819202122232425262728293031323322 unmodified lines5657585960616212 unmodified linesdef 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."returnmessages = [{"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 += tokenyield responsewith gr.Blocks() as demo:user_profile = gr.State({"interview_type": "", "field": ""})22 unmodified lines# Step 3: Interviewgr.Markdown("### Step 3: Start Interview")chatbot = gr.ChatInterface(lambda msg, hist: respond(msg, hist, user_profile.value), title="Intervu - AI Interview Practice")demo.launch()12 unmodified lines131415161718192021222324252627282930313233343536373822 unmodified lines61626364656667686970717212 unmodified linesdef respond(message, history, user_profile):if not user_profile["interview_type"] or not user_profile["field"]: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."}]if history:messages.extend(history)messages.append({"role": "user", "content": message})response = client.chat_completion(messages,max_tokens=150,stream=False # Make sure streaming is OFF)return response.choices[0].message.contentwith gr.Blocks() as demo:user_profile = gr.State({"interview_type": "", "field": ""})22 unmodified lines# Step 3: Interviewgr.Markdown("### Step 3: Start Interview")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