mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2026-01-28 03:14:43 +01:00
Properly fix the /v1/models endpoint
This commit is contained in:
parent
93cd47c948
commit
84617abdeb
|
|
@ -18,6 +18,15 @@ def list_models():
|
|||
return {'model_names': get_available_models()}
|
||||
|
||||
|
||||
def list_models_openai_format():
|
||||
"""Returns model list in OpenAI API format"""
|
||||
model_names = get_available_models()
|
||||
return {
|
||||
"object": "list",
|
||||
"data": [model_info_dict(name) for name in model_names]
|
||||
}
|
||||
|
||||
|
||||
def model_info_dict(model_name: str) -> dict:
|
||||
return {
|
||||
"id": model_name,
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ async def handle_models(request: Request):
|
|||
is_list = request.url.path.split('?')[0].split('#')[0] == '/v1/models'
|
||||
|
||||
if is_list:
|
||||
response = OAImodels.list_models()['model_names']
|
||||
response = OAImodels.list_models_openai_format()
|
||||
else:
|
||||
model_name = path[len('/v1/models/'):]
|
||||
response = OAImodels.model_info_dict(model_name)
|
||||
|
|
|
|||
Loading…
Reference in a new issue