fix OpenAI Embedding length error (#1972)
### What problem does this PR solve? #1958 fix OpenAI Embedding length error ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --------- Co-authored-by: Zhedong Cen <cenzhedong2@126.com>
This commit is contained in:
parent
5b5e3677b6
commit
b4ef50bdb5
1 changed files with 2 additions and 2 deletions
|
|
@ -99,14 +99,14 @@ class OpenAIEmbed(Base):
|
|||
self.model_name = model_name
|
||||
|
||||
def encode(self, texts: list, batch_size=32):
|
||||
texts = [truncate(t, 8196) for t in texts]
|
||||
texts = [truncate(t, 8191) for t in texts]
|
||||
res = self.client.embeddings.create(input=texts,
|
||||
model=self.model_name)
|
||||
return np.array([d.embedding for d in res.data]
|
||||
), res.usage.total_tokens
|
||||
|
||||
def encode_queries(self, text):
|
||||
res = self.client.embeddings.create(input=[truncate(text, 8196)],
|
||||
res = self.client.embeddings.create(input=[truncate(text, 8191)],
|
||||
model=self.model_name)
|
||||
return np.array(res.data[0].embedding), res.usage.total_tokens
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue