From 7f3ae7d2eccc83c24d9b272ffd5deea18239fd64 Mon Sep 17 00:00:00 2001 From: Shroominic Date: Mon, 30 Jun 2025 09:36:29 -0300 Subject: [PATCH] make script run without extra deps --- scripts/models_meta.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/scripts/models_meta.py b/scripts/models_meta.py index eb9fd238..79813c1e 100644 --- a/scripts/models_meta.py +++ b/scripts/models_meta.py @@ -1,8 +1,6 @@ -import asyncio import json from typing import TypedDict - -import httpx +from urllib.request import urlopen class ModelArchitecture(TypedDict): @@ -40,12 +38,10 @@ class Model(TypedDict): per_request_limits: dict | None -async def fetch_openrouter_models() -> list[Model]: +def fetch_openrouter_models() -> list[Model]: """Fetches model information from OpenRouter API.""" - async with httpx.AsyncClient() as client: - response = await client.get("https://openrouter.ai/api/v1/models") - response.raise_for_status() - data = response.json() + with urlopen("https://openrouter.ai/api/v1/models") as response: + data = json.loads(response.read().decode("utf-8")) models_data: list[Model] = [] for model in data.get("data", []): @@ -64,8 +60,8 @@ async def fetch_openrouter_models() -> list[Model]: return models_data -async def main() -> None: - models = await fetch_openrouter_models() +def main() -> None: + models = fetch_openrouter_models() # Print the first model data in a nicely indented JSON format print(json.dumps(models[0], indent=4)) @@ -75,4 +71,4 @@ async def main() -> None: if __name__ == "__main__": - asyncio.run(main()) + main()