Threatthriver commited on
Commit
3942997
1 Parent(s): aea68a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -22
app.py CHANGED
@@ -58,28 +58,25 @@ def respond(
58
  except Exception as e:
59
  yield f"An error occurred: {str(e)}"
60
 
61
- # Define the UI layout with a more user-friendly design
62
- with gr.Blocks() as demo:
63
- gr.Markdown("# 🧠 AI Chatbot Interface")
64
- gr.Markdown("### Customize your AI Chatbot's behavior and responses.")
65
-
66
- with gr.Row():
67
- chatbot = gr.Chatbot()
68
- with gr.Column():
69
- system_message = gr.Textbox(value="You are a friendly Chatbot.", label="System message", lines=2)
70
- max_tokens = gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens")
71
- temperature = gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature")
72
- top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)")
73
-
74
- with gr.Row():
75
- message = gr.Textbox(label="Your message:", lines=1)
76
- submit_btn = gr.Button("Send")
77
-
78
- # Update the chatbot with the new message and response
79
- submit_btn.click(respond,
80
- inputs=[message, chatbot, system_message, max_tokens, temperature, top_p],
81
- outputs=[chatbot],
82
- show_progress=True)
83
 
84
  # Launch the Gradio interface
85
  if __name__ == "__main__":
 
58
  except Exception as e:
59
  yield f"An error occurred: {str(e)}"
60
 
61
+
62
+ # Define the ChatInterface with additional input components for user customization
63
+ demo = gr.ChatInterface(
64
+ fn=respond,
65
+ additional_inputs=[
66
+ gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
67
+ gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
68
+ gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
69
+ gr.Slider(
70
+ minimum=0.1,
71
+ maximum=1.0,
72
+ value=0.95,
73
+ step=0.05,
74
+ label="Top-p (nucleus sampling)",
75
+ ),
76
+ ],
77
+ title="Chatbot Interface",
78
+ description="A customizable chatbot interface using Hugging Face's Inference API.",
79
+ )
 
 
 
80
 
81
  # Launch the Gradio interface
82
  if __name__ == "__main__":