CedricZ commited on
Commit
0d2ec57
1 Parent(s): a8df0db

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -16,14 +16,17 @@ def greet(prompt, temperature, max_lenth, top_p, samples):
16
  #Samples
17
  sample_input = {'Sample 1': 'Hi, this is a demo prompt for you',
18
  'Sample 2': 'Alber Einstein is a famous physicist graduated from',
19
- 'Sample 3': 'University of Zurich locate at'}
20
 
21
  #Choose between samples
22
  if samples and prompt == '':
23
  prompt = sample_input[samples]
24
 
25
- a = generator(prompt, max_new_tokens=max_lenth, generation_config=config)
26
- return a[0]['generated_text']
 
 
 
27
 
28
  demo = gr.Interface(
29
  fn=greet,
 
16
  #Samples
17
  sample_input = {'Sample 1': 'Hi, this is a demo prompt for you',
18
  'Sample 2': 'Alber Einstein is a famous physicist graduated from',
19
+ 'Sample 3': 'University of Zurich located in'}
20
 
21
  #Choose between samples
22
  if samples and prompt == '':
23
  prompt = sample_input[samples]
24
 
25
+ #Streaming the output
26
+ for i in range(max_lenth):
27
+ a = generator(prompt, max_new_tokens=1, generation_config=config)
28
+ prompt=a[0]['generated_text']
29
+ yield a[0]['generated_text']
30
 
31
  demo = gr.Interface(
32
  fn=greet,