99i commited on
Commit
e8426cb
·
verified ·
1 Parent(s): 3eeaab0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -179,6 +179,12 @@ async def embeddings(request: Request):
179
  @app.get("/hf/v1/models")
180
  async def models(request: Request):
181
  """转发 models 请求."""
 
 
 
 
 
 
182
  async with httpx.AsyncClient(timeout=REQUEST_TIMEOUT) as client:
183
  response = await client.get(
184
  "https://api.siliconflow.cn/v1/models", headers=headers
 
179
  @app.get("/hf/v1/models")
180
  async def models(request: Request):
181
  """转发 models 请求."""
182
+ """通用的请求转发函数."""
183
+ body = await request.json()
184
+ key = get_api_key()
185
+ if not key:
186
+ raise HTTPException(status_code=400, detail="No valid API key available.")
187
+ headers = {"Authorization": f"Bearer {key}"}
188
  async with httpx.AsyncClient(timeout=REQUEST_TIMEOUT) as client:
189
  response = await client.get(
190
  "https://api.siliconflow.cn/v1/models", headers=headers