Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions css/highlightjs/github-dark.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions css/highlightjs/highlightjs-copy.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions css/html_instruct_style.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
.chat {
background: var(--block-background-fill);
background: transparent;
padding: 24px 19px;
padding-right: 19px !important;
padding-top: 0;
border: 1px solid var(--block-border-color);
}

.chat > .messages {
padding-top: 28px !important;
padding-top: 18px !important;
}

.message {
Expand Down Expand Up @@ -50,23 +49,24 @@

.gradio-container .chat .assistant-message {
padding: 20px;
background: var(--background-fill-secondary);
margin-top: 12px !important;
margin-bottom: 24px !important;
margin-right: 16px;
border-radius: 22px;
border-bottom-left-radius: 0;
background: var(--color-grey-200);
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;
background-color: var(--color-accent-soft);
margin-bottom: 12px !important;
margin-left: 16px;
border-radius: 22px;
padding-left: 0px;
padding-right: 0px;
background-color: transparent;
border-radius: 8px;
border-bottom-right-radius: 0;
border: 1px solid var(--border-color-accent-subdued);
}

.gradio-container .chat .assistant-message:last-child, .gradio-container .chat .user-message:last-child {
Expand All @@ -79,4 +79,4 @@ code {

.dark code {
background-color: #1f2937 !important;
}
}
Binary file added css/katex/fonts/KaTeX_AMS-Regular.ttf
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_AMS-Regular.woff
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_AMS-Regular.woff2
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Caligraphic-Bold.ttf
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Caligraphic-Bold.woff
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Caligraphic-Bold.woff2
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Caligraphic-Regular.ttf
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Caligraphic-Regular.woff
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Caligraphic-Regular.woff2
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Fraktur-Bold.ttf
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Fraktur-Bold.woff
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Fraktur-Bold.woff2
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Fraktur-Regular.ttf
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Fraktur-Regular.woff
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Fraktur-Regular.woff2
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Main-Bold.ttf
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Main-Bold.woff
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Main-Bold.woff2
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Main-BoldItalic.ttf
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Main-BoldItalic.woff
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Main-BoldItalic.woff2
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Main-Italic.ttf
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Main-Italic.woff
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Main-Italic.woff2
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Main-Regular.ttf
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Main-Regular.woff
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Main-Regular.woff2
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Math-BoldItalic.ttf
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Math-BoldItalic.woff
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Math-BoldItalic.woff2
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Math-Italic.ttf
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Math-Italic.woff
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Math-Italic.woff2
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_SansSerif-Bold.ttf
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_SansSerif-Bold.woff
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_SansSerif-Bold.woff2
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_SansSerif-Italic.ttf
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_SansSerif-Italic.woff
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_SansSerif-Italic.woff2
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_SansSerif-Regular.ttf
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_SansSerif-Regular.woff
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_SansSerif-Regular.woff2
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Script-Regular.ttf
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Script-Regular.woff
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Script-Regular.woff2
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Size1-Regular.ttf
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Size1-Regular.woff
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Size1-Regular.woff2
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Size2-Regular.ttf
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Size2-Regular.woff
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Size2-Regular.woff2
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Size3-Regular.ttf
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Size3-Regular.woff
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Size3-Regular.woff2
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Size4-Regular.ttf
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Size4-Regular.woff
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Size4-Regular.woff2
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Typewriter-Regular.ttf
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Typewriter-Regular.woff
Binary file not shown.
Binary file added css/katex/fonts/KaTeX_Typewriter-Regular.woff2
Binary file not shown.
1 change: 1 addition & 0 deletions css/katex/katex.min.css

Large diffs are not rendered by default.

30 changes: 18 additions & 12 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ gradio-app > :first-child {

.header_bar {
background-color: #f7f7f7;
box-shadow: 0 2px 3px rgba(22 22 22 / 35%);
box-shadow: 0 0px 3px rgba(22 22 22 / 35%);
margin-bottom: 0;
overflow-x: scroll;
margin-left: calc(-1 * var(--size-4));
Expand Down Expand Up @@ -220,7 +220,7 @@ button {
}

.pretty_scrollbar::-webkit-scrollbar {
width: 5px;
width: 7px;
}

.pretty_scrollbar::-webkit-scrollbar-track {
Expand All @@ -229,12 +229,12 @@ button {

.pretty_scrollbar::-webkit-scrollbar-thumb,
.pretty_scrollbar::-webkit-scrollbar-thumb:hover {
background: #c5c5d2;
background: var(--neutral-300);
}

.dark .pretty_scrollbar::-webkit-scrollbar-thumb,
.dark .pretty_scrollbar::-webkit-scrollbar-thumb:hover {
background: #374151;
background: var(--neutral-700);
}

.pretty_scrollbar::-webkit-resizer {
Expand Down Expand Up @@ -433,11 +433,12 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
.message-body code {
white-space: pre-wrap !important;
word-wrap: break-word !important;
border: 1px solid var(--border-color-primary);
border-radius: var(--radius-sm);
background: var(--background-fill-secondary);
font-size: 90%;
border: 1px solid #666666;
border-radius: 5px;
font-size: 82%;
padding: 1px 3px;
background: #0d1117 !important;
color: rgb(201, 209, 217);
}

.message-body pre > code {
Expand Down Expand Up @@ -518,8 +519,12 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
text-overflow: ellipsis;
}

.dark #show-controls span {
color: var(--neutral-400);
}

#show-controls span {
opacity: 0.6;
color: var(--neutral-600);
}

#typing-container {
Expand Down Expand Up @@ -590,8 +595,8 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
position: absolute;
bottom: 80%;
left: 0;
background-color: var(--background-fill-secondary);
box-shadow: 0 0 10px rgb(0 0 0 / 50%);
background-color: var(--background-fill-primary);
box-shadow: 0 0 5px rgb(0 0 0 / 25%);
z-index: 10000;
min-width: 330px;
flex-direction: column;
Expand All @@ -601,6 +606,7 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
width: 100%;
background: transparent !important;
border-radius: 0 !important;
border-color: var(--border-color-primary);
justify-content: space-between;
margin: 0 !important;
height: 36px;
Expand All @@ -611,7 +617,7 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
}

.hover-menu button:not(#clear-history-confirm):last-child {
border-bottom: var(--button-border-width) solid var(--button-secondary-border-color) !important;
border-bottom: var(--button-border-width) solid var(--border-color-primary) !important;
}

.hover-menu button:hover {
Expand Down
101 changes: 59 additions & 42 deletions download-model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
import re
import sys
from pathlib import Path
from time import sleep

import requests
import tqdm
from requests.adapters import HTTPAdapter
from requests.exceptions import ConnectionError, RequestException, Timeout
from tqdm.contrib.concurrent import thread_map

base = os.environ.get("HF_ENDPOINT") or "https://huggingface.co"
Expand Down Expand Up @@ -177,50 +179,65 @@ def get_output_folder(self, model, branch, is_lora, is_llamacpp=False):
return output_folder

def get_single_file(self, url, output_folder, start_from_scratch=False):
session = self.get_session()
filename = Path(url.rsplit('/', 1)[1])
output_path = output_folder / filename
headers = {}
mode = 'wb'
if output_path.exists() and not start_from_scratch:

# Check if the file has already been downloaded completely
r = session.get(url, stream=True, timeout=10)
total_size = int(r.headers.get('content-length', 0))
if output_path.stat().st_size >= total_size:
return

# Otherwise, resume the download from where it left off
headers = {'Range': f'bytes={output_path.stat().st_size}-'}
mode = 'ab'

with session.get(url, stream=True, headers=headers, timeout=10) as r:
r.raise_for_status() # Do not continue the download if the request was unsuccessful
total_size = int(r.headers.get('content-length', 0))
block_size = 1024 * 1024 # 1MB

tqdm_kwargs = {
'total': total_size,
'unit': 'iB',
'unit_scale': True,
'bar_format': '{l_bar}{bar}| {n_fmt:6}/{total_fmt:6} {rate_fmt:6}'
}

if 'COLAB_GPU' in os.environ:
tqdm_kwargs.update({
'position': 0,
'leave': True
})

with open(output_path, mode) as f:
with tqdm.tqdm(**tqdm_kwargs) as t:
count = 0
for data in r.iter_content(block_size):
t.update(len(data))
f.write(data)
if total_size != 0 and self.progress_bar is not None:
count += len(data)
self.progress_bar(float(count) / float(total_size), f"{filename}")

max_retries = 7
attempt = 0
while attempt < max_retries:
attempt += 1
session = self.get_session()
headers = {}
mode = 'wb'

if output_path.exists() and not start_from_scratch:
# Resume download
r = session.get(url, stream=True, timeout=20)
total_size = int(r.headers.get('content-length', 0))
if output_path.stat().st_size >= total_size:
return

headers = {'Range': f'bytes={output_path.stat().st_size}-'}
mode = 'ab'

try:
with session.get(url, stream=True, headers=headers, timeout=30) as r:
r.raise_for_status() # If status is not 2xx, raise an error
total_size = int(r.headers.get('content-length', 0))
block_size = 1024 * 1024 # 1MB

tqdm_kwargs = {
'total': total_size,
'unit': 'iB',
'unit_scale': True,
'bar_format': '{l_bar}{bar}| {n_fmt}/{total_fmt} {rate_fmt}'
}

if 'COLAB_GPU' in os.environ:
tqdm_kwargs.update({
'position': 0,
'leave': True
})

with open(output_path, mode) as f:
with tqdm.tqdm(**tqdm_kwargs) as t:
count = 0
for data in r.iter_content(block_size):
f.write(data)
t.update(len(data))
if total_size != 0 and self.progress_bar is not None:
count += len(data)
self.progress_bar(float(count) / float(total_size), f"{filename}")

break # Exit loop if successful
except (RequestException, ConnectionError, Timeout) as e:
print(f"Error downloading {filename}: {e}.")
print(f"That was attempt {attempt}/{max_retries}.", end=' ')
if attempt < max_retries:
print(f"Retry begins in {2 ** attempt} seconds.")
sleep(2 ** attempt)
else:
print("Failed to download after the maximum number of attempts.")

def start_download_threads(self, file_list, output_folder, start_from_scratch=False, threads=4):
thread_map(lambda url: self.get_single_file(url, output_folder, start_from_scratch=start_from_scratch), file_list, max_workers=threads, disable=True)
Expand Down
Loading