Spaces:
Runtime error
Runtime error
Update app.py
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273import gradio as gr# Respond to user inputdef chatbot_response(user_input):return f"π€ Thanks! Thatβs a strong example of an interview response."# Show/hide the tip "pop-up"def show_tip():return gr.update(visible=True)def hide_tip():return gr.update(visible=False)with gr.Blocks(css=""".popup-box {position: fixed;top: 30%;left: 50%;transform: translate(-50%, -50%);background-color: white;border: 2px solid #333;padding: 20px;z-index: 999;box-shadow: 0 0 10px rgba(0,0,0,0.3);border-radius: 12px;}.overlay {position: fixed;top: 0;left: 0;width: 100%;height: 100%;background: rgba(0,0,0,0.4);z-index: 998;}""") as demo:gr.Markdown("## π€ Interview Chatbot")gr.Markdown("Write your answer below or click an example:")# User input and bot outputuser_input = gr.Textbox(label="Your Answer", placeholder="Type your interview response here...")submit_btn = gr.Button("Submit")bot_output = gr.Textbox(label="Bot Reply")# Example answers for interview questionsgr.Examples(examples=[["I led a cross-functional team to deliver a project ahead of schedule."],["I handled a client complaint by staying calm and offering a solution."],["I used data to reduce delivery time by 15% on a logistics project."]],inputs=user_input)# Submit logicsubmit_btn.click(fn=chatbot_response, inputs=user_input, outputs=bot_output)# Button to show interview tiptip_button = gr.Button("π‘ Show Interview Tip")# Tip pop-up with overlaywith gr.Group(visible=False) as popup:gr.HTML('<div class="overlay"></div>')with gr.Column(elem_classes="popup-box"):gr.Markdown("π§ **Tip:** Use the **STAR method** β Situation, Task, Action, Result β to structure your answers.")close_btn = gr.Button("β Close Tip")# Show/hide logictip_button.click(fn=show_tip, outputs=popup)close_btn.click(fn=hide_tip, outputs=popup)demo.launch()123456789101112131415161718192021222324import gradio as grfrom huggingface_hub import InferenceClientclient = InferenceClient("HuggingFaceH4/zephyr-7b-beta") #change LLMdef respond(message, history):messages = [{"role": "system", "content": "You are a helpful chatbot."}]if history:messages.extend(history)messages.append({"role": "user", "content": message})response = ""for message in client.chat_completion(messages,max_tokens=100,stream=True,):token = message.choices[0].delta.contentresponse += tokenyield responsechatbot = gr.ChatInterface(respond, type="messages")chatbot.launch()
app.py+23-72