Improved UI (#6575)

This commit is contained in:
oobabooga 2024-12-17 00:47:41 -03:00 committed by GitHub
parent dc56fcff12
commit d769618591
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 884 additions and 254 deletions

Binary file not shown.

Binary file not shown.

View File

@ -16,6 +16,6 @@
} }
.message { .message {
padding-bottom: 30px; padding-bottom: 2em;
grid-template-columns: 70px minmax(0, 1fr); grid-template-columns: 70px minmax(0, 1fr);
} }

View File

@ -1,7 +1,7 @@
.message { .message {
display: grid; display: grid;
grid-template-columns: 60px minmax(0, 1fr); grid-template-columns: 60px minmax(0, 1fr);
padding-bottom: 15px; padding-bottom: 2em;
font-size: 15px; font-size: 15px;
font-family: 'Noto Sans', Helvetica, Arial, sans-serif; font-family: 'Noto Sans', Helvetica, Arial, sans-serif;
line-height: 22.5px !important; line-height: 22.5px !important;

View File

@ -1,21 +1,52 @@
.chat { .chat {
background: transparent; background: transparent;
padding: 24px 19px; padding: 0;
padding-right: 19px !important;
padding-top: 0; padding-top: 0;
} }
.chat > .messages { .chat > .messages:first-child {
padding-top: 18px !important; padding-top: 0 !important;
} }
.message { .chat > .messages > :last-child {
display: grid; margin-bottom: 1.7rem !important;
grid-template-columns: 60px 1fr; }
padding-bottom: 25px;
font-size: 15px; .chat .message-body p, .chat .message-body li {
font-family: 'Noto Sans', Helvetica, Arial, sans-serif; font-size: 1rem !important;
line-height: 24px; line-height: 28px !important;
}
.dark .chat .message-body p, .dark .chat .message-body li {
color: #d1d5db !important;
}
.chat .message-body p,
.chat .message-body ul,
.chat .message-body ol {
margin-top: 1.25em !important;
margin-bottom: 1.25em !important;
}
.chat .message-body p:first-child,
.chat .message-body ul:first-child,
.chat .message-body ol:first-child {
margin-top: 0 !important;
}
.chat .message-body p:last-child,
.chat .message-body ul:last-child,
.chat .message-body ol:last-child {
margin-bottom: 0 !important;
}
.chat .message-body li {
margin-top: 1.25em !important;
margin-bottom: 1.25em !important;
}
.user-message, .assistant-message {
font-family: Inter, Helvetica, Arial, sans-serif;
} }
.message:first-child { .message:first-child {
@ -26,49 +57,43 @@
display: none; display: none;
} }
.message-body p, .message-body li { .chat .user-message {
font-size: 15px !important; padding: 1.5rem 1rem;
line-height: 24px !important; border-radius: 0;
}
.message-body p, .chat .message-body ul, .chat .message-body ol {
margin-bottom: 16px !important;
}
.message-body p:last-child, .chat .message-body ul:last-child, .chat .message-body ol:last-child {
margin-bottom: 0 !important;
}
.gradio-container .chat .assistant-message {
padding: 20px;
background: #f4f4f4;
margin-top: 9px !important;
margin-bottom: 12px !important;
border-radius: 7px;
border: 1px solid var(--border-color-primary);
}
.dark .chat .assistant-message {
background: var(--color-grey-800);
}
.gradio-container .chat .user-message {
padding: 20px;
padding-left: 0;
padding-right: 0;
background-color: transparent;
border-radius: 8px;
border-bottom-right-radius: 0; border-bottom-right-radius: 0;
} }
.gradio-container .chat .assistant-message:last-child, .gradio-container .chat .user-message:last-child { .chat .assistant-message {
margin-bottom: 0 !important; background: #f4f4f4;
padding: 1.5rem 1rem;
border-radius: 0;
border: 0;
} }
code { .dark .chat .user-message {
background: transparent;
}
.dark .chat .assistant-message {
background: var(--light-gray);
}
.chat .user-message .text,
.chat .assistant-message .text {
max-width: 40.25rem;
margin-left: auto;
margin-right: auto;
}
/* Create space between two assistant messages in a row */
.assistant-message + .assistant-message {
margin-top: 1.5rem;
}
pre > code {
background-color: #f3f4f6 !important; background-color: #f3f4f6 !important;
} }
.dark code { .dark pre > code {
background-color: #1f2937 !important; background-color: #1f2937 !important;
} }

View File

@ -1,7 +1,41 @@
:root {
--darker-gray: #202123;
--dark-gray: #343541;
--light-gray: #444654;
--light-theme-gray: #f4f4f4;
--border-color-dark: #525252;
--header-width: 112px;
--selected-item-color-dark: #32333e;
}
@font-face {
font-family: Inter;
src: url('file/css/Inter/Inter-VariableFont_opsz,wght.ttf') format('truetype');
font-weight: 100 900;
font-style: normal;
}
@font-face {
font-family: Inter;
src: url('file/css/Inter/Inter-Italic-VariableFont_opsz,wght.ttf') format('truetype');
font-weight: 100 900;
font-style: italic;
}
.tabs.svelte-710i53 { .tabs.svelte-710i53 {
margin-top: 0 margin-top: 0
} }
.padded.svelte-12cmxck {
padding: 3px 0;
}
div.svelte-sfqy0y,
div.svelte-iyf88w {
background: transparent;
border: 0;
}
.py-6 { .py-6 {
padding-top: 2.5rem padding-top: 2.5rem
} }
@ -19,7 +53,7 @@
height: 39.594px; height: 39.594px;
align-self: end; align-self: end;
line-height: 1em; line-height: 1em;
border-radius: 0.5em; border-radius: 0.375rem;
flex: none; flex: none;
} }
@ -46,10 +80,6 @@
min-height: 0 min-height: 0
} }
.dark svg {
fill: white;
}
.dark a { .dark a {
color: white !important; color: white !important;
} }
@ -62,14 +92,20 @@ ol li p, ul li p {
border: 0; border: 0;
} }
#default-tab, #notebook-tab, #parameters, #chat-settings, #lora, #training-tab, #model-tab, #session-tab {
padding: 1rem;
}
.gradio-container { .gradio-container {
max-width: 100% !important; max-width: 100% !important;
padding-top: 0 !important; padding-top: 0 !important;
} }
#extensions { #extensions {
margin-top: 5px; margin: 5px auto 35px;
margin-bottom: 35px; max-width: 880px;
padding: 1em;
padding-left: calc(var(--header-width) + 1em);
} }
.extension-tab { .extension-tab {
@ -86,20 +122,29 @@ div.svelte-15lo0d8 > *, div.svelte-15lo0d8 > .form > * {
} }
gradio-app > :first-child { gradio-app > :first-child {
padding-left: var(--size-4) !important; padding: 0 !important;
padding-right: var(--size-4) !important;
} }
.header_bar { .header_bar {
background-color: #f4f4f4;
box-shadow: 0 0 3px rgba(22 22 22 / 35%); box-shadow: 0 0 3px rgba(22 22 22 / 35%);
margin-bottom: 0; margin-bottom: 0;
overflow-x: scroll; overflow-x: scroll;
margin-left: calc(-1 * var(--size-4));
margin-right: calc(-1 * var(--size-4));
display: block !important;
text-wrap: nowrap; text-wrap: nowrap;
z-index: 90; z-index: 90;
position: fixed;
display: flex !important;
flex-direction: column;
height: 100dvh;
width: var(--header-width);
}
.header_bar button {
margin: 0;
padding: 0.75rem;
}
.header_bar button.selected {
border: 0;
} }
.dark .header_bar { .dark .header_bar {
@ -113,23 +158,23 @@ gradio-app > :first-child {
} }
.textbox_default textarea { .textbox_default textarea {
height: calc(100dvh - 271px); height: calc(100dvh - 201px);
} }
.textbox_default_output textarea { .textbox_default_output textarea {
height: calc(100dvh - 185px); height: calc(100dvh - 117px);
} }
.textbox textarea { .textbox textarea {
height: calc(100dvh - 241px); height: calc(100dvh - 172px);
} }
.textbox_logits textarea { .textbox_logits textarea {
height: calc(100dvh - 236px); height: calc(100dvh - 205px);
} }
.textbox_logits_notebook textarea { .textbox_logits_notebook textarea {
height: calc(100dvh - 292px); height: calc(100dvh - 221px);
} }
.monospace textarea { .monospace textarea {
@ -149,24 +194,6 @@ gradio-app > :first-child {
color: #efefef !important; color: #efefef !important;
} }
@media screen and (width <= 711px) {
.textbox_default textarea {
height: calc(100dvh - 259px);
}
div .default-token-counter {
top: calc( 0.5 * (100dvh - 236px) ) !important;
}
.transparent-substring {
display: none;
}
.hover-menu {
min-width: 250px !important;
}
}
/* Hide the gradio footer */ /* Hide the gradio footer */
footer { footer {
display: none !important; display: none !important;
@ -227,11 +254,13 @@ button {
.pretty_scrollbar::-webkit-scrollbar-thumb, .pretty_scrollbar::-webkit-scrollbar-thumb,
.pretty_scrollbar::-webkit-scrollbar-thumb:hover { .pretty_scrollbar::-webkit-scrollbar-thumb:hover {
background: var(--neutral-300); background: var(--neutral-300);
border-radius: 30px;
} }
.dark .pretty_scrollbar::-webkit-scrollbar-thumb, .dark .pretty_scrollbar::-webkit-scrollbar-thumb,
.dark .pretty_scrollbar::-webkit-scrollbar-thumb:hover { .dark .pretty_scrollbar::-webkit-scrollbar-thumb:hover {
background: var(--neutral-700); background: #ccc;
border-radius: 10px;
} }
.pretty_scrollbar::-webkit-resizer { .pretty_scrollbar::-webkit-resizer {
@ -239,7 +268,8 @@ button {
} }
.dark .pretty_scrollbar::-webkit-resizer { .dark .pretty_scrollbar::-webkit-resizer {
background: #374151; background: #ccc;
border-radius: 10px;
} }
.pretty_scrollbar::-webkit-scrollbar-corner { .pretty_scrollbar::-webkit-scrollbar-corner {
@ -251,20 +281,26 @@ audio {
} }
/* Copied from https://github.com/AUTOMATIC1111/stable-diffusion-webui */ /* Copied from https://github.com/AUTOMATIC1111/stable-diffusion-webui */
.token-counter { #default-token-counter, #notebook-token-counter {
position: absolute !important; position: absolute !important;
top: calc( 0.5 * (100dvh - 218px) ) !important;
right: 2px;
z-index: 100; z-index: 100;
background: var(--input-background-fill) !important; background: var(--input-background-fill) !important;
min-height: 0 !important; min-height: 0 !important;
width: 0;
text-align: left;
direction: rtl;
right: 5px;
} }
.default-token-counter { #default-token-counter {
top: calc( 0.5 * (100dvh - 248px) ) !important; top: calc(100dvh - 200px) !important;
} }
.token-counter span { #notebook-token-counter {
top: calc(100dvh - 171px) !important;
}
#default-token-counter span, #notebook-token-counter span {
padding: 1px; padding: 1px;
box-shadow: 0 0 0 0.3em rgb(192 192 192 / 15%), inset 0 0 0.6em rgb(192 192 192 / 7.5%); box-shadow: 0 0 0 0.3em rgb(192 192 192 / 15%), inset 0 0 0.6em rgb(192 192 192 / 7.5%);
border: 2px solid rgb(192 192 192 / 40%) !important; border: 2px solid rgb(192 192 192 / 40%) !important;
@ -272,15 +308,15 @@ audio {
} }
.no-background { .no-background {
background: var(--background-fill-primary) !important; background: transparent;
padding: 0 !important; padding: 0 !important;
} }
/* ---------------------------------------------- /* ----------------------------------------------
Chat tab Chat tab
---------------------------------------------- */ ---------------------------------------------- */
.h-\[40vh\], .wrap.svelte-byatnx.svelte-byatnx.svelte-byatnx { .h-\[40dvh\], .wrap.svelte-byatnx.svelte-byatnx.svelte-byatnx {
height: 66.67vh height: 66.67dvh
} }
.gradio-container { .gradio-container {
@ -310,7 +346,13 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
} }
#chat-tab { #chat-tab {
padding-top: 0; padding: 0;
}
#chat-tab > :nth-child(1) {
display: flex;
flex-direction: row;
gap: 0;
} }
#chat-tab button#Generate, #chat-tab button#stop { #chat-tab button#Generate, #chat-tab button#stop {
@ -322,7 +364,6 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
} }
#chat-tab > :first-child, #extensions { #chat-tab > :first-child, #extensions {
max-width: 880px;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
} }
@ -342,61 +383,49 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
.chat { .chat {
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
max-width: 880px;
min-height: var(--chat-height); min-height: var(--chat-height);
overflow-y: auto; overflow-y: auto;
padding-right: 15px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
word-break: break-word; word-break: break-word;
overflow-wrap: anywhere; overflow-wrap: anywhere;
border-top: none; border-top: none;
border-radius: 0 0 0 8px; border-radius: 0;
visibility: visible; visibility: visible;
} }
.chat-parent { .chat-parent {
height: calc(100dvh - 98px - var(--header-height) - var(--input-delta)); height: calc(100dvh - 98px - var(--input-delta));
overflow: auto !important; overflow: auto !important;
border-radius: 0 !important; border-radius: 0 !important;
margin-bottom: var(--input-delta) !important; margin-bottom: var(--input-delta) !important;
} }
/* On desktop, automatically hide the chat scroll bar
* when not hovered. */
@media (hover: hover) and (pointer: fine) {
.chat-parent {
visibility: hidden;
}
.chat-parent:focus, .chat-parent:hover {
visibility: visible;
}
}
.chat-parent .prose { .chat-parent .prose {
visibility: visible; visibility: visible;
} }
.old-ui .chat-parent { .chat .message {
height: calc(100dvh - 192px - var(--header-height) - var(--input-delta)); width: min(100%, 48rem);
margin-bottom: var(--input-delta) !important; margin-left: auto;
margin-right: auto;
text-align: start;
padding-left: 1rem;
padding-right: 1rem;
} }
.chat-parent.bigchat { .chat-parent.bigchat {
height: calc(100dvh - 98px - var(--header-height) - var(--input-delta)) !important; height: calc(100dvh - 98px - var(--input-delta)) !important;
margin-bottom: var(--input-delta) !important; margin-bottom: var(--input-delta) !important;
} }
.chat > .messages { .chat > .messages {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding-top: 25px;
} }
.chat .message:last-child { .chat > .messages > :first-child {
margin-bottom: 0 !important; padding-top: 20px;
padding-bottom: 15px !important;
} }
.message-body h1, .message-body h1,
@ -423,12 +452,12 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
padding-inline-start: 2em; padding-inline-start: 2em;
} }
.message-body li:not(:last-child) { .chat .message-body li:not(:last-child) {
margin-top: 0 !important; margin-top: 0;
margin-bottom: 2px !important; margin-bottom: 2px;
} }
.message-body li:last-child { .chat .message-body li:last-child {
margin-bottom: 0 !important; margin-bottom: 0 !important;
} }
@ -460,7 +489,7 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
margin: 0; margin: 0;
} }
.message-body code { .message-body pre > code {
white-space: pre-wrap !important; white-space: pre-wrap !important;
word-wrap: break-word !important; word-wrap: break-word !important;
border: 1px solid #666; border: 1px solid #666;
@ -471,7 +500,7 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
color: #1f2328; color: #1f2328;
} }
.dark .message-body code { .dark .message-body pre > code {
background: #0d1117 !important; background: #0d1117 !important;
color: rgb(201 209 217); color: rgb(201 209 217);
} }
@ -481,8 +510,18 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
padding: 15px; padding: 15px;
} }
.message-body :not(pre) > code::before {
content: "`";
}
.message-body :not(pre) > code::after {
content: "`";
}
.message-body :not(pre) > code { .message-body :not(pre) > code {
white-space: normal !important; white-space: normal !important;
font-weight: bold;
font-family: unset;
} }
#chat-input { #chat-input {
@ -492,6 +531,15 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
border: none; border: none;
} }
#chat-input textarea {
padding: 0.65rem 2.5rem;
}
#chat-input textarea::placeholder {
white-space: nowrap;
overflow: hidden;
}
#chat-input textarea:focus { #chat-input textarea:focus {
box-shadow: none !important; box-shadow: none !important;
} }
@ -504,6 +552,14 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
display: none; display: none;
} }
.chat-input-positioned {
position: absolute;
bottom: 0;
max-width: 54rem;
left: 50%;
transform: translateX(-50%);
}
@media print { @media print {
body { body {
visibility: hidden; visibility: hidden;
@ -539,7 +595,6 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
#show-controls { #show-controls {
position: absolute; position: absolute;
height: 100%;
background-color: transparent; background-color: transparent;
border: 0 !important; border: 0 !important;
border-radius: 0; border-radius: 0;
@ -548,7 +603,8 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
#show-controls label { #show-controls label {
z-index: 1000; z-index: 1000;
position: absolute; position: absolute;
right: 0; right: 30px;
top: 10px;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
@ -630,7 +686,6 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
position: absolute; position: absolute;
bottom: 80%; bottom: 80%;
left: 0; left: 0;
background-color: var(--background-fill-primary);
box-shadow: 0 0 5px rgb(0 0 0 / 25%); box-shadow: 0 0 5px rgb(0 0 0 / 25%);
z-index: 10000; z-index: 10000;
min-width: 330px; min-width: 330px;
@ -641,7 +696,6 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
width: 100%; width: 100%;
background: transparent !important; background: transparent !important;
border-radius: 0 !important; border-radius: 0 !important;
border-color: var(--border-color-primary);
justify-content: space-between; justify-content: space-between;
margin: 0 !important; margin: 0 !important;
height: 36px; height: 36px;
@ -663,7 +717,7 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
opacity: 0.333; opacity: 0.333;
} }
#chat-tab:not(.old-ui) #chat-buttons { #chat-tab #chat-buttons {
display: none !important; display: none !important;
} }
@ -694,23 +748,37 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
} }
#chat-input-row { #chat-input-row {
padding-bottom: 20px; padding-bottom: 1.5em;
padding-left: 1rem;
padding-right: 1rem;
} }
.old-ui #chat-input-row, #chat-input-row.bigchat { #chat-input-row.bigchat {
padding-bottom: 0 !important; padding-bottom: 1px !important;
} }
#chat-col { #chat-col {
padding-bottom: 100px; padding-bottom: 100px;
} }
.old-ui #chat-col, #chat-col.bigchat { @media screen and (width <= 924px) {
padding-bottom: 80px !important; #chat-col {
padding-bottom: 100px;
margin-top: 32px;
position: relative; /* Ensure positioning for the pseudo-element */
}
.chat-parent {
height: calc(100dvh - 98px - var(--input-delta) - 32px);
}
.chat-parent.bigchat {
height: calc(100dvh - 98px - var(--input-delta) - 32px) !important;
}
} }
.old-ui #chat-buttons #clear-history-confirm { #chat-col.bigchat {
order: -1; padding-bottom: 80px !important;
} }
.chat ol, .chat ul { .chat ol, .chat ul {
@ -725,26 +793,36 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
} }
/* ---------------------------------------------- /* ----------------------------------------------
Past chat histories in a side bar on desktop Create the sidebars
---------------------------------------------- */ ---------------------------------------------- */
@media screen and (width >= 1327px) { #chat-controls,
#past-chats-row { #past-chats-row {
position: absolute; width: 260px;
top: 36px; max-width: 80vw;
left: 0; padding: 0.5rem;
width: calc(0.5*(var(--document-width) - 880px - 120px - 16px*2)); height: 100dvh;
max-width: 300px; flex-shrink: 0;
margin-left: calc(-0.5*(var(--document-width) - 880px - 14px - 16px * 2)); box-sizing: content-box;
} z-index: 10;
}
#chat-controls { #past-chats-row:not(.negative-header) {
position: absolute; max-width: calc(85vw - var(--header-width));
top: 16px; }
right: 0;
width: calc(0.5*(var(--document-width) - 880px - 120px - 16px*2)); #chat-controls {
max-width: 400px; padding: 1rem;
margin-right: calc(-0.5*(var(--document-width) - 880px - 14px - 16px * 2)); padding-bottom: 0;
} }
#chat-controls > :nth-child(1) {
padding: 0.5rem;
}
#past-chats-row + * {
width: unset;
flex-grow: 1;
flex-shrink: 1;
} }
/* ---------------------------------------------- /* ----------------------------------------------
@ -761,12 +839,12 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
position: fixed; position: fixed;
bottom: 0; bottom: 0;
left: 0; left: 0;
width: calc((100vw - 880px - 120px) /2); width: calc(100vw / 2 - 600px);
z-index: 10000;
} }
.pfp_character { .pfp_character {
position: relative; position: relative;
z-index: 100;
} }
.pfp_character:hover { .pfp_character:hover {
@ -780,10 +858,14 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
} }
#past-chats { #past-chats {
max-height: calc(100vh - 195px); max-height: calc(100dvh - 90px);
overflow-y: scroll !important; overflow-y: scroll !important;
border-radius: 0; border-radius: 0;
scrollbar-width: none; /* Hide scrollbar in Firefox by default */ scrollbar-width: auto;
}
#past-chats::-webkit-scrollbar {
display: block;
} }
#past-chats label { #past-chats label {
@ -794,6 +876,24 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
border-radius: 0; border-radius: 0;
padding-top: 8px; padding-top: 8px;
padding-bottom: 8px; padding-bottom: 8px;
position: relative;
min-height: 42px !important;
}
#past-chats label::before {
content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 9h8"></path><path d="M8 13h6"></path><path d="M18 4a3 3 0 0 1 3 3v8a3 3 0 0 1 -3 3h-5l-5 3v-3h-2a3 3 0 0 1 -3 -3v-8a3 3 0 0 1 3 -3h12z"></path></svg>');
position: absolute;
top: 12px;
left: 12px;
margin-right: 8px;
}
.dark #past-chats label::before {
content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 9h8"></path><path d="M8 13h6"></path><path d="M18 4a3 3 0 0 1 3 3v8a3 3 0 0 1 -3 3h-5l-5 3v-3h-2a3 3 0 0 1 -3 -3v-8a3 3 0 0 1 3 -3h12z"></path></svg>');
}
#past-chats label span {
margin-left: 29px;
} }
#past-chats > :nth-child(2) { #past-chats > :nth-child(2) {
@ -801,23 +901,264 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
} }
#past-chats > :nth-child(3) { #past-chats > :nth-child(3) {
gap: 0; gap: 0.25rem;
} }
#past-chats::-webkit-scrollbar { #past-chats input {
display: none; display: none;
} }
#past-chats:hover { #past-chats label {
scrollbar-width: auto; padding: 0.75rem;
font-size: 12.5px;
font-weight: 400;
} }
#past-chats:hover::-webkit-scrollbar { #past-chats .selected,
display: block; #past-chats label:hover {
border-radius: 0.5rem;
} }
@media screen and (width < 1327px) { #past-chats label:hover {
#past-chats { cursor: pointer;
max-height: 300px; }
#past-chats-buttons,
#delete-chat-row,
#rename-row {
width: 100%;
justify-content: center;
}
#past-chats-row,
#chat-controls {
width: 260px;
padding: 0.5rem;
height: calc(100dvh - 16px);
flex-shrink: 0;
box-sizing: content-box;
}
.sidebar-hidden {
width: 0 !important;
padding: 0 !important;
overflow: hidden;
}
#past-chats-toggle,
#chat-controls-toggle,
#navigation-toggle {
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
user-select: none;
border-radius: 3px;
z-index: 1000;
position: fixed;
width: 2rem;
height: 2rem;
top: 0;
}
#past-chats-toggle svg,
#chat-controls-toggle svg,
#navigation-toggle svg {
pointer-events: none;
}
#past-chats-row:not(.negative-header, .sidebar-hidden) {
margin-left: 112px;
}
@media screen and (width <= 408px) {
#past-chats-toggle.past-chats-open {
top: 28px;
}
#chat-controls-toggle.chat-controls-open {
top: 28px;
right: calc(16px + min(260px, 80vw)) !important;
}
}
#past-chats-toggle.past-chats-open.negative-header {
left: calc(min(260px, 85vw) + 16px);
}
#past-chats-toggle.past-chats-open:not(.negative-header) {
left: calc(112px + min(260px, calc(85vw - var(--header-width))) + 16px);
}
#past-chats-toggle.past-chats-closed:not(.negative-header) {
left: 112px;
}
#past-chats-toggle.past-chats-closed.negative-header {
left: 0;
top: 28px;
}
@media screen and (width <= 924px) {
#past-chats-toggle.past-chats-closed.negative-header {
left: 28px;
top: 0;
}
}
.header_bar ~ *:not(#chat-tab) {
margin-left: var(--header-width);
}
/* Positions for chat-controls-toggle */
#chat-controls-toggle.chat-controls-open {
right: calc(min(260px, 80vw) + 23px);
}
#chat-controls-toggle.chat-controls-closed {
right: 7px;
}
@media screen and (width <= 924px) {
#chat-controls.sidebar-shown {
position: fixed;
right: 0;
}
#past-chats-row.sidebar-shown {
position: fixed;
}
}
/* ----------------------------------------------
Dark theme
---------------------------------------------- */
.dark .header_bar {
background-color: var(--darker-gray) !important;
}
.dark .header_bar button.selected {
background: var(--selected-item-color-dark);
}
.dark #chat-input textarea {
background: var(--light-gray);
color: white !important;
border-color: #292c3b;
}
.dark #chat-input textarea::placeholder {
color: #9ca3af;
}
.dark .hover-menu {
background-color: var(--darker-gray);
}
.dark .hover-menu button {
border-color: var(--border-color-primary);
}
.dark #chat-controls,
.dark #past-chats-row {
background-color: var(--darker-gray);
border: 0 !important;
}
.dark #past-chats .selected,
.dark #past-chats label:hover {
background-color: var(--selected-item-color-dark) !important;
}
.dark #past-chats-row,
.dark #chat-controls {
background-color: var(--darker-gray);
}
.dark #past-chats-toggle,
.dark #chat-controls-toggle,
.dark #navigation-toggle {
color: white;
}
.dark svg {
fill: white;
color: white;
}
@media screen and (width <= 408px) {
.dark #past-chats-toggle.past-chats-open {
background: var(--darker-gray);
}
.dark #chat-controls-toggle.chat-controls-open {
background: var(--darker-gray);
}
}
/* ----------------------------------------------
Light theme
---------------------------------------------- */
.header_bar {
background-color: var(--light-theme-gray) !important;
}
.header_bar button.selected {
background: white;
}
#chat-controls,
#past-chats-row {
background-color: var(--light-theme-gray);
}
#chat-controls {
border-left: 1px solid #d9d9d0;
}
#past-chats-row {
border-right: 1px solid #d9d9d0;
}
#past-chats-toggle,
#chat-controls-toggle,
#navigation-toggle {
color: gray !important;
}
.mobile-top-bar {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 32px;
z-index: 2;
opacity: 0;
pointer-events: none;
}
@media screen and (width <= 924px) {
.mobile-top-bar {
opacity: 1;
pointer-events: auto;
}
.dark .mobile-top-bar {
background-color: var(--darker-gray);
}
.mobile-top-bar {
background-color: var(--light-theme-gray);
}
}
@media screen and (width <= 408px) {
#past-chats-toggle.past-chats-open {
background: var(--light-theme-gray);
}
#chat-controls-toggle.chat-controls-open {
background: var(--light-theme-gray);
} }
} }

View File

@ -18,16 +18,18 @@ document.querySelector(".header_bar").addEventListener("click", function(event)
if (extensionsVisible) { if (extensionsVisible) {
if (extensions) { if (extensions) {
extensions.style.display = "flex"; extensions.style.display = "flex";
extensions.style.maxWidth = chatVisible ? "880px" : "none";
extensions.style.padding = chatVisible ? "0px" : "15px";
} }
this.style.marginBottom = chatVisible ? "0px" : "19px"; this.style.marginBottom = chatVisible ? "0px" : "19px";
if (chatVisible && !showControlsChecked) { if (chatVisible && !showControlsChecked) {
document.querySelectorAll("#chat-tab > div > :nth-child(n+2), #extensions").forEach(element => { document.querySelectorAll(
"#chat-tab > div > :nth-child(1), #chat-tab > div > :nth-child(3), #chat-tab > div > :nth-child(4), #extensions"
).forEach(element => {
element.style.display = "none"; element.style.display = "none";
}); });
} }
} else { } else {
this.style.marginBottom = "19px"; this.style.marginBottom = "19px";
if (extensions) extensions.style.display = "none"; if (extensions) extensions.style.display = "none";
@ -132,8 +134,7 @@ targetElement.addEventListener("scroll", function() {
const observer = new MutationObserver(function(mutations) { const observer = new MutationObserver(function(mutations) {
updateCssProperties(); updateCssProperties();
const firstChild = targetElement.children[0]; if (targetElement.classList.contains("_generating")) {
if (firstChild.classList.contains("generating")) {
typing.parentNode.classList.add("visible-dots"); typing.parentNode.classList.add("visible-dots");
document.getElementById("stop").style.display = "flex"; document.getElementById("stop").style.display = "flex";
document.getElementById("Generate").style.display = "none"; document.getElementById("Generate").style.display = "none";
@ -255,7 +256,7 @@ for (i = 0; i < slimDropdownElements.length; i++) {
// The show/hide events were adapted from: // The show/hide events were adapted from:
// https://github.com/SillyTavern/SillyTavern/blob/6c8bd06308c69d51e2eb174541792a870a83d2d6/public/script.js // https://github.com/SillyTavern/SillyTavern/blob/6c8bd06308c69d51e2eb174541792a870a83d2d6/public/script.js
//------------------------------------------------ //------------------------------------------------
var buttonsInChat = document.querySelectorAll("#chat-tab:not(.old-ui) #chat-buttons button"); var buttonsInChat = document.querySelectorAll("#chat-tab #chat-buttons button");
var button = document.getElementById("hover-element-button"); var button = document.getElementById("hover-element-button");
var menu = document.getElementById("hover-menu"); var menu = document.getElementById("hover-menu");
var istouchscreen = (navigator.maxTouchPoints > 0) || "ontouchstart" in document.documentElement; var istouchscreen = (navigator.maxTouchPoints > 0) || "ontouchstart" in document.documentElement;
@ -290,12 +291,6 @@ if (buttonsInChat.length > 0) {
thisButton.innerHTML = newText; thisButton.innerHTML = newText;
} }
} }
} else {
buttonsInChat = document.querySelectorAll("#chat-tab.old-ui #chat-buttons button");
for (let i = 0; i < buttonsInChat.length; i++) {
buttonsInChat[i].textContent = buttonsInChat[i].textContent.replace(/ \(.*?\)/, "");
}
document.getElementById("gr-hover-container").style.display = "none";
} }
function isMouseOverButtonOrMenu() { function isMouseOverButtonOrMenu() {
@ -339,6 +334,8 @@ menu.addEventListener("mouseleave", function () {
// Add event listener for click anywhere in the document // Add event listener for click anywhere in the document
document.addEventListener("click", function (event) { document.addEventListener("click", function (event) {
const target = event.target;
// Check if the click is outside the button/menu and the menu is visible // Check if the click is outside the button/menu and the menu is visible
if (!isMouseOverButtonOrMenu() && menu.style.display === "flex") { if (!isMouseOverButtonOrMenu() && menu.style.display === "flex") {
hideMenu(); hideMenu();
@ -361,10 +358,9 @@ for (var i = 0; i < 2; i++) {
parent.insertBefore(elementToMove, parent.firstChild); parent.insertBefore(elementToMove, parent.firstChild);
//------------------------------------------------ //------------------------------------------------
// Make the chat input grow upwards instead of downwards // Position the chat input
//------------------------------------------------ //------------------------------------------------
document.getElementById("show-controls").parentNode.style.position = "absolute"; document.getElementById("show-controls").parentNode.classList.add("chat-input-positioned");
document.getElementById("show-controls").parentNode.style.bottom = "0px";
//------------------------------------------------ //------------------------------------------------
// Focus on the chat input // Focus on the chat input
@ -444,20 +440,10 @@ function updateCssProperties() {
// Check if the chat container is visible // Check if the chat container is visible
if (chatContainer.clientHeight > 0) { if (chatContainer.clientHeight > 0) {
var numericHeight = chatContainer.parentNode.clientHeight - chatInputHeight + 40 - 100; const newChatHeight = `${chatContainer.parentNode.clientHeight - chatInputHeight + 40 - 100 - 20}px`;
if (document.getElementById("chat-tab").style.paddingBottom != "") {
numericHeight += 20;
}
const newChatHeight = `${numericHeight}px`;
document.documentElement.style.setProperty("--chat-height", newChatHeight); document.documentElement.style.setProperty("--chat-height", newChatHeight);
document.documentElement.style.setProperty("--input-delta", `${chatInputHeight - 40}px`); document.documentElement.style.setProperty("--input-delta", `${chatInputHeight - 40}px`);
// Get and set header height
const header = document.querySelector(".header_bar");
const headerHeight = `${header.clientHeight}px`;
document.documentElement.style.setProperty("--header-height", headerHeight);
// Adjust scrollTop based on input height change // Adjust scrollTop based on input height change
if (chatInputHeight !== currentChatInputHeight) { if (chatInputHeight !== currentChatInputHeight) {
if (!isScrolled && chatInputHeight < currentChatInputHeight) { if (!isScrolled && chatInputHeight < currentChatInputHeight) {
@ -568,6 +554,8 @@ function moveToChatTab() {
grandParent.style.display = "none"; grandParent.style.display = "none";
} }
grandParent.children[0].style.minWidth = "100%";
const chatControlsFirstChild = document.querySelector("#chat-controls").firstElementChild; const chatControlsFirstChild = document.querySelector("#chat-controls").firstElementChild;
const newParent = chatControlsFirstChild; const newParent = chatControlsFirstChild;
let newPosition = newParent.children.length - 2; let newPosition = newParent.children.length - 2;
@ -586,6 +574,7 @@ function restoreOriginalPosition() {
document.getElementById("save-character").style.display = ""; document.getElementById("save-character").style.display = "";
movedElement.style.display = ""; movedElement.style.display = "";
movedElement.children[0].style.minWidth = "";
} }
} }
@ -612,3 +601,206 @@ window.addEventListener("beforeunload", function (event) {
}); });
moveToChatTab(); moveToChatTab();
//------------------------------------------------
// Buttons to toggle the sidebars
//------------------------------------------------
const leftArrowSVG = `
<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="tabler-icon tabler-icon-arrow-bar-left">
<path d="M4 12l10 0"></path>
<path d="M4 12l4 4"></path>
<path d="M4 12l4 -4"></path>
<path d="M20 4l0 16"></path>
</svg>`;
const rightArrowSVG = `
<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="tabler-icon tabler-icon-arrow-bar-right">
<path d="M20 12l-10 0"></path>
<path d="M20 12l-4 4"></path>
<path d="M20 12l-4 -4"></path>
<path d="M4 4l0 16"></path>
</svg>`;
const hamburgerMenuSVG = `
<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-hamburger-menu">
<line x1="3" y1="12" x2="21" y2="12"></line>
<line x1="3" y1="6" x2="21" y2="6"></line>
<line x1="3" y1="18" x2="21" y2="18"></line>
</svg>`;
const closeMenuSVG = `
<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-close-menu">
<line x1="18" y1="6" x2="6" y2="18"></line>
<line x1="6" y1="6" x2="18" y2="18"></line>
</svg>`;
const chatTab = document.getElementById("chat-tab");
const pastChatsRow = document.getElementById("past-chats-row");
const chatControlsRow = document.getElementById("chat-controls");
if (chatTab) {
// Create past-chats-toggle div
const pastChatsToggle = document.createElement("div");
pastChatsToggle.id = "past-chats-toggle";
pastChatsToggle.innerHTML = leftArrowSVG; // Set initial icon to left arrow
pastChatsToggle.classList.add("past-chats-open"); // Set initial position
// Create chat-controls-toggle div
const chatControlsToggle = document.createElement("div");
chatControlsToggle.id = "chat-controls-toggle";
chatControlsToggle.innerHTML = rightArrowSVG; // Set initial icon to right arrow
chatControlsToggle.classList.add("chat-controls-open"); // Set initial position
// Append both elements to the chat-tab
chatTab.appendChild(pastChatsToggle);
chatTab.appendChild(chatControlsToggle);
}
// Create navigation toggle div
const navigationToggle = document.createElement("div");
navigationToggle.id = "navigation-toggle";
navigationToggle.innerHTML = leftArrowSVG; // Set initial icon to right arrow
navigationToggle.classList.add("navigation-left"); // Set initial position
headerBar.appendChild(navigationToggle);
// Retrieve the dynamically created toggle buttons
const pastChatsToggle = document.getElementById("past-chats-toggle");
const chatControlsToggle = document.getElementById("chat-controls-toggle");
function toggleSidebar(sidebar, toggle) {
const isCurrentlyHidden = sidebar.classList.contains("sidebar-hidden");
const shouldClose = !isCurrentlyHidden;
// Apply visibility classes
sidebar.classList.toggle("sidebar-hidden", shouldClose);
sidebar.classList.toggle("sidebar-shown", !shouldClose);
if (sidebar === headerBar) {
// Special handling for header bar
document.documentElement.style.setProperty("--header-width", shouldClose ? "0px" : "112px");
pastChatsRow.classList.toggle("negative-header", shouldClose);
pastChatsToggle.classList.toggle("negative-header", shouldClose);
toggle.innerHTML = shouldClose ? hamburgerMenuSVG : closeMenuSVG;
} else if (sidebar === pastChatsRow) {
// Past chats sidebar
toggle.classList.toggle("past-chats-closed", shouldClose);
toggle.classList.toggle("past-chats-open", !shouldClose);
toggle.innerHTML = shouldClose ? rightArrowSVG : leftArrowSVG;
} else if (sidebar === chatControlsRow) {
// Chat controls sidebar
toggle.classList.toggle("chat-controls-closed", shouldClose);
toggle.classList.toggle("chat-controls-open", !shouldClose);
toggle.innerHTML = shouldClose ? leftArrowSVG : rightArrowSVG;
}
// Mobile handling
if (isMobile()) {
sidebar.classList.toggle("sidebar-shown", !shouldClose);
}
}
// Function to check if the device is mobile
function isMobile() {
return window.innerWidth <= 924;
}
// Function to initialize sidebars
function initializeSidebars() {
const isOnMobile = isMobile();
if (isOnMobile) {
// Mobile state: Hide sidebars and set closed states
[pastChatsRow, chatControlsRow, headerBar].forEach(el => {
el.classList.add("sidebar-hidden");
el.classList.remove("sidebar-shown");
});
document.documentElement.style.setProperty("--header-width", "0px");
pastChatsRow.classList.add("negative-header");
pastChatsToggle.classList.add("negative-header", "past-chats-closed");
pastChatsToggle.classList.remove("past-chats-open");
[chatControlsToggle, navigationToggle].forEach(el => {
el.classList.add("chat-controls-closed");
el.classList.remove("chat-controls-open");
});
pastChatsToggle.innerHTML = rightArrowSVG;
chatControlsToggle.innerHTML = leftArrowSVG;
navigationToggle.innerHTML = hamburgerMenuSVG;
} else {
// Desktop state: Show sidebars and set open states
[pastChatsRow, chatControlsRow].forEach(el => {
el.classList.remove("sidebar-hidden", "sidebar-shown");
});
pastChatsToggle.classList.add("past-chats-open");
pastChatsToggle.classList.remove("past-chats-closed");
[chatControlsToggle, navigationToggle].forEach(el => {
el.classList.add("chat-controls-open");
el.classList.remove("chat-controls-closed");
});
pastChatsToggle.innerHTML = leftArrowSVG;
chatControlsToggle.innerHTML = rightArrowSVG;
navigationToggle.innerHTML = closeMenuSVG;
}
}
// Run the initializer when the page loads
initializeSidebars();
// Add an event listener to handle screen resizing
window.addEventListener("resize", initializeSidebars);
// Add click event listeners to toggle buttons
pastChatsToggle.addEventListener("click", () => {
toggleSidebar(pastChatsRow, pastChatsToggle);
});
chatControlsToggle.addEventListener("click", () => {
toggleSidebar(chatControlsRow, chatControlsToggle);
});
navigationToggle.addEventListener("click", () => {
toggleSidebar(headerBar, navigationToggle);
});
//------------------------------------------------
// Fixes #chat-input textarea height issue
// for devices with width <= 924px
//------------------------------------------------
if (isMobile()) {
// Target the textarea
const textarea = document.querySelector("#chat-input textarea");
if (textarea) {
// Simulate adding and removing a newline
textarea.value += "\n";
textarea.dispatchEvent(new Event("input", { bubbles: true }));
textarea.value = textarea.value.slice(0, -1);
textarea.dispatchEvent(new Event("input", { bubbles: true }));
}
}
//------------------------------------------------
// Create a top navigation bar on mobile
//------------------------------------------------
function createMobileTopBar() {
const chatTab = document.getElementById("chat-tab");
// Only create the top bar if it doesn't already exist
if (chatTab && !chatTab.querySelector(".mobile-top-bar")) {
const topBar = document.createElement("div");
topBar.classList.add("mobile-top-bar");
// Insert the top bar as the first child of chat-tab
chatTab.appendChild(topBar);
}
}
createMobileTopBar();

View File

@ -1,4 +1,6 @@
const belowChatInput = document.querySelectorAll("#chat-tab > div > :nth-child(n+2), #extensions"); const belowChatInput = document.querySelectorAll(
"#chat-tab > div > :nth-child(1), #chat-tab > div > :nth-child(3), #chat-tab > div > :nth-child(4), #extensions"
);
const chatParent = document.querySelector(".chat-parent"); const chatParent = document.querySelector(".chat-parent");
function toggle_controls(value) { function toggle_controls(value) {

View File

@ -352,13 +352,17 @@ def chatbot_wrapper(text, state, regenerate=False, _continue=False, loading_mess
for j, reply in enumerate(generate_reply(prompt, state, stopping_strings=stopping_strings, is_chat=True, for_ui=for_ui)): for j, reply in enumerate(generate_reply(prompt, state, stopping_strings=stopping_strings, is_chat=True, for_ui=for_ui)):
# Extract the reply # Extract the reply
visible_reply = reply
if state['mode'] in ['chat', 'chat-instruct']: if state['mode'] in ['chat', 'chat-instruct']:
visible_reply = re.sub("(<USER>|<user>|{{user}})", state['name1'], reply) visible_reply = re.sub("(<USER>|<user>|{{user}})", state['name1'], reply + '')
else:
visible_reply = reply + ''
visible_reply = html.escape(visible_reply) visible_reply = html.escape(visible_reply)
if shared.stop_everything: if shared.stop_everything:
if output['visible'][-1][1].endswith(''):
output['visible'][-1][1] = output['visible'][-1][1][:-1]
output['visible'][-1][1] = apply_extensions('output', output['visible'][-1][1], state, is_chat=True) output['visible'][-1][1] = apply_extensions('output', output['visible'][-1][1], state, is_chat=True)
yield output yield output
return return
@ -374,6 +378,9 @@ def chatbot_wrapper(text, state, regenerate=False, _continue=False, loading_mess
if is_stream: if is_stream:
yield output yield output
if output['visible'][-1][1].endswith(''):
output['visible'][-1][1] = output['visible'][-1][1][:-1]
output['visible'][-1][1] = apply_extensions('output', output['visible'][-1][1], state, is_chat=True) output['visible'][-1][1] = apply_extensions('output', output['visible'][-1][1], state, is_chat=True)
yield output yield output
@ -606,9 +613,9 @@ def find_all_histories_with_first_prompts(state):
first_prompt = first_prompt.strip() first_prompt = first_prompt.strip()
# Truncate the first prompt if it's longer than 32 characters # Truncate the first prompt if it's longer than 30 characters
if len(first_prompt) > 32: if len(first_prompt) > 30:
first_prompt = first_prompt[:29] + '...' first_prompt = first_prompt[:30-3] + '...'
result.append((first_prompt, filename)) result.append((first_prompt, filename))
@ -1087,9 +1094,8 @@ def handle_delete_chat_confirm_click(state):
def handle_rename_chat_click(): def handle_rename_chat_click():
return [ return [
gr.update(visible=True, value="My New Chat"), gr.update(value="My New Chat"),
gr.update(visible=True), gr.update(visible=True),
gr.update(visible=True)
] ]
@ -1100,8 +1106,6 @@ def handle_rename_chat_confirm(rename_to, state):
return [ return [
gr.update(choices=histories, value=rename_to), gr.update(choices=histories, value=rename_to),
gr.update(visible=False), gr.update(visible=False),
gr.update(visible=False),
gr.update(visible=False)
] ]
@ -1209,7 +1213,7 @@ def handle_delete_template_click(template):
return [ return [
f"{template}.yaml", f"{template}.yaml",
"instruction-templates/", "instruction-templates/",
gr.update(visible=True) gr.update(visible=False)
] ]

View File

@ -81,7 +81,6 @@ group.add_argument('--model-menu', action='store_true', help='Show a model menu
group.add_argument('--settings', type=str, help='Load the default interface settings from this yaml file. See settings-template.yaml for an example. If you create a file called settings.yaml, this file will be loaded by default without the need to use the --settings flag.') group.add_argument('--settings', type=str, help='Load the default interface settings from this yaml file. See settings-template.yaml for an example. If you create a file called settings.yaml, this file will be loaded by default without the need to use the --settings flag.')
group.add_argument('--extensions', type=str, nargs='+', help='The list of extensions to load. If you want to load more than one extension, write the names separated by spaces.') group.add_argument('--extensions', type=str, nargs='+', help='The list of extensions to load. If you want to load more than one extension, write the names separated by spaces.')
group.add_argument('--verbose', action='store_true', help='Print the prompts to the terminal.') group.add_argument('--verbose', action='store_true', help='Print the prompts to the terminal.')
group.add_argument('--chat-buttons', action='store_true', help='Show buttons on the chat tab instead of a hover menu.')
group.add_argument('--idle-timeout', type=int, default=0, help='Unload model after this many minutes of inactivity. It will be automatically reloaded when you try to use it again.') group.add_argument('--idle-timeout', type=int, default=0, help='Unload model after this many minutes of inactivity. It will be automatically reloaded when you try to use it again.')
# Model loader # Model loader
@ -191,6 +190,7 @@ group.add_argument('--gradio-auth-path', type=str, help='Set the Gradio authenti
group.add_argument('--ssl-keyfile', type=str, help='The path to the SSL certificate key file.', default=None) group.add_argument('--ssl-keyfile', type=str, help='The path to the SSL certificate key file.', default=None)
group.add_argument('--ssl-certfile', type=str, help='The path to the SSL certificate cert file.', default=None) group.add_argument('--ssl-certfile', type=str, help='The path to the SSL certificate cert file.', default=None)
group.add_argument('--subpath', type=str, help='Customize the subpath for gradio, use with reverse proxy') group.add_argument('--subpath', type=str, help='Customize the subpath for gradio, use with reverse proxy')
group.add_argument('--old-colors', action='store_true', help='Use the legacy Gradio colors, before the December/2024 update.')
# API # API
group = parser.add_argument_group('API') group = parser.add_argument_group('API')
@ -213,6 +213,7 @@ group.add_argument('--pre_layer', type=int, nargs='+', help='DEPRECATED')
group.add_argument('--checkpoint', type=str, help='DEPRECATED') group.add_argument('--checkpoint', type=str, help='DEPRECATED')
group.add_argument('--monkey-patch', action='store_true', help='DEPRECATED') group.add_argument('--monkey-patch', action='store_true', help='DEPRECATED')
group.add_argument('--no_inject_fused_attention', action='store_true', help='DEPRECATED') group.add_argument('--no_inject_fused_attention', action='store_true', help='DEPRECATED')
group.add_argument('--chat-buttons', action='store_true', help='DEPRECATED')
args = parser.parse_args() args = parser.parse_args()
args_defaults = parser.parse_args([]) args_defaults = parser.parse_args([])

View File

@ -50,6 +50,49 @@ theme = gr.themes.Default(
button_secondary_border_color="var(--border-color-primary)" button_secondary_border_color="var(--border-color-primary)"
) )
if not shared.args.old_colors:
theme = theme.set(
# General Colors
border_color_primary='#c5c5d2',
body_text_color_subdued='#484848',
background_fill_secondary='#eaeaea',
background_fill_secondary_dark='var(--dark-gray)',
background_fill_primary='var(--neutral-50)',
background_fill_primary_dark='var(--darker-gray)',
body_background_fill="white",
block_background_fill="transparent",
body_text_color="#333",
button_secondary_background_fill="#f4f4f4",
button_secondary_border_color="var(--border-color-primary)",
# Dark Mode Colors
input_background_fill_dark='var(--darker-gray)',
checkbox_background_color_dark='var(--darker-gray)',
block_background_fill_dark='transparent',
block_border_color_dark='transparent',
input_border_color_dark='var(--border-color-dark)',
checkbox_border_color_dark='var(--border-color-dark)',
border_color_primary_dark='var(--border-color-dark)',
button_secondary_border_color_dark='var(--border-color-dark)',
body_background_fill_dark='var(--dark-gray)',
button_primary_background_fill_dark='transparent',
button_secondary_background_fill_dark='transparent',
checkbox_label_background_fill_dark='transparent',
button_cancel_background_fill_dark='transparent',
button_secondary_background_fill_hover_dark='var(--selected-item-color-dark)',
checkbox_label_background_fill_hover_dark='var(--selected-item-color-dark)',
table_even_background_fill_dark='var(--darker-gray)',
table_odd_background_fill_dark='var(--dark-gray)',
# Shadows and Radius
checkbox_label_shadow='none',
block_shadow='none',
block_shadow_dark='none',
button_large_radius='0.375rem',
button_large_padding='6px 12px',
input_radius='0.375rem',
)
if Path("notification.mp3").exists(): if Path("notification.mp3").exists():
audio_notification_js = "document.querySelector('#audio_notification audio')?.play();" audio_notification_js = "document.querySelector('#audio_notification audio')?.play();"
else: else:
@ -232,10 +275,10 @@ def gather_interface_values(*args):
def apply_interface_values(state, use_persistent=False): def apply_interface_values(state, use_persistent=False):
if use_persistent: if use_persistent:
state = shared.persistent_interface_state state = shared.persistent_interface_state
if 'textbox-default' in state: if 'textbox-default' in state and 'prompt_menu-default' in state:
state.pop('prompt_menu-default') state.pop('prompt_menu-default')
if 'textbox-notebook' in state: if 'textbox-notebook' and 'prompt_menu-notebook' in state:
state.pop('prompt_menu-notebook') state.pop('prompt_menu-notebook')
elements = list_interface_input_elements() elements = list_interface_input_elements()

View File

@ -12,7 +12,6 @@ from modules.utils import gradio
inputs = ('Chat input', 'interface_state') inputs = ('Chat input', 'interface_state')
reload_arr = ('history', 'name1', 'name2', 'mode', 'chat_style', 'character_menu') reload_arr = ('history', 'name1', 'name2', 'mode', 'chat_style', 'character_menu')
clear_arr = ('delete_chat-confirm', 'delete_chat', 'delete_chat-cancel')
def create_ui(): def create_ui():
@ -21,7 +20,27 @@ def create_ui():
shared.gradio['Chat input'] = gr.State() shared.gradio['Chat input'] = gr.State()
shared.gradio['history'] = gr.JSON({'internal': [], 'visible': []}, visible=False) shared.gradio['history'] = gr.JSON({'internal': [], 'visible': []}, visible=False)
with gr.Tab('Chat', elem_id='chat-tab', elem_classes=("old-ui" if shared.args.chat_buttons else None)): with gr.Tab('Chat', elem_id='chat-tab'):
with gr.Row(elem_id='past-chats-row', elem_classes=['pretty_scrollbar']):
with gr.Column():
with gr.Row(elem_id='past-chats-buttons'):
shared.gradio['rename_chat'] = gr.Button('Rename', elem_classes='refresh-button', interactive=not mu)
shared.gradio['delete_chat'] = gr.Button('🗑️', elem_classes='refresh-button', interactive=not mu)
shared.gradio['Start new chat'] = gr.Button('New chat', elem_classes=['refresh-button', 'focus-on-chat-input'])
with gr.Row(elem_id='delete-chat-row', visible=False) as shared.gradio['delete-chat-row']:
shared.gradio['delete_chat-cancel'] = gr.Button('Cancel', elem_classes=['refresh-button', 'focus-on-chat-input'])
shared.gradio['delete_chat-confirm'] = gr.Button('Confirm', variant='stop', elem_classes=['refresh-button', 'focus-on-chat-input'])
with gr.Row(elem_id='rename-row', visible=False) as shared.gradio['rename-row']:
shared.gradio['rename_to'] = gr.Textbox(label='Rename to:', placeholder='New name', elem_classes=['no-background'])
with gr.Row():
shared.gradio['rename_to-cancel'] = gr.Button('Cancel', elem_classes=['refresh-button', 'focus-on-chat-input'])
shared.gradio['rename_to-confirm'] = gr.Button('Confirm', elem_classes=['refresh-button', 'focus-on-chat-input'], variant='primary')
with gr.Row():
shared.gradio['unique_id'] = gr.Radio(label="", elem_classes=['slim-dropdown', 'pretty_scrollbar'], interactive=not mu, elem_id='past-chats')
with gr.Row(): with gr.Row():
with gr.Column(elem_id='chat-col'): with gr.Column(elem_id='chat-col'):
shared.gradio['display'] = gr.HTML(value=chat_html_wrapper({'internal': [], 'visible': []}, '', '', 'chat', 'cai-chat', '')) shared.gradio['display'] = gr.HTML(value=chat_html_wrapper({'internal': [], 'visible': []}, '', '', 'chat', 'cai-chat', ''))
@ -60,25 +79,6 @@ def create_ui():
shared.gradio['send-chat-to-default'] = gr.Button('Send to default') shared.gradio['send-chat-to-default'] = gr.Button('Send to default')
shared.gradio['send-chat-to-notebook'] = gr.Button('Send to notebook') shared.gradio['send-chat-to-notebook'] = gr.Button('Send to notebook')
with gr.Row(elem_id='past-chats-row', elem_classes=['pretty_scrollbar']):
with gr.Column():
with gr.Row():
shared.gradio['rename_chat'] = gr.Button('Rename', elem_classes='refresh-button', interactive=not mu)
shared.gradio['delete_chat'] = gr.Button('🗑️', elem_classes='refresh-button', interactive=not mu)
shared.gradio['delete_chat-confirm'] = gr.Button('Confirm', variant='stop', visible=False, elem_classes=['refresh-button', 'focus-on-chat-input'])
shared.gradio['delete_chat-cancel'] = gr.Button('Cancel', visible=False, elem_classes=['refresh-button', 'focus-on-chat-input'])
shared.gradio['Start new chat'] = gr.Button('New chat', elem_classes=['refresh-button', 'focus-on-chat-input'])
with gr.Row(elem_id='rename-row'):
shared.gradio['rename_to'] = gr.Textbox(label='Rename to:', placeholder='New name', visible=False, elem_classes=['no-background'])
with gr.Row():
shared.gradio['rename_to-confirm'] = gr.Button('Confirm', visible=False, elem_classes=['refresh-button', 'focus-on-chat-input'])
shared.gradio['rename_to-cancel'] = gr.Button('Cancel', visible=False, elem_classes=['refresh-button', 'focus-on-chat-input'])
gr.Markdown("Past chats")
with gr.Row():
shared.gradio['unique_id'] = gr.Radio(label="", elem_classes=['slim-dropdown', 'pretty_scrollbar'], interactive=not mu, elem_id='past-chats')
with gr.Row(elem_id='chat-controls', elem_classes=['pretty_scrollbar']): with gr.Row(elem_id='chat-controls', elem_classes=['pretty_scrollbar']):
with gr.Column(): with gr.Column():
with gr.Row(): with gr.Row():
@ -180,29 +180,39 @@ def create_event_handlers():
shared.gradio['Generate'].click( shared.gradio['Generate'].click(
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then( ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
lambda x: (x, ''), gradio('textbox'), gradio('Chat input', 'textbox'), show_progress=False).then( lambda x: (x, ''), gradio('textbox'), gradio('Chat input', 'textbox'), show_progress=False).then(
lambda: None, None, None, js='() => document.getElementById("chat").parentNode.parentNode.parentNode.classList.add("_generating")').then(
chat.generate_chat_reply_wrapper, gradio(inputs), gradio('display', 'history'), show_progress=False).then( chat.generate_chat_reply_wrapper, gradio(inputs), gradio('display', 'history'), show_progress=False).then(
None, None, None, js='() => document.getElementById("chat").parentNode.parentNode.parentNode.classList.remove("_generating")').then(
None, None, None, js=f'() => {{{ui.audio_notification_js}}}') None, None, None, js=f'() => {{{ui.audio_notification_js}}}')
shared.gradio['textbox'].submit( shared.gradio['textbox'].submit(
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then( ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
lambda x: (x, ''), gradio('textbox'), gradio('Chat input', 'textbox'), show_progress=False).then( lambda x: (x, ''), gradio('textbox'), gradio('Chat input', 'textbox'), show_progress=False).then(
lambda: None, None, None, js='() => document.getElementById("chat").parentNode.parentNode.parentNode.classList.add("_generating")').then(
chat.generate_chat_reply_wrapper, gradio(inputs), gradio('display', 'history'), show_progress=False).then( chat.generate_chat_reply_wrapper, gradio(inputs), gradio('display', 'history'), show_progress=False).then(
None, None, None, js='() => document.getElementById("chat").parentNode.parentNode.parentNode.classList.remove("_generating")').then(
None, None, None, js=f'() => {{{ui.audio_notification_js}}}') None, None, None, js=f'() => {{{ui.audio_notification_js}}}')
shared.gradio['Regenerate'].click( shared.gradio['Regenerate'].click(
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then( ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
lambda: None, None, None, js='() => document.getElementById("chat").parentNode.parentNode.parentNode.classList.add("_generating")').then(
partial(chat.generate_chat_reply_wrapper, regenerate=True), gradio(inputs), gradio('display', 'history'), show_progress=False).then( partial(chat.generate_chat_reply_wrapper, regenerate=True), gradio(inputs), gradio('display', 'history'), show_progress=False).then(
None, None, None, js='() => document.getElementById("chat").parentNode.parentNode.parentNode.classList.remove("_generating")').then(
None, None, None, js=f'() => {{{ui.audio_notification_js}}}') None, None, None, js=f'() => {{{ui.audio_notification_js}}}')
shared.gradio['Continue'].click( shared.gradio['Continue'].click(
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then( ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
lambda: None, None, None, js='() => document.getElementById("chat").parentNode.parentNode.parentNode.classList.add("_generating")').then(
partial(chat.generate_chat_reply_wrapper, _continue=True), gradio(inputs), gradio('display', 'history'), show_progress=False).then( partial(chat.generate_chat_reply_wrapper, _continue=True), gradio(inputs), gradio('display', 'history'), show_progress=False).then(
None, None, None, js='() => document.getElementById("chat").parentNode.parentNode.parentNode.classList.remove("_generating")').then(
None, None, None, js=f'() => {{{ui.audio_notification_js}}}') None, None, None, js=f'() => {{{ui.audio_notification_js}}}')
shared.gradio['Impersonate'].click( shared.gradio['Impersonate'].click(
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then( ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
lambda x: x, gradio('textbox'), gradio('Chat input'), show_progress=False).then( lambda x: x, gradio('textbox'), gradio('Chat input'), show_progress=False).then(
lambda: None, None, None, js='() => document.getElementById("chat").parentNode.parentNode.parentNode.classList.add("_generating")').then(
chat.impersonate_wrapper, gradio(inputs), gradio('textbox', 'display'), show_progress=False).then( chat.impersonate_wrapper, gradio(inputs), gradio('textbox', 'display'), show_progress=False).then(
None, None, None, js='() => document.getElementById("chat").parentNode.parentNode.parentNode.classList.remove("_generating")').then(
None, None, None, js=f'() => {{{ui.audio_notification_js}}}') None, None, None, js=f'() => {{{ui.audio_notification_js}}}')
shared.gradio['Replace last reply'].click( shared.gradio['Replace last reply'].click(
@ -234,21 +244,21 @@ def create_event_handlers():
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then( ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
chat.handle_start_new_chat_click, gradio('interface_state'), gradio('history', 'display', 'unique_id'), show_progress=False) chat.handle_start_new_chat_click, gradio('interface_state'), gradio('history', 'display', 'unique_id'), show_progress=False)
shared.gradio['delete_chat'].click(lambda: [gr.update(visible=True), gr.update(visible=False), gr.update(visible=True)], None, gradio(clear_arr)) shared.gradio['delete_chat'].click(lambda: gr.update(visible=True), None, gradio('delete-chat-row'))
shared.gradio['delete_chat-cancel'].click(lambda: [gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)], None, gradio(clear_arr)) shared.gradio['delete_chat-cancel'].click(lambda: gr.update(visible=False), None, gradio('delete-chat-row'))
shared.gradio['delete_chat-confirm'].click( shared.gradio['delete_chat-confirm'].click(
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then( ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
chat.handle_delete_chat_confirm_click, gradio('interface_state'), gradio('history', 'display', 'unique_id') + gradio(clear_arr), show_progress=False) chat.handle_delete_chat_confirm_click, gradio('interface_state'), gradio('history', 'display', 'unique_id', 'delete-chat-row'), show_progress=False)
shared.gradio['rename_chat'].click(chat.handle_rename_chat_click, None, gradio('rename_to', 'rename_to-confirm', 'rename_to-cancel'), show_progress=False) shared.gradio['rename_chat'].click(chat.handle_rename_chat_click, None, gradio('rename_to', 'rename-row'), show_progress=False)
shared.gradio['rename_to-cancel'].click(lambda: [gr.update(visible=False)] * 3, None, gradio('rename_to', 'rename_to-confirm', 'rename_to-cancel'), show_progress=False) shared.gradio['rename_to-cancel'].click(lambda: gr.update(visible=False), None, gradio('rename-row'), show_progress=False)
shared.gradio['rename_to-confirm'].click( shared.gradio['rename_to-confirm'].click(
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then( ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
chat.handle_rename_chat_confirm, gradio('rename_to', 'interface_state'), gradio('unique_id', 'rename_to', 'rename_to-confirm', 'rename_to-cancel'), show_progress=False) chat.handle_rename_chat_confirm, gradio('rename_to', 'interface_state'), gradio('unique_id', 'rename-row'))
shared.gradio['rename_to'].submit( shared.gradio['rename_to'].submit(
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then( ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
chat.handle_rename_chat_confirm, gradio('rename_to', 'interface_state'), gradio('unique_id', 'rename_to', 'rename_to-confirm', 'rename_to-cancel'), show_progress=False) chat.handle_rename_chat_confirm, gradio('rename_to', 'interface_state'), gradio('unique_id', 'rename-row'), show_progress=False)
shared.gradio['load_chat_history'].upload( shared.gradio['load_chat_history'].upload(
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then( ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(

View File

@ -20,12 +20,12 @@ def create_ui():
with gr.Column(): with gr.Column():
with gr.Row(): with gr.Row():
shared.gradio['textbox-default'] = gr.Textbox(value='', lines=27, label='Input', elem_classes=['textbox_default', 'add_scrollbar']) shared.gradio['textbox-default'] = gr.Textbox(value='', lines=27, label='Input', elem_classes=['textbox_default', 'add_scrollbar'])
shared.gradio['token-counter-default'] = gr.HTML(value="<span>0</span>", elem_classes=["token-counter", "default-token-counter"]) shared.gradio['token-counter-default'] = gr.HTML(value="<span>0</span>", elem_id="default-token-counter")
with gr.Row(): with gr.Row():
shared.gradio['Generate-default'] = gr.Button('Generate', variant='primary')
shared.gradio['Stop-default'] = gr.Button('Stop', elem_id='stop')
shared.gradio['Continue-default'] = gr.Button('Continue') shared.gradio['Continue-default'] = gr.Button('Continue')
shared.gradio['Stop-default'] = gr.Button('Stop', elem_id='stop', visible=False)
shared.gradio['Generate-default'] = gr.Button('Generate', variant='primary')
with gr.Row(): with gr.Row():
shared.gradio['prompt_menu-default'] = gr.Dropdown(choices=utils.get_available_prompts(), value='None', label='Prompt', elem_classes='slim-dropdown') shared.gradio['prompt_menu-default'] = gr.Dropdown(choices=utils.get_available_prompts(), value='None', label='Prompt', elem_classes='slim-dropdown')
@ -63,20 +63,26 @@ def create_ui():
def create_event_handlers(): def create_event_handlers():
shared.gradio['Generate-default'].click( shared.gradio['Generate-default'].click(
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then( ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
lambda : [gr.update(visible=True), gr.update(visible=False)], None, gradio('Stop-default', 'Generate-default')).then(
generate_reply_wrapper, gradio(inputs), gradio(outputs), show_progress=False).then( generate_reply_wrapper, gradio(inputs), gradio(outputs), show_progress=False).then(
lambda state, left, right: state.update({'textbox-default': left, 'output_textbox': right}), gradio('interface_state', 'textbox-default', 'output_textbox'), None).then( lambda state, left, right: state.update({'textbox-default': left, 'output_textbox': right}), gradio('interface_state', 'textbox-default', 'output_textbox'), None).then(
lambda : [gr.update(visible=False), gr.update(visible=True)], None, gradio('Stop-default', 'Generate-default')).then(
None, None, None, js=f'() => {{{ui.audio_notification_js}}}') None, None, None, js=f'() => {{{ui.audio_notification_js}}}')
shared.gradio['textbox-default'].submit( shared.gradio['textbox-default'].submit(
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then( ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
lambda : [gr.update(visible=True), gr.update(visible=False)], None, gradio('Stop-default', 'Generate-default')).then(
generate_reply_wrapper, gradio(inputs), gradio(outputs), show_progress=False).then( generate_reply_wrapper, gradio(inputs), gradio(outputs), show_progress=False).then(
lambda state, left, right: state.update({'textbox-default': left, 'output_textbox': right}), gradio('interface_state', 'textbox-default', 'output_textbox'), None).then( lambda state, left, right: state.update({'textbox-default': left, 'output_textbox': right}), gradio('interface_state', 'textbox-default', 'output_textbox'), None).then(
lambda : [gr.update(visible=False), gr.update(visible=True)], None, gradio('Stop-default', 'Generate-default')).then(
None, None, None, js=f'() => {{{ui.audio_notification_js}}}') None, None, None, js=f'() => {{{ui.audio_notification_js}}}')
shared.gradio['Continue-default'].click( shared.gradio['Continue-default'].click(
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then( ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
lambda : [gr.update(visible=True), gr.update(visible=False)], None, gradio('Stop-default', 'Generate-default')).then(
generate_reply_wrapper, [shared.gradio['output_textbox']] + gradio(inputs)[1:], gradio(outputs), show_progress=False).then( generate_reply_wrapper, [shared.gradio['output_textbox']] + gradio(inputs)[1:], gradio(outputs), show_progress=False).then(
lambda state, left, right: state.update({'textbox-default': left, 'output_textbox': right}), gradio('interface_state', 'textbox-default', 'output_textbox'), None).then( lambda state, left, right: state.update({'textbox-default': left, 'output_textbox': right}), gradio('interface_state', 'textbox-default', 'output_textbox'), None).then(
lambda : [gr.update(visible=False), gr.update(visible=True)], None, gradio('Stop-default', 'Generate-default')).then(
None, None, None, js=f'() => {{{ui.audio_notification_js}}}') None, None, None, js=f'() => {{{ui.audio_notification_js}}}')
shared.gradio['Stop-default'].click(stop_everything_event, None, None, queue=False) shared.gradio['Stop-default'].click(stop_everything_event, None, None, queue=False)

View File

@ -23,7 +23,7 @@ def create_ui():
with gr.Tab('Raw'): with gr.Tab('Raw'):
with gr.Row(): with gr.Row():
shared.gradio['textbox-notebook'] = gr.Textbox(value='', lines=27, elem_id='textbox-notebook', elem_classes=['textbox', 'add_scrollbar']) shared.gradio['textbox-notebook'] = gr.Textbox(value='', lines=27, elem_id='textbox-notebook', elem_classes=['textbox', 'add_scrollbar'])
shared.gradio['token-counter-notebook'] = gr.HTML(value="<span>0</span>", elem_classes=["token-counter"]) shared.gradio['token-counter-notebook'] = gr.HTML(value="<span>0</span>", elem_id="notebook-token-counter")
with gr.Tab('Markdown'): with gr.Tab('Markdown'):
shared.gradio['markdown_render-notebook'] = gr.Button('Render') shared.gradio['markdown_render-notebook'] = gr.Button('Render')
@ -48,10 +48,10 @@ def create_ui():
shared.gradio['tokens-notebook'] = gr.Textbox(lines=23, label='Tokens', elem_classes=['textbox_logits_notebook', 'add_scrollbar', 'monospace']) shared.gradio['tokens-notebook'] = gr.Textbox(lines=23, label='Tokens', elem_classes=['textbox_logits_notebook', 'add_scrollbar', 'monospace'])
with gr.Row(): with gr.Row():
shared.gradio['Generate-notebook'] = gr.Button('Generate', variant='primary', elem_classes='small-button')
shared.gradio['Stop-notebook'] = gr.Button('Stop', elem_classes='small-button', elem_id='stop')
shared.gradio['Undo'] = gr.Button('Undo', elem_classes='small-button') shared.gradio['Undo'] = gr.Button('Undo', elem_classes='small-button')
shared.gradio['Regenerate-notebook'] = gr.Button('Regenerate', elem_classes='small-button') shared.gradio['Regenerate-notebook'] = gr.Button('Regenerate', elem_classes='small-button')
shared.gradio['Stop-notebook'] = gr.Button('Stop', visible=False, elem_classes='small-button', elem_id='stop')
shared.gradio['Generate-notebook'] = gr.Button('Generate', variant='primary', elem_classes='small-button')
with gr.Column(scale=1): with gr.Column(scale=1):
gr.HTML('<div style="padding-bottom: 13px"></div>') gr.HTML('<div style="padding-bottom: 13px"></div>')
@ -66,22 +66,28 @@ def create_event_handlers():
shared.gradio['Generate-notebook'].click( shared.gradio['Generate-notebook'].click(
lambda x: x, gradio('textbox-notebook'), gradio('last_input-notebook')).then( lambda x: x, gradio('textbox-notebook'), gradio('last_input-notebook')).then(
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then( ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
lambda : [gr.update(visible=True), gr.update(visible=False)], None, gradio('Stop-notebook', 'Generate-notebook')).then(
generate_reply_wrapper, gradio(inputs), gradio(outputs), show_progress=False).then( generate_reply_wrapper, gradio(inputs), gradio(outputs), show_progress=False).then(
lambda state, text: state.update({'textbox-notebook': text}), gradio('interface_state', 'textbox-notebook'), None).then( lambda state, text: state.update({'textbox-notebook': text}), gradio('interface_state', 'textbox-notebook'), None).then(
lambda : [gr.update(visible=False), gr.update(visible=True)], None, gradio('Stop-notebook', 'Generate-notebook')).then(
None, None, None, js=f'() => {{{ui.audio_notification_js}}}') None, None, None, js=f'() => {{{ui.audio_notification_js}}}')
shared.gradio['textbox-notebook'].submit( shared.gradio['textbox-notebook'].submit(
lambda x: x, gradio('textbox-notebook'), gradio('last_input-notebook')).then( lambda x: x, gradio('textbox-notebook'), gradio('last_input-notebook')).then(
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then( ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
lambda : [gr.update(visible=True), gr.update(visible=False)], None, gradio('Stop-notebook', 'Generate-notebook')).then(
generate_reply_wrapper, gradio(inputs), gradio(outputs), show_progress=False).then( generate_reply_wrapper, gradio(inputs), gradio(outputs), show_progress=False).then(
lambda state, text: state.update({'textbox-notebook': text}), gradio('interface_state', 'textbox-notebook'), None).then( lambda state, text: state.update({'textbox-notebook': text}), gradio('interface_state', 'textbox-notebook'), None).then(
lambda : [gr.update(visible=False), gr.update(visible=True)], None, gradio('Stop-notebook', 'Generate-notebook')).then(
None, None, None, js=f'() => {{{ui.audio_notification_js}}}') None, None, None, js=f'() => {{{ui.audio_notification_js}}}')
shared.gradio['Regenerate-notebook'].click( shared.gradio['Regenerate-notebook'].click(
lambda x: x, gradio('last_input-notebook'), gradio('textbox-notebook'), show_progress=False).then( lambda x: x, gradio('last_input-notebook'), gradio('textbox-notebook'), show_progress=False).then(
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then( ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
lambda : [gr.update(visible=True), gr.update(visible=False)], None, gradio('Stop-notebook', 'Generate-notebook')).then(
generate_reply_wrapper, gradio(inputs), gradio(outputs), show_progress=False).then( generate_reply_wrapper, gradio(inputs), gradio(outputs), show_progress=False).then(
lambda state, text: state.update({'textbox-notebook': text}), gradio('interface_state', 'textbox-notebook'), None).then( lambda state, text: state.update({'textbox-notebook': text}), gradio('interface_state', 'textbox-notebook'), None).then(
lambda : [gr.update(visible=False), gr.update(visible=True)], None, gradio('Stop-notebook', 'Generate-notebook')).then(
None, None, None, js=f'() => {{{ui.audio_notification_js}}}') None, None, None, js=f'() => {{{ui.audio_notification_js}}}')
shared.gradio['Undo'].click( shared.gradio['Undo'].click(

View File

@ -4,7 +4,7 @@ colorama
datasets datasets
einops einops
fastapi==0.112.4 fastapi==0.112.4
gradio==4.26.* gradio==4.37.*
jinja2==3.1.4 jinja2==3.1.4
markdown markdown
numba==0.59.* numba==0.59.*

View File

@ -3,7 +3,7 @@ colorama
datasets datasets
einops einops
fastapi==0.112.4 fastapi==0.112.4
gradio==4.26.* gradio==4.37.*
jinja2==3.1.4 jinja2==3.1.4
markdown markdown
numba==0.59.* numba==0.59.*

View File

@ -3,7 +3,7 @@ colorama
datasets datasets
einops einops
fastapi==0.112.4 fastapi==0.112.4
gradio==4.26.* gradio==4.37.*
jinja2==3.1.4 jinja2==3.1.4
markdown markdown
numba==0.59.* numba==0.59.*

View File

@ -3,7 +3,7 @@ colorama
datasets datasets
einops einops
fastapi==0.112.4 fastapi==0.112.4
gradio==4.26.* gradio==4.37.*
jinja2==3.1.4 jinja2==3.1.4
markdown markdown
numba==0.59.* numba==0.59.*

View File

@ -3,7 +3,7 @@ colorama
datasets datasets
einops einops
fastapi==0.112.4 fastapi==0.112.4
gradio==4.26.* gradio==4.37.*
jinja2==3.1.4 jinja2==3.1.4
markdown markdown
numba==0.59.* numba==0.59.*

View File

@ -3,7 +3,7 @@ colorama
datasets datasets
einops einops
fastapi==0.112.4 fastapi==0.112.4
gradio==4.26.* gradio==4.37.*
jinja2==3.1.4 jinja2==3.1.4
markdown markdown
numba==0.59.* numba==0.59.*

View File

@ -3,7 +3,7 @@ colorama
datasets datasets
einops einops
fastapi==0.112.4 fastapi==0.112.4
gradio==4.26.* gradio==4.37.*
jinja2==3.1.4 jinja2==3.1.4
markdown markdown
numba==0.59.* numba==0.59.*

View File

@ -4,7 +4,7 @@ colorama
datasets datasets
einops einops
fastapi==0.112.4 fastapi==0.112.4
gradio==4.26.* gradio==4.37.*
jinja2==3.1.4 jinja2==3.1.4
markdown markdown
numba==0.59.* numba==0.59.*

View File

@ -3,7 +3,7 @@ colorama
datasets datasets
einops einops
fastapi==0.112.4 fastapi==0.112.4
gradio==4.26.* gradio==4.37.*
jinja2==3.1.4 jinja2==3.1.4
markdown markdown
numba==0.59.* numba==0.59.*