eliebak HF staff commited on
Commit
d64704c
1 Parent(s): 74bce70

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -4,8 +4,9 @@ import gradio as gr
4
  from huggingface_hub import InferenceClient
5
  import torch
6
  import spaces
 
7
  # Initialize the client with your model
8
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta") # Replace with your model's name or endpoint
9
 
10
  default_system = 'You are a helpful assistant'
11
 
@@ -36,9 +37,14 @@ def modify_system_session(system):
36
  if not system:
37
  system = default_system
38
  return system, system, []
 
39
  def use_example(example):
40
  return example
41
 
 
 
 
 
42
  with gr.Blocks() as demo:
43
  gr.Markdown("<h1 style='text-align: center;'>LLM.C Chat Demo</h1>")
44
 
@@ -74,10 +80,8 @@ with gr.Blocks() as demo:
74
  modify_system.click(fn=modify_system_session, inputs=[system_input], outputs=[system_state, system_input, chatbot])
75
 
76
  # Event handlers for example prompts
77
- example1.click(use_example, inputs=[], outputs=[message],
78
- _js="(x) => 'In a shocking finding, scientist discovered a herd of unicorns living in a remote, previously unexplored valley, in the Andes Mountains. Even more surprising to the researchers was the fact that the unicorns spoke perfect English.'")
79
- example2.click(use_example, inputs=[], outputs=[message],
80
- _js="(x) => 'Explain the grandfather paradox in time travel and propose a potential resolution.'")
81
 
82
  gr.Markdown(
83
  """
 
4
  from huggingface_hub import InferenceClient
5
  import torch
6
  import spaces
7
+
8
  # Initialize the client with your model
9
+ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta") # Replace with your model's name or endpoint
10
 
11
  default_system = 'You are a helpful assistant'
12
 
 
37
  if not system:
38
  system = default_system
39
  return system, system, []
40
+
41
  def use_example(example):
42
  return example
43
 
44
+ # Define example prompts
45
+ unicorn_example = "In a shocking finding, scientist discovered a herd of unicorns living in a remote, previously unexplored valley, in the Andes Mountains. Even more surprising to the researchers was the fact that the unicorns spoke perfect English."
46
+ time_travel_example = "Explain the grandfather paradox in time travel and propose a potential resolution."
47
+
48
  with gr.Blocks() as demo:
49
  gr.Markdown("<h1 style='text-align: center;'>LLM.C Chat Demo</h1>")
50
 
 
80
  modify_system.click(fn=modify_system_session, inputs=[system_input], outputs=[system_state, system_input, chatbot])
81
 
82
  # Event handlers for example prompts
83
+ example1.click(fn=use_example, inputs=[], outputs=[message], _js=f"() => '{unicorn_example}'")
84
+ example2.click(fn=use_example, inputs=[], outputs=[message], _js=f"() => '{time_travel_example}'")
 
 
85
 
86
  gr.Markdown(
87
  """