mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-10-05 12:28:22 +00:00
convert prints to logging
This commit is contained in:
@@ -7,8 +7,11 @@ from urllib.request import urlopen
|
|||||||
from fastapi import APIRouter
|
from fastapi import APIRouter
|
||||||
from pydantic.v1 import BaseModel
|
from pydantic.v1 import BaseModel
|
||||||
|
|
||||||
|
from ..core.logging import get_logger
|
||||||
from .price import sats_usd_ask_price
|
from .price import sats_usd_ask_price
|
||||||
|
|
||||||
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
models_router = APIRouter()
|
models_router = APIRouter()
|
||||||
|
|
||||||
|
|
||||||
@@ -101,7 +104,7 @@ def load_models() -> list[Model]:
|
|||||||
|
|
||||||
# Check if user has actively provided a models.json file
|
# Check if user has actively provided a models.json file
|
||||||
if models_path.exists():
|
if models_path.exists():
|
||||||
print(f"Loading models from user-provided file: {models_path}")
|
logger.info(f"Loading models from user-provided file: {models_path}")
|
||||||
try:
|
try:
|
||||||
with models_path.open("r") as f:
|
with models_path.open("r") as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
@@ -111,16 +114,16 @@ def load_models() -> list[Model]:
|
|||||||
# Fall through to auto-generation
|
# Fall through to auto-generation
|
||||||
|
|
||||||
# Auto-generate models from OpenRouter API
|
# Auto-generate models from OpenRouter API
|
||||||
print("Auto-generating models from OpenRouter API")
|
logger.info("Auto-generating models from OpenRouter API")
|
||||||
source_filter = os.getenv("SOURCE")
|
source_filter = os.getenv("SOURCE")
|
||||||
source_filter = source_filter if source_filter and source_filter.strip() else None
|
source_filter = source_filter if source_filter and source_filter.strip() else None
|
||||||
|
|
||||||
models_data = fetch_openrouter_models(source_filter=source_filter)
|
models_data = fetch_openrouter_models(source_filter=source_filter)
|
||||||
if not models_data:
|
if not models_data:
|
||||||
print("Failed to fetch models from OpenRouter API")
|
logger.error("Failed to fetch models from OpenRouter API")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
print(f"Successfully fetched {len(models_data)} models from OpenRouter API")
|
logger.info(f"Successfully fetched {len(models_data)} models from OpenRouter API")
|
||||||
return [Model(**model) for model in models_data]
|
return [Model(**model) for model in models_data]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user