Spaces:
Sleeping
Sleeping
aaaaa
Browse files11 unmodified lines12131415161718104 unmodified lines12312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616711 unmodified linesdef respond(message,history=None, # Default to Nonesystem_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.")# 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)")# chat_history = gr.Chatbot(label="Chat")# user_input = gr.Textbox(show_label=False, placeholder="Type your message here...")# 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 Spacesdemo = 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)if __name__ == "__main__":demo.launch(share=True)11 unmodified lines12131415161718104 unmodified lines12312412512612712812913013113213313413513613713813914014114214314414514614714814915015115211 unmodified linesdef respond(message,history: list[tuple[str, str]],system_message="You are a friendly Chatbot.",max_tokens=512,temperature=0.7,104 unmodified lines}"""# 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():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")user_input = gr.Textbox(show_label=False, placeholder="Type your message here...")cancel_button = gr.Button("Cancel Inference", variant="danger")# Adjusted to ensure history is maintained and passed correctlyuser_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
app.py+20-35