faizah2512 commited on
Commit
bd660b0
·
verified ·
1 Parent(s): 838c6ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -23
app.py CHANGED
@@ -3,6 +3,7 @@ from huggingface_hub import InferenceClient
3
 
4
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
5
 
 
6
  def respond(
7
  message,
8
  history: list[tuple[str, str]],
@@ -35,27 +36,25 @@ def respond(
35
  response += token
36
  yield response
37
 
38
- # Create a custom function for the theme and interface
39
- def create_interface():
40
- with gr.Blocks(theme='HaleyCH/HaleyCH_Theme') as demo:
41
- with gr.Row():
42
- with gr.Column():
43
- # Inputs for system message, max tokens, temperature, top_p
44
- system_message = gr.Textbox(value="You are a friendly Chatbot.", label="System message")
45
- max_tokens = gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens")
46
- temperature = gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature")
47
- top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)")
48
-
49
- # Chat Interface
50
- chat = gr.ChatInterface(
51
- fn=respond,
52
- inputs=[system_message, max_tokens, temperature, top_p],
53
- theme='HaleyCH/HaleyCH_Theme'
54
- )
55
-
56
- return demo
57
-
58
- # Launch the Gradio app
59
  if __name__ == "__main__":
60
- interface = create_interface()
61
- interface.launch()
 
3
 
4
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
5
 
6
+
7
  def respond(
8
  message,
9
  history: list[tuple[str, str]],
 
36
  response += token
37
  yield response
38
 
39
+ """
40
+ For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
41
+ """
42
+ demo = gr.ChatInterface(
43
+ respond,
44
+ additional_inputs=[
45
+ gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
46
+ gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
47
+ gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
48
+ gr.Slider(
49
+ minimum=0.1,
50
+ maximum=1.0,
51
+ value=0.95,
52
+ step=0.05,
53
+ label="Top-p (nucleus sampling)",
54
+ ),
55
+ ],
56
+ )
57
+
58
+
 
59
  if __name__ == "__main__":
60
+ demo.launch()