Threatthriver commited on
Commit
e84e0fa
1 Parent(s): e7f3548

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -37
app.py CHANGED
@@ -67,41 +67,43 @@ def respond(
67
  yield f"**Error:** {str(e)}"
68
 
69
 
70
- # Define the ChatInterface with additional input components
71
- demo = gr.ChatInterface(
72
- fn=respond,
73
- additional_inputs=[
74
- gr.Textbox(
75
- value="You are a friendly and helpful assistant.",
76
- label="System message",
77
- lines=2
78
- ),
79
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
80
- gr.Slider(minimum=0.1, maximum=2.0, value=0.7, step=0.1, label="Temperature"),
81
- gr.Slider(
82
- minimum=0.1,
83
- maximum=1.0,
84
- value=0.95,
85
- step=0.05,
86
- label="Top-p (nucleus sampling)",
87
- ),
88
- ],
89
- title="Zephyr 7B Beta Chatbot",
90
- description="A customizable chatbot interface using Hugging Face's Zephyr 7B Beta model and Inference API.",
91
- )
92
-
93
- # Add the "Show Updates" button and output area
94
- with gr.Row():
95
- updates_button = gr.Button("Show Latest Updates")
96
- updates_output = gr.Markdown(visible=False) # Initially hidden
97
-
98
- # Define the button's click event
99
- updates_button.click(
100
- fn=lambda: latest_updates,
101
- outputs=updates_output,
102
- show_progress=False
103
- )
104
-
105
- # Launch the Gradio interface
 
 
106
  if __name__ == "__main__":
107
- demo.launch()
 
67
  yield f"**Error:** {str(e)}"
68
 
69
 
70
+ # Define the Gradio interface with the Blocks context
71
+ with gr.Blocks() as demo:
72
+ chat_interface = gr.ChatInterface(
73
+ fn=respond,
74
+ additional_inputs=[
75
+ gr.Textbox(
76
+ value="You are a friendly and helpful assistant.",
77
+ label="System message",
78
+ lines=2
79
+ ),
80
+ gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
81
+ gr.Slider(minimum=0.1, maximum=2.0, value=0.7, step=0.1, label="Temperature"),
82
+ gr.Slider(
83
+ minimum=0.1,
84
+ maximum=1.0,
85
+ value=0.95,
86
+ step=0.05,
87
+ label="Top-p (nucleus sampling)",
88
+ ),
89
+ ],
90
+ title="Zephyr 7B Beta Chatbot",
91
+ description="A customizable chatbot interface using Hugging Face's Zephyr 7B Beta model and Inference API.",
92
+ )
93
+
94
+ # Add the "Show Updates" button and output area
95
+ with gr.Row():
96
+ updates_button = gr.Button("Show Latest Updates")
97
+ updates_output = gr.Markdown(visible=False)
98
+
99
+ # Define the button's click event (now inside the Blocks context)
100
+ updates_button.click(
101
+ fn=lambda: latest_updates,
102
+ outputs=updates_output,
103
+ show_progress=False
104
+ )
105
+
106
+
107
+ # Launch the Gradio interface
108
  if __name__ == "__main__":
109
+ demo.launch()