Skip to content

Commit

Permalink
add /v1/models endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
yym68686 committed Jul 9, 2024
1 parent 08e1b7e commit 3790bd8
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,29 @@ def verify_api_key(credentials: HTTPAuthorizationCredentials = Depends(security)
async def request_model(request: RequestModel, token: str = Depends(verify_api_key)):
return await model_handler.request_model(request, token)

def get_all_models():
config = load_config()
all_models = []

for provider in config:
for model in provider['model']:
model_info = {
"id": model,
"object": "model",
"created": 1720524448858,
"owned_by": provider['provider']
}
all_models.append(model_info)

return all_models

@app.get("/v1/models")
async def list_models():
models = get_all_models()
return {
"object": "list",
"data": models
}
if __name__ == '__main__':
import uvicorn
uvicorn.run("__main__:app", host="0.0.0.0", port=8000, reload=True)

0 comments on commit 3790bd8

Please sign in to comment.