mirror of
https://github.com/kharonsec/ollama-python
synced 2026-05-10 17:12:03 +02:00
examples: rename directories
This commit is contained in:
23
examples/pull-progress/main.py
Normal file
23
examples/pull-progress/main.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# pip install tqdm
|
||||
|
||||
from tqdm import tqdm
|
||||
from ollama import pull
|
||||
|
||||
|
||||
current_digest, bars = '', {}
|
||||
for progress in pull('mistral', stream=True):
|
||||
digest = progress.get('digest', '')
|
||||
if digest != current_digest and current_digest in bars:
|
||||
bars[current_digest].close()
|
||||
|
||||
if not digest:
|
||||
print(progress.get('status'))
|
||||
continue
|
||||
|
||||
if digest not in bars and (total := progress.get('total')):
|
||||
bars[digest] = tqdm(total=total, desc=f'pushing {digest[7:19]}', unit='B', unit_scale=True)
|
||||
|
||||
if completed := progress.get('completed'):
|
||||
bars[digest].update(completed - bars[digest].n)
|
||||
|
||||
current_digest = digest
|
||||
Reference in New Issue
Block a user