mirror of
https://github.com/ollama/ollama-python.git
synced 2026-08-07 05:47:46 +00:00
Examples refactor (#329)
* Examples and README updates --------- Co-authored-by: fujitatomoya <[email protected]> Co-authored-by: Michael Yang <[email protected]>
This commit is contained in:
co-authored by
fujitatomoya
Michael Yang
parent
139c89e833
commit
64c1eb78ff
@@ -0,0 +1,21 @@
|
||||
from tqdm import tqdm
|
||||
from ollama import pull
|
||||
|
||||
|
||||
current_digest, bars = '', {}
|
||||
for progress in pull('llama3.2', 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'pulling {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