Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -42,15 +42,21 @@ def generate(
|
|
42 |
input=None,
|
43 |
temperature=0.1,
|
44 |
top_p=0.95,
|
45 |
-
top_k=40
|
|
|
46 |
result = ""
|
47 |
if input:
|
48 |
instruction = ins_inp.format(instruction, input)
|
49 |
else:
|
50 |
instruction = ins.format(instruction)
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
|
56 |
examples = [
|
@@ -139,6 +145,7 @@ with gr.Blocks(theme=seafoam, analytics_enabled=False, css=css) as demo:
|
|
139 |
temperature = gr.components.Slider(minimum=0, maximum=1, value=0.1, label="Temperature")
|
140 |
top_p = gr.components.Slider(minimum=0, maximum=1, value=0.95, label="Top p")
|
141 |
top_k = gr.components.Slider(minimum=0, maximum=100, step=1, value=40, label="Top k")
|
|
|
142 |
|
143 |
|
144 |
with gr.Box():
|
@@ -155,7 +162,7 @@ with gr.Blocks(theme=seafoam, analytics_enabled=False, css=css) as demo:
|
|
155 |
|
156 |
|
157 |
|
158 |
-
submit.click(generate, inputs=[instruction, input, temperature, top_p, top_k], outputs=[output])
|
159 |
instruction.submit(generate, inputs=[instruction], outputs=[output])
|
160 |
|
161 |
demo.queue(concurrency_count=1).launch(debug=True)
|
|
|
42 |
input=None,
|
43 |
temperature=0.1,
|
44 |
top_p=0.95,
|
45 |
+
top_k=40,
|
46 |
+
stram=True):
|
47 |
result = ""
|
48 |
if input:
|
49 |
instruction = ins_inp.format(instruction, input)
|
50 |
else:
|
51 |
instruction = ins.format(instruction)
|
52 |
+
if stream:
|
53 |
+
for x in llm(instruction, stop=['### Instruction:', '### End'], stream=True, temperature=temperature, top_p=top_p, top_k=top_k):
|
54 |
+
result += x['choices'][0]['text']
|
55 |
+
yield result
|
56 |
+
else:
|
57 |
+
for x in llm(instruction, stop=['### Instruction:', '### End'], temperature=temperature, top_p=top_p, top_k=top_k):
|
58 |
+
result += x['choices'][0]['text']
|
59 |
+
return result
|
60 |
|
61 |
|
62 |
examples = [
|
|
|
145 |
temperature = gr.components.Slider(minimum=0, maximum=1, value=0.1, label="Temperature")
|
146 |
top_p = gr.components.Slider(minimum=0, maximum=1, value=0.95, label="Top p")
|
147 |
top_k = gr.components.Slider(minimum=0, maximum=100, step=1, value=40, label="Top k")
|
148 |
+
stream = gr.Checkbox(value=True, label="Stream", info="Stream")
|
149 |
|
150 |
|
151 |
with gr.Box():
|
|
|
162 |
|
163 |
|
164 |
|
165 |
+
submit.click(generate, inputs=[instruction, input, temperature, top_p, top_k, stream], outputs=[output])
|
166 |
instruction.submit(generate, inputs=[instruction], outputs=[output])
|
167 |
|
168 |
demo.queue(concurrency_count=1).launch(debug=True)
|