Skip to content

Commit 2008eb8

Browse files
Update app.py
Signed-off-by: PROJECT ZERO <56379955+ProjectZeroDays@users.noreply.github.com>
1 parent bb5d0ad commit 2008eb8

File tree

1 file changed

+1
-123
lines changed

1 file changed

+1
-123
lines changed

modules/baize-ai/app.py

Lines changed: 1 addition & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -102,126 +102,4 @@ def retry(
102102
with gr.Row():
103103
gr.HTML(title)
104104
status_display = gr.Markdown("Success", elem_id="status_display")
105-
gr.Markdown(description_top)
106-
with gr.Row(scale=1).style(equal_height=True):
107-
with gr.Column(scale=5):
108-
with gr.Row(scale=1):
109-
chatbot = gr.Chatbot(elem_id="chuanhu_chatbot").style(height="100%")
110-
with gr.Row(scale=1):
111-
with gr.Column(scale=12):
112-
user_input = gr.Textbox(
113-
show_label=False, placeholder="Enter text"
114-
).style(container=False)
115-
with gr.Column(min_width=70, scale=1):
116-
submitBtn = gr.Button("Send")
117-
with gr.Column(min_width=70, scale=1):
118-
cancelBtn = gr.Button("Stop")
119-
with gr.Row(scale=1):
120-
emptyBtn = gr.Button(
121-
"🧹 New Conversation",
122-
)
123-
retryBtn = gr.Button("🔄 Regenerate")
124-
delLastBtn = gr.Button("🗑️ Remove Last Turn")
125-
with gr.Column():
126-
with gr.Column(min_width=50, scale=1):
127-
with gr.Tab(label="Parameter Setting"):
128-
gr.Markdown("# Parameters")
129-
top_p = gr.Slider(
130-
minimum=-0,
131-
maximum=1.0,
132-
value=0.95,
133-
step=0.05,
134-
interactive=True,
135-
label="Top-p",
136-
)
137-
temperature = gr.Slider(
138-
minimum=0.1,
139-
maximum=2.0,
140-
value=1,
141-
step=0.1,
142-
interactive=True,
143-
label="Temperature",
144-
)
145-
max_length_tokens = gr.Slider(
146-
minimum=0,
147-
maximum=512,
148-
value=512,
149-
step=8,
150-
interactive=True,
151-
label="Max Generation Tokens",
152-
)
153-
max_context_length_tokens = gr.Slider(
154-
minimum=0,
155-
maximum=4096,
156-
value=2048,
157-
step=128,
158-
interactive=True,
159-
label="Max History Tokens",
160-
)
161-
gr.Markdown(description)
162-
163-
predict_args = dict(
164-
fn=predict,
165-
inputs=[
166-
user_question,
167-
chatbot,
168-
history,
169-
top_p,
170-
temperature,
171-
max_length_tokens,
172-
max_context_length_tokens,
173-
],
174-
outputs=[chatbot, history, status_display],
175-
show_progress=True,
176-
)
177-
retry_args = dict(
178-
fn=retry,
179-
inputs=[
180-
user_input,
181-
chatbot,
182-
history,
183-
top_p,
184-
temperature,
185-
max_length_tokens,
186-
max_context_length_tokens,
187-
],
188-
outputs=[chatbot, history, status_display],
189-
show_progress=True,
190-
)
191-
192-
reset_args = dict(
193-
fn=reset_textbox, inputs=[], outputs=[user_input, status_display]
194-
)
195-
196-
transfer_input_args = dict(
197-
fn=transfer_input, inputs=[user_input], outputs=[user_question, user_input, submitBtn], show_progress=True
198-
)
199-
200-
predict_event1 = user_input.submit(**transfer_input_args).then(**predict_args)
201-
202-
predict_event2 = submitBtn.click(**transfer_input_args).then(**predict_args)
203-
204-
emptyBtn.click(
205-
reset_state,
206-
outputs=[chatbot, history, status_display],
207-
show_progress=True,
208-
)
209-
emptyBtn.click(**reset_args)
210-
211-
predict_event3 = retryBtn.click(**retry_args)
212-
213-
delLastBtn.click(
214-
delete_last_conversation,
215-
[chatbot, history],
216-
[chatbot, history, status_display],
217-
show_progress=True,
218-
)
219-
cancelBtn.click(
220-
cancel_outputing, [], [status_display],
221-
cancels=[
222-
predict_event1, predict_event2, predict_event3
223-
]
224-
)
225-
demo.title = "Baize"
226-
227-
demo.queue(concurrency_count=1).launch()
105+
gr.Markdown

0 commit comments

Comments
 (0)