pcuenq HF staff commited on
Commit
0d0112a
1 Parent(s): c86df15

Actually cache examples (#4)

Browse files

- Actually cache examples (b5e8dcf4edfb4ca9d7527aaac3f2f8070b091634)

Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -77,6 +77,14 @@ def generate(
77
  yield history + [(message, response)]
78
 
79
 
 
 
 
 
 
 
 
 
80
  with gr.Blocks(css='style.css') as demo:
81
  gr.Markdown(DESCRIPTION)
82
  gr.DuplicateButton(value='Duplicate Space for private use',
@@ -136,13 +144,13 @@ with gr.Blocks(css='style.css') as demo:
136
  )
137
 
138
  gr.Examples(
139
- examples = [
140
- ["Hello there! How are you doing?"],
141
- ["Can you explain briefly to me what is the Python programming language?"],
142
- ["Explain the plot of Cinderella in a sentence."],
143
- ["How many hours does it take a man to eat a Helicopter?"],
144
- ["Write a 100-word article on 'Benefits of Open-Source in AI research'"]
145
- ],
146
  inputs=textbox,
147
  outputs=[textbox, chatbot],
148
  fn=process_example,
 
77
  yield history + [(message, response)]
78
 
79
 
80
+ def process_example(message: str) -> tuple[str, list[tuple[str, str]]]:
81
+ generator = generate(message, [], DEFAULT_SYSTEM_PROMPT, 1024, 0.95, 1,
82
+ 1000)
83
+ for x in generator:
84
+ pass
85
+ return '', x
86
+
87
+
88
  with gr.Blocks(css='style.css') as demo:
89
  gr.Markdown(DESCRIPTION)
90
  gr.DuplicateButton(value='Duplicate Space for private use',
 
144
  )
145
 
146
  gr.Examples(
147
+ examples=[
148
+ 'Hello there! How are you doing?',
149
+ 'Can you explain briefly to me what is the Python programming language?',
150
+ 'Explain the plot of Cinderella in a sentence.',
151
+ 'How many hours does it take a man to eat a Helicopter?',
152
+ "Write a 100-word article on 'Benefits of Open-Source in AI research'",
153
+ ],
154
  inputs=textbox,
155
  outputs=[textbox, chatbot],
156
  fn=process_example,