Upload app.py
Browse files
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
|
20 |
|
21 |
#Choose between samples
|
22 |
if samples and prompt == '':
|
23 |
prompt = sample_input[samples]
|
24 |
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
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,
|