AI_Table / app.py
1TSnakers's picture
Update app.py
2dfdba7 verified
raw
history blame
1.4 kB
import streamlit as st
import pandas as pd
import requests
import os
import time
from datetime import datetime
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
if st.button("Make list"):
start_time = time.time()
if not is_api_up():
st.error("API is not reachable")
else:
r = requests.get(f"{HOST}/search?q=%20")
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)
st.write(f"{len(models)} models counted in {total_time} seconds")
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")
}
)