mirror of
https://github.com/snailyp/gemini-balance.git
synced 2026-06-28 03:02:12 +08:00
新增list_models接口的授权验证逻辑,完善模型格式转换结构
This commit is contained in:
@@ -24,7 +24,10 @@ embedding_service = EmbeddingService(settings.BASE_URL)
|
||||
|
||||
@router.get("/v1/models")
|
||||
@router.get("/hf/v1/models")
|
||||
async def list_models():
|
||||
async def list_models(
|
||||
authorization: str = Header(None),
|
||||
token: str = Depends(security_service.verify_authorization),
|
||||
):
|
||||
logger.info("Handling models list request")
|
||||
api_key = await key_manager.get_next_working_key()
|
||||
logger.info(f"Using API key: {api_key}")
|
||||
|
||||
@@ -31,7 +31,7 @@ class ModelService:
|
||||
def convert_to_openai_models_format(
|
||||
self, gemini_models: Dict[str, Any]
|
||||
) -> Dict[str, Any]:
|
||||
openai_format = {"object": "list", "data": []}
|
||||
openai_format = {"object": "list", "data": [],"success": True}
|
||||
|
||||
for model in gemini_models.get("models", []):
|
||||
model_id = model["name"].split("/")[-1]
|
||||
@@ -43,7 +43,7 @@ class ModelService:
|
||||
"permission": [],
|
||||
"root": model["name"],
|
||||
"parent": None,
|
||||
"success": True,
|
||||
|
||||
}
|
||||
openai_format["data"].append(openai_model)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user