Zalohovani vsech podstatnych souboru
This commit is contained in:
74
scripts/check_nanobot_version.py
Executable file
74
scripts/check_nanobot_version.py
Executable file
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env -S uv run --script
|
||||
# /// script
|
||||
# requires-python = ">=3.11"
|
||||
# dependencies = ["nanobot-ai"]
|
||||
# ///
|
||||
"""Check latest nanobot version from PyPI, GitHub releases, and Docker Hub."""
|
||||
|
||||
import importlib.metadata
|
||||
import json
|
||||
import sys
|
||||
from urllib.error import URLError
|
||||
from urllib.request import Request, urlopen
|
||||
|
||||
try:
|
||||
CURRENT_VERSION = importlib.metadata.version("nanobot-ai")
|
||||
except importlib.metadata.PackageNotFoundError:
|
||||
CURRENT_VERSION = "unknown"
|
||||
|
||||
USER_AGENT = "nanobot-version-check/1.0"
|
||||
|
||||
|
||||
def fetch_json(url: str, timeout: int = 10) -> dict | None:
|
||||
req = Request(url, headers={"User-Agent": USER_AGENT})
|
||||
try:
|
||||
with urlopen(req, timeout=timeout) as resp:
|
||||
return json.loads(resp.read())
|
||||
except (URLError, json.JSONDecodeError, OSError) as e:
|
||||
print(f" Error fetching {url}: {e}", file=sys.stderr)
|
||||
return None
|
||||
|
||||
|
||||
def check_pypi() -> str | None:
|
||||
data = fetch_json("https://pypi.org/pypi/nanobot-ai/json")
|
||||
if data:
|
||||
return data.get("info", {}).get("version")
|
||||
return None
|
||||
|
||||
|
||||
def check_github() -> str | None:
|
||||
data = fetch_json("https://api.github.com/repos/HKUDS/nanobot/releases/latest")
|
||||
if data:
|
||||
tag = data.get("tag_name", "")
|
||||
return tag.lstrip("v") if tag else None
|
||||
return None
|
||||
|
||||
|
||||
def check_docker() -> str | None:
|
||||
data = fetch_json("https://hub.docker.com/v2/repositories/smanx/nanobot/tags?page_size=10")
|
||||
if data:
|
||||
for tag in data.get("results", []):
|
||||
name = tag.get("name", "")
|
||||
if name and name != "latest":
|
||||
return name
|
||||
return None
|
||||
|
||||
|
||||
def main():
|
||||
print(f"Current nanobot version: {CURRENT_VERSION}")
|
||||
|
||||
pypi = check_pypi()
|
||||
if pypi:
|
||||
print(f"Latest PyPI version: {pypi}")
|
||||
|
||||
github = check_github()
|
||||
if github:
|
||||
print(f"Latest GitHub release: {github}")
|
||||
|
||||
docker = check_docker()
|
||||
if docker:
|
||||
print(f"Latest Docker Hub version tag: {docker}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
5
scripts/ollama_library.txt
Normal file
5
scripts/ollama_library.txt
Normal file
File diff suppressed because one or more lines are too long
27
scripts/ollama_library_full.txt
Normal file
27
scripts/ollama_library_full.txt
Normal file
File diff suppressed because one or more lines are too long
23
scripts/parse_library.py
Normal file
23
scripts/parse_library.py
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Parse the ollama library page text dump and list unique models."""
|
||||
import re, json, sys
|
||||
|
||||
raw = open('scripts/ollama_library_full.txt').read()
|
||||
first_line = raw.split('\n')[0]
|
||||
# Each line is prefixed "N| " repeated; find the first { and the last }
|
||||
start = first_line.find('{')
|
||||
end = first_line.rfind('}') + 1
|
||||
first_line = first_line[start:end]
|
||||
j = json.loads(first_line)
|
||||
text = j['text']
|
||||
print('text length:', len(text))
|
||||
|
||||
# Pattern: ## [name desc](https://ollama.com/library/normalized)
|
||||
matches = re.findall(r'## \[([a-z0-9.\-]+) [^\]]*\]\(https://ollama.com/library/([a-z0-9.\-]+)\)', text)
|
||||
seen = {}
|
||||
for desc, name in matches:
|
||||
seen.setdefault(name, desc)
|
||||
|
||||
print('Total models in library page:', len(seen))
|
||||
for n in sorted(seen):
|
||||
print(f'{n}\t{seen[n][:80]}')
|
||||
Reference in New Issue
Block a user