@@ -335,10 +335,12 @@ def get_image_cache(path):
335
335
refresh_svg = '''<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="tabler-icon tabler-icon-repeat"><path d="M4 12v-3a3 3 0 0 1 3 -3h13m-3 -3l3 3l-3 3"></path><path d="M20 12v3a3 3 0 0 1 -3 3h-13m3 3l-3 -3l3 -3"></path></svg>'''
336
336
continue_svg = '''<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-player-play"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M7 4v16l13 -8z" /></svg>'''
337
337
remove_svg = '''<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-trash"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 7l16 0" /><path d="M10 11l0 6" /><path d="M14 11l0 6" /><path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12" /><path d="M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3" /></svg>'''
338
+ branch_svg = '''<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-git-branch"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M7 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" /><path d="M7 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" /><path d="M17 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" /><path d="M7 8l0 8" /><path d="M9 18h6a2 2 0 0 0 2 -2v-5" /><path d="M14 14l3 -3l3 3" /></svg>'''
338
339
info_svg = '''<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="thinking-icon tabler-icon tabler-icon-info-circle"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 2a10 10 0 0 1 0 20a10 10 0 0 1 0 -20z" /><path d="M12 16v-4" /><path d="M12 8h.01" /></svg>'''
339
340
info_svg_small = '''<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="thinking-icon tabler-icon tabler-icon-info-circle"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 2a10 10 0 0 1 0 20a10 10 0 0 1 0 -20z" /><path d="M12 16v-4" /><path d="M12 8h.01" /></svg>'''
340
341
341
342
copy_button = f'<button class="footer-button footer-copy-button" title="Copy" onclick="copyToClipboard(this)">{ copy_svg } </button>'
343
+ branch_button = f'<button class="footer-button footer-branch-button" title="Branch here" onclick="branchHere(this)">{ branch_svg } </button>'
342
344
refresh_button = f'<button class="footer-button footer-refresh-button" title="Regenerate" onclick="regenerateClick()">{ refresh_svg } </button>'
343
345
continue_button = f'<button class="footer-button footer-continue-button" title="Continue" onclick="continueClick()">{ continue_svg } </button>'
344
346
remove_button = f'<button class="footer-button footer-remove-button" title="Remove last reply" onclick="removeLastClick()">{ remove_svg } </button>'
@@ -355,6 +357,17 @@ def format_message_timestamp(history, role, index):
355
357
return ""
356
358
357
359
360
+ def actions_html (history , i , info_message = "" ):
361
+ return (f'<div class="message-actions">'
362
+ f'{ copy_button } '
363
+ f'{ refresh_button if i == len (history ["visible" ]) - 1 else "" } '
364
+ f'{ continue_button if i == len (history ["visible" ]) - 1 else "" } '
365
+ f'{ remove_button if i == len (history ["visible" ]) - 1 else "" } '
366
+ f'{ branch_button } '
367
+ f'{ info_message } '
368
+ f'</div>' )
369
+
370
+
358
371
def generate_instruct_html (history ):
359
372
output = f'<style>{ instruct_css } </style><div class="chat" id="chat" data-mode="instruct"><div class="messages">'
360
373
@@ -386,22 +399,18 @@ def generate_instruct_html(history):
386
399
f'data-raw="{ html .escape (row_internal [0 ], quote = True )} ">'
387
400
f'<div class="text">'
388
401
f'<div class="message-body">{ converted_visible [0 ]} </div>'
389
- f'{ copy_button } '
390
- f'{ info_message_user } '
402
+ f'<div class="message-actions">{ copy_button } { info_message_user } </div>'
391
403
f'</div>'
392
404
f'</div>'
393
405
)
394
406
395
407
output += (
396
408
f'<div class="assistant-message" '
397
- f'data-raw="{ html .escape (row_internal [1 ], quote = True )} ">'
409
+ f'data-raw="{ html .escape (row_internal [1 ], quote = True )} "'
410
+ f'data-index={ i } >'
398
411
f'<div class="text">'
399
412
f'<div class="message-body">{ converted_visible [1 ]} </div>'
400
- f'{ copy_button } '
401
- f'{ refresh_button if i == len (history ["visible" ]) - 1 else "" } '
402
- f'{ continue_button if i == len (history ["visible" ]) - 1 else "" } '
403
- f'{ remove_button if i == len (history ["visible" ]) - 1 else "" } '
404
- f'{ info_message_assistant } '
413
+ f'{ actions_html (history , i , info_message_assistant )} '
405
414
f'</div>'
406
415
f'</div>'
407
416
)
@@ -441,22 +450,20 @@ def generate_cai_chat_html(history, name1, name2, style, character, reset_cache=
441
450
f'<div class="text">'
442
451
f'<div class="username">{ name1 } { user_timestamp } </div>'
443
452
f'<div class="message-body">{ converted_visible [0 ]} </div>'
444
- f'{ copy_button } '
453
+ f'<div class="message-actions"> { copy_button } </div> '
445
454
f'</div>'
446
455
f'</div>'
447
456
)
448
457
449
458
output += (
450
459
f'<div class="message" '
451
- f'data-raw="{ html .escape (row_internal [1 ], quote = True )} ">'
460
+ f'data-raw="{ html .escape (row_internal [1 ], quote = True )} "'
461
+ f'data-index={ i } >'
452
462
f'<div class="circle-bot">{ img_bot } </div>'
453
463
f'<div class="text">'
454
464
f'<div class="username">{ name2 } { assistant_timestamp } </div>'
455
465
f'<div class="message-body">{ converted_visible [1 ]} </div>'
456
- f'{ copy_button } '
457
- f'{ refresh_button if i == len (history ["visible" ]) - 1 else "" } '
458
- f'{ continue_button if i == len (history ["visible" ]) - 1 else "" } '
459
- f'{ remove_button if i == len (history ["visible" ]) - 1 else "" } '
466
+ f'{ actions_html (history , i )} '
460
467
f'</div>'
461
468
f'</div>'
462
469
)
@@ -496,22 +503,18 @@ def generate_chat_html(history, name1, name2, reset_cache=False):
496
503
f'data-raw="{ html .escape (row_internal [0 ], quote = True )} ">'
497
504
f'<div class="text-you">'
498
505
f'<div class="message-body">{ converted_visible [0 ]} </div>'
499
- f'{ copy_button } '
500
- f'{ info_message_user } '
506
+ f'<div class="message-actions">{ copy_button } { info_message_user } </div>'
501
507
f'</div>'
502
508
f'</div>'
503
509
)
504
510
505
511
output += (
506
512
f'<div class="message" '
507
- f'data-raw="{ html .escape (row_internal [1 ], quote = True )} ">'
513
+ f'data-raw="{ html .escape (row_internal [1 ], quote = True )} "'
514
+ f'data-index={ i } >'
508
515
f'<div class="text-bot">'
509
516
f'<div class="message-body">{ converted_visible [1 ]} </div>'
510
- f'{ copy_button } '
511
- f'{ refresh_button if i == len (history ["visible" ]) - 1 else "" } '
512
- f'{ continue_button if i == len (history ["visible" ]) - 1 else "" } '
513
- f'{ remove_button if i == len (history ["visible" ]) - 1 else "" } '
514
- f'{ info_message_assistant } '
517
+ f'{ actions_html (history , i , info_message_assistant )} '
515
518
f'</div>'
516
519
f'</div>'
517
520
)
0 commit comments