Spaces:
Sleeping
Sleeping
aaaaa
Browse files11 unmodified lines1213141515161718104 unmodified lines12312412512612712812912612712812913013113213313113213313413513613713813513613713813914014014114214214314414414514614714814915015115215315415515615715815916016116216316414614714814915016715115211 unmodified lines
def respond( message, history=None, # Default to None history: list[tuple[str, str]], system_message="You are a friendly Chatbot.", max_tokens=512, temperature=0.7,104 unmodified lines}"""
# # Define the interface# with gr.Blocks(css=custom_css) as demo:# gr.Markdown("<h1 style='text-align: center;'>π Fancy AI Chatbot π</h1>")# gr.Markdown("Interact with the AI chatbot using customizable settings below.")# Define the interfacewith gr.Blocks(css=custom_css) as demo: gr.Markdown("<h1 style='text-align: center;'>π Fancy AI Chatbot π</h1>") gr.Markdown("Interact with the AI chatbot using customizable settings below.")
# with gr.Row():# system_message = gr.Textbox(value="You are a friendly Chatbot.", label="System message", interactive=True)# use_local_model = gr.Checkbox(label="Use Local Model", value=False) with gr.Row(): system_message = gr.Textbox(value="You are a friendly Chatbot.", label="System message", interactive=True) use_local_model = gr.Checkbox(label="Use Local Model", value=False)
# with gr.Row():# max_tokens = gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens")# temperature = gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature")# top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)") with gr.Row(): max_tokens = gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens") temperature = gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature") top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)")
# chat_history = gr.Chatbot(label="Chat") chat_history = gr.Chatbot(label="Chat")
# user_input = gr.Textbox(show_label=False, placeholder="Type your message here...") user_input = gr.Textbox(show_label=False, placeholder="Type your message here...")
# cancel_button = gr.Button("Cancel Inference", variant="danger") cancel_button = gr.Button("Cancel Inference", variant="danger")
# # Adjusted to ensure history is maintained and passed correctly# user_input.submit(respond, [user_input, chat_history, system_message, max_tokens, temperature, top_p, use_local_model], chat_history)# cancel_button.click(cancel_inference)
# if __name__ == "__main__":# demo.launch(share=False) # Remove share=True because it's not supported on HF Spaces
demo = gr.ChatInterface( fn=respond, additional_inputs=[ gr.Textbox(value="You are a friendly Chatbot.", label="System message"), gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"), gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"), gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"), gr.Checkbox(label="Use Local Model", value=False) ], cancel=gr.Button("Cancel Inference", variant="danger"), css=custom_css # Apply the custom CSS styling) # Adjusted to ensure history is maintained and passed correctly user_input.submit(respond, [user_input, chat_history, system_message, max_tokens, temperature, top_p, use_local_model], chat_history) cancel_button.click(cancel_inference)
if __name__ == "__main__": demo.launch(share=True) demo.launch(share=False) # Remove share=True because it's not supported on HF Spaces
app.py+20-35