SrijitMukherjee commited on
Commit
3d8291f
·
verified ·
1 Parent(s): b26224b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -4,7 +4,7 @@ from huggingface_hub import InferenceClient
4
  # Initialize the InferenceClient
5
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
6
 
7
- # Define the function for the button click
8
  def generate_output():
9
  # Initialize the prompt
10
  prompt = "Initialize your prompt here."
@@ -12,11 +12,17 @@ def generate_output():
12
  response = client.text_generation(prompt, max_new_tokens=512, temperature=0.7, top_p=0.95)
13
  return response[0]['generated_text']
14
 
15
- # Create a Gradio interface with a button
16
- button = gr.Button("Generate Output", onclick=generate_output)
 
 
17
 
18
- # Combine the button with a text output
19
- interface = gr.Interface(button, gr.outputs.Textbox(label="Output"))
 
 
 
 
20
 
21
  # Launch the app
22
  if __name__ == "__main__":
 
4
  # Initialize the InferenceClient
5
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
6
 
7
+ # Define the function for generating output based on a prompt
8
  def generate_output():
9
  # Initialize the prompt
10
  prompt = "Initialize your prompt here."
 
12
  response = client.text_generation(prompt, max_new_tokens=512, temperature=0.7, top_p=0.95)
13
  return response[0]['generated_text']
14
 
15
+ # Define the action to be taken when the button is clicked
16
+ def button_click():
17
+ # Generate output based on the prompt when the button is clicked
18
+ output_textbox.update(generate_output())
19
 
20
+ # Create a Gradio interface with a button and a text output
21
+ button = gr.Button("Generate Output", onclick=button_click)
22
+ output_textbox = gr.outputs.Textbox(label="Output")
23
+
24
+ # Combine the button and the text output in a Gradio interface
25
+ interface = gr.Interface(button, output_textbox)
26
 
27
  # Launch the app
28
  if __name__ == "__main__":