fix: embedding 与 model_name 类型检查

This commit is contained in:
2024-01-15 14:21:01 +08:00
parent dabdbb42de
commit 70a08a9ed1
2 changed files with 5 additions and 3 deletions

6
app.py
View File

@@ -32,12 +32,14 @@ async def embedding_api(req: EmbeddingAPIRequest) -> EmbeddingAPIResposne:
req.input = [req.input]
# 进行 embedding 计算
embeddings: list[float] = []
embeddings: list[list[float]] = []
if req.model == "acge-large-zh":
embeddings = acge_embedding(req.input).tolist()
embeddings = acge_embedding(req.input)
elif req.model == "text-embedding-ada-002":
# [TODO]: Implement text-embedding-ada-002
raise NotImplementedError("text-embedding-ada-002 not implemented yet!")
else:
raise ValueError("Unknown model name!")
# 与 OpenAI 接口返回格式一致
# https://platform.openai.com/docs/api-reference/embeddings/create