pvanand commited on
Commit
76466bd
·
verified ·
1 Parent(s): dcb9038

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +15 -1
main.py CHANGED
@@ -184,7 +184,21 @@ async def followup_agent(query: FollowupQueryModel, background_tasks: Background
184
  logger.error(f"Error in followup_agent: {str(e)}")
185
  raise HTTPException(status_code=500, detail="An error occurred while processing the followup agent request.")
186
 
187
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  from fastapi.middleware.cors import CORSMiddleware
189
 
190
  app.add_middleware(
 
184
  logger.error(f"Error in followup_agent: {str(e)}")
185
  raise HTTPException(status_code=500, detail="An error occurred while processing the followup agent request.")
186
 
187
+ class ModelsResponse(BaseModel):
188
+ models: List[str]
189
+
190
+ @app.get("/models", response_model=ModelsResponse)
191
+ def get_models():
192
+ """
193
+ Endpoint to return a list of available model IDs dynamically extracted from the ModelID Literal.
194
+ """
195
+ try:
196
+ # Dynamically extract the literal values of ModelID
197
+ model_list = list(get_args(ModelID))
198
+ return ModelsResponse(models=model_list)
199
+ except Exception as e:
200
+ raise HTTPException(status_code=500, detail=f"An error occurred while fetching the models: {str(e)}")
201
+
202
  from fastapi.middleware.cors import CORSMiddleware
203
 
204
  app.add_middleware(