import streamlit as st import pandas as pd import requests import os import time from datetime import datetime import humanize st.header("List Ollama model downloads") HOST = os.getenv("HOST", "https://1tsnakers-ollamasearchapi.hf.space") def is_api_up(): try: r = requests.get(f"{HOST}/ping") return r.status_code == 200 except: return False namespace = st.text_input( "Namespace", value="library" ) if st.button("Make list"): start_time = time.time() if not is_api_up(): st.error("API is not reachable") else: if not namespace: st.warning("Namespace cannot be empty!") st.stop() r = requests.get(f"{HOST}/{namespace}") library = r.json()["results"] models = [model["model_base_name"] for model in library] pull_count = [int(model["pull_count"]) for model in library] date = [datetime.fromisoformat(model["last_updated_iso"]) for model in library] total_time = time.time() - start_time total_time = round(total_time, 3) cache_time = datetime.fromisoformat(r.json()["cached_at"]) - time.time() st.write(f"{len(models)} models counted in {total_time} seconds") st.write(f"Cache expires in {humanize.naturaltime(cache_time)}") df = pd.DataFrame({ "model": models, "pull_count": pull_count, "date": date }) st.dataframe( df, hide_index=True, column_config={ "model": "AI Model", "Pulls": st.column_config.NumberColumn("Pulls"), "date": st.column_config.DateColumn("Last Updated") } )