sanbo commited on
Commit
b017a1d
·
1 Parent(s): 7dda3aa

update sth. at 2025-03-03 19:59:27

Browse files
Files changed (1) hide show
  1. app.py +1 -3
app.py CHANGED
@@ -5,7 +5,6 @@ import torch
5
  import gradio as gr
6
  from fastapi import FastAPI, HTTPException, Depends
7
  from fastapi.middleware.cors import CORSMiddleware
8
- from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
9
  from pydantic import BaseModel, Field, model_validator
10
  from typing import List, Dict, Optional
11
 
@@ -106,7 +105,6 @@ app.add_middleware(
106
  allow_methods=["*"],
107
  allow_headers=["*"],
108
  )
109
- security = HTTPBearer()
110
 
111
  @app.post("/embed", response_model=EmbeddingResponse)
112
  @app.post("/api/embeddings", response_model=EmbeddingResponse)
@@ -117,7 +115,7 @@ security = HTTPBearer()
117
  @app.post("/hf/v1/embeddings", response_model=EmbeddingResponse)
118
  @app.post("/api/v1/chat/completions", response_model=EmbeddingResponse)
119
  @app.post("/hf/v1/chat/completions", response_model=EmbeddingResponse)
120
- async def generate_embeddings(request: EmbeddingRequest, credentials: HTTPAuthorizationCredentials = Depends(security)):
121
  try:
122
  # 计算token数量
123
  token_count = len(embedding_service.tokenizer.encode(request.inputs))
 
5
  import gradio as gr
6
  from fastapi import FastAPI, HTTPException, Depends
7
  from fastapi.middleware.cors import CORSMiddleware
 
8
  from pydantic import BaseModel, Field, model_validator
9
  from typing import List, Dict, Optional
10
 
 
105
  allow_methods=["*"],
106
  allow_headers=["*"],
107
  )
 
108
 
109
  @app.post("/embed", response_model=EmbeddingResponse)
110
  @app.post("/api/embeddings", response_model=EmbeddingResponse)
 
115
  @app.post("/hf/v1/embeddings", response_model=EmbeddingResponse)
116
  @app.post("/api/v1/chat/completions", response_model=EmbeddingResponse)
117
  @app.post("/hf/v1/chat/completions", response_model=EmbeddingResponse)
118
+ async def generate_embeddings(request: EmbeddingRequest):
119
  try:
120
  # 计算token数量
121
  token_count = len(embedding_service.tokenizer.encode(request.inputs))