Spaces:
Runtime error
Runtime error
feat: simplification of UI
Browse files
app.py
CHANGED
|
@@ -240,12 +240,27 @@ textbox = gr.Textbox(
|
|
| 240 |
placeholder="...Type something here",
|
| 241 |
rtl=True,
|
| 242 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
chat_interface = gr.ChatInterface(
|
| 244 |
generate,
|
| 245 |
chatbot=chatbot,
|
| 246 |
textbox=textbox,
|
| 247 |
#examples=examples,
|
| 248 |
additional_inputs=additional_inputs,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
cache_examples=False,
|
| 250 |
)
|
| 251 |
|
|
@@ -292,17 +307,28 @@ def vote(data: gr.LikeData):
|
|
| 292 |
]
|
| 293 |
jsonlfile.write("\n".join(json_data) + "\n")
|
| 294 |
|
| 295 |
-
|
|
|
|
| 296 |
global USERNAME
|
| 297 |
global NAME
|
| 298 |
-
|
| 299 |
-
if profile is None:
|
| 300 |
USERNAME = "guest"
|
| 301 |
NAME = "guest"
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
|
| 307 |
with gr.Blocks(css=CSS) as demo:
|
| 308 |
|
|
@@ -315,10 +341,13 @@ with gr.Blocks(css=CSS) as demo:
|
|
| 315 |
)
|
| 316 |
with gr.Row():
|
| 317 |
with gr.Column():
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
|
|
|
|
|
|
|
|
|
| 322 |
#gr.LogoutButton()
|
| 323 |
|
| 324 |
chatbot.like(vote, None, None)
|
|
|
|
| 240 |
placeholder="...Type something here",
|
| 241 |
rtl=True,
|
| 242 |
)
|
| 243 |
+
|
| 244 |
+
textbox_whoareu = gr.Textbox(
|
| 245 |
+
label="textbox_whoareu",
|
| 246 |
+
container=False,
|
| 247 |
+
show_label=False,
|
| 248 |
+
lines=1,
|
| 249 |
+
placeholder="Who are you?",
|
| 250 |
+
rtl=False,
|
| 251 |
+
)
|
| 252 |
+
|
| 253 |
chat_interface = gr.ChatInterface(
|
| 254 |
generate,
|
| 255 |
chatbot=chatbot,
|
| 256 |
textbox=textbox,
|
| 257 |
#examples=examples,
|
| 258 |
additional_inputs=additional_inputs,
|
| 259 |
+
submit_btn = "Generate",
|
| 260 |
+
stop_btn = None,
|
| 261 |
+
retry_btn = None,
|
| 262 |
+
undo_btn = None,
|
| 263 |
+
clear_btn = None,
|
| 264 |
cache_examples=False,
|
| 265 |
)
|
| 266 |
|
|
|
|
| 307 |
]
|
| 308 |
jsonlfile.write("\n".join(json_data) + "\n")
|
| 309 |
|
| 310 |
+
|
| 311 |
+
def save_whotheyare(x):
|
| 312 |
global USERNAME
|
| 313 |
global NAME
|
| 314 |
+
if len(x) == 0:
|
|
|
|
| 315 |
USERNAME = "guest"
|
| 316 |
NAME = "guest"
|
| 317 |
+
else:
|
| 318 |
+
USERNAME = ""
|
| 319 |
+
NAME = x
|
| 320 |
+
|
| 321 |
+
# def hello(profile: gr.OAuthProfile | None) -> str:
|
| 322 |
+
# global USERNAME
|
| 323 |
+
# global NAME
|
| 324 |
+
# #print(dir(profile))
|
| 325 |
+
# if profile is None:
|
| 326 |
+
# USERNAME = "guest"
|
| 327 |
+
# NAME = "guest"
|
| 328 |
+
# return "I don't know you. Please login:"
|
| 329 |
+
# NAME = profile.name
|
| 330 |
+
# USERNAME = profile.preferred_username
|
| 331 |
+
# return f"Hello {profile.name}"
|
| 332 |
|
| 333 |
with gr.Blocks(css=CSS) as demo:
|
| 334 |
|
|
|
|
| 341 |
)
|
| 342 |
with gr.Row():
|
| 343 |
with gr.Column():
|
| 344 |
+
textbox_whoareu.render()
|
| 345 |
+
textbox_whoareu.change(fn=save_whotheyare, inputs=textbox_whoareu, outputs=None,
|
| 346 |
+
show_progress = False, status_tracker = None)
|
| 347 |
+
# gr.Markdown().attach_load_event(hello, None)
|
| 348 |
+
# with gr.Row():
|
| 349 |
+
# with gr.Column():
|
| 350 |
+
# gr.LoginButton()
|
| 351 |
#gr.LogoutButton()
|
| 352 |
|
| 353 |
chatbot.like(vote, None, None)
|