pagezyhf HF Staff commited on
Commit
08e0ab7
·
1 Parent(s): e0174a0
Files changed (1) hide show
  1. app/main.py +10 -14
app/main.py CHANGED
@@ -41,18 +41,12 @@ async def home(request: Request):
41
  async def get_model_list():
42
  logger.info("Fetching model list")
43
  try:
44
- # Ensure cache directory exists
45
- os.makedirs("/cache", exist_ok=True)
46
 
47
- # Get actual model configurations
48
  model_list = utils.get_hub_cached_models(mode="inference")
49
  logger.info(f"Found {len(model_list)} models")
50
 
51
- if not model_list:
52
- logger.warning("No models found")
53
- return JSONResponse(content=[])
54
-
55
- # Transform the data into the expected format
56
  models = []
57
  seen_models = set()
58
 
@@ -63,21 +57,23 @@ async def get_model_list():
63
  if full_model_id not in seen_models:
64
  models.append({
65
  "id": full_model_id,
66
- "name": full_model_id, # This will be used as the title
67
- "type": architecture # This will be used as the subtitle
68
  })
69
  seen_models.add(full_model_id)
70
 
71
  logger.info(f"Returning {len(models)} unique models")
72
  return JSONResponse(content=models)
73
  except Exception as e:
74
- logger.error(f"Error fetching models: {str(e)}", exc_info=True)
 
 
75
  return JSONResponse(
76
  status_code=500,
77
- content={"error": str(e)}
78
  )
79
 
80
- @app.get("/api/models/{model_id}")
81
  async def get_model_info_endpoint(model_id: str):
82
  logger.info(f"Fetching configurations for model: {model_id}")
83
  try:
@@ -92,4 +88,4 @@ async def get_model_info_endpoint(model_id: str):
92
  return JSONResponse(
93
  status_code=500,
94
  content={"error": str(e)}
95
- )
 
41
  async def get_model_list():
42
  logger.info("Fetching model list")
43
  try:
44
+ # Add debug logging
45
+ logger.info(f"HF_TOKEN present: {bool(os.getenv('HF_TOKEN'))}")
46
 
 
47
  model_list = utils.get_hub_cached_models(mode="inference")
48
  logger.info(f"Found {len(model_list)} models")
49
 
 
 
 
 
 
50
  models = []
51
  seen_models = set()
52
 
 
57
  if full_model_id not in seen_models:
58
  models.append({
59
  "id": full_model_id,
60
+ "name": full_model_id,
61
+ "type": architecture
62
  })
63
  seen_models.add(full_model_id)
64
 
65
  logger.info(f"Returning {len(models)} unique models")
66
  return JSONResponse(content=models)
67
  except Exception as e:
68
+ # Enhanced error logging
69
+ logger.error(f"Error fetching models: {str(e)}")
70
+ logger.error("Full error details:", exc_info=True)
71
  return JSONResponse(
72
  status_code=500,
73
+ content={"error": str(e), "type": str(type(e).__name__)}
74
  )
75
 
76
+ @app.get("/api/models/{model_id:path}")
77
  async def get_model_info_endpoint(model_id: str):
78
  logger.info(f"Fetching configurations for model: {model_id}")
79
  try:
 
88
  return JSONResponse(
89
  status_code=500,
90
  content={"error": str(e)}
91
+ )