ParthSadaria commited on
Commit
614a889
·
verified ·
1 Parent(s): 1995cd0

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -7
main.py CHANGED
@@ -105,13 +105,15 @@ async def root():
105
  return HTMLResponse(content="<h1>File not found</h1>", status_code=404)
106
 
107
  async def get_models():
108
- async with httpx.AsyncClient() as client:
109
- try:
110
- response = await client.get(f"{secret_api_endpoint}/v1/models", timeout=3)
111
- response.raise_for_status()
112
- return response.json()
113
- except httpx.RequestError as e:
114
- raise HTTPException(status_code=500, detail=f"Request failed: {e}")
 
 
115
 
116
  @app.get("/models")
117
  async def fetch_models():
 
105
  return HTMLResponse(content="<h1>File not found</h1>", status_code=404)
106
 
107
  async def get_models():
108
+ try:
109
+ # Load the models from models.json in the same folder
110
+ file_path = Path(__file__).parent / 'models.json'
111
+ with open(file_path, 'r') as f:
112
+ return json.load(f)
113
+ except FileNotFoundError:
114
+ raise HTTPException(status_code=404, detail="models.json not found")
115
+ except json.JSONDecodeError:
116
+ raise HTTPException(status_code=500, detail="Error decoding models.json")
117
 
118
  @app.get("/models")
119
  async def fetch_models():