Files
weval-l99/oss-cache-refresh.py
2026-04-13 12:43:21 +02:00

25 lines
1007 B
Python

#!/usr/bin/env python3
"""OSS Cache Refresh — rebuilds oss-cache.json from oss-trending.json + Qdrant stats"""
import json, os, urllib.request
from datetime import datetime
TRENDING = "/var/www/html/api/oss-trending.json"
CACHE = "/var/www/html/api/oss-cache.json"
def main():
print(f"[{datetime.now().strftime('%H:%M:%S')}] OSS Cache Refresh")
tools = json.load(open(TRENDING)) if os.path.exists(TRENDING) else []
# Get Qdrant stats
qdrant_count = 0
try:
r = urllib.request.urlopen("http://127.0.0.1:6333/collections/weval_skills", timeout=3)
d = json.loads(r.read())
qdrant_count = d.get("result",{}).get("points_count",0)
except: pass
cache = {"report":{"total":len(tools),"qdrant_skills":qdrant_count,"refreshed":datetime.now().isoformat()},
"skills":tools}
json.dump(cache, open(CACHE,"w"), ensure_ascii=False, indent=2)
print(f" Cache: {len(tools)} tools, {qdrant_count} Qdrant vectors")
if __name__ == "__main__": main()