Skip to content

Commit

Permalink
向量处理问题
Browse files Browse the repository at this point in the history
  • Loading branch information
glide-the committed May 21, 2024
1 parent 7b6cc81 commit 842a230
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ async def create_embeddings(
model=embeddings_request.model,
)

# 判断embeddings_request.input是否为list
# 判断embeddings_request.input是否为list[int]
input = ""
if isinstance(embeddings_request.input, list):
tokens = embeddings_request.input
Expand All @@ -241,8 +241,13 @@ async def create_embeddings(
model = "cl100k_base"
encoding = tiktoken.get_encoding(model)
for i, token in enumerate(tokens):
text = encoding.decode(token)
input += text
# 判断是否是int
if isinstance(token, int):
text = encoding.decode(token)
input += text
else:
input += token


else:
input = embeddings_request.input
Expand Down

0 comments on commit 842a230

Please sign in to comment.