jonathanjordan21 commited on
Commit
1d3dcfd
1 Parent(s): 87bcf8e

Update apis/chat_api.py

Browse files
Files changed (1) hide show
  1. apis/chat_api.py +3 -3
apis/chat_api.py CHANGED
@@ -325,11 +325,11 @@ class ChatAPIApp:
325
  model = request.model
326
  model_kwargs = request.options
327
  encoding = tiktoken.get_encoding("cl100k_base")
328
- embeddings = self.embeddings[model].encode(encoding.decode(request.input), convert_to_tensor=True)#, **model_kwargs)
329
  return {
330
  "object":"list",
331
  "data":[
332
- {"object": "embedding", "index": 0, "embedding": embeddings.tolist()}
333
  ],
334
  "model": model,
335
  "usage":{},
@@ -341,7 +341,7 @@ class ChatAPIApp:
341
  try:
342
  model = request.model
343
  model_kwargs = request.options
344
- embeddings = self.embeddings[model].encode(request.prompt, convert_to_tensor=True)#, **model_kwargs)
345
  return {"embedding": embeddings.tolist()}
346
  except ValueError as e:
347
  raise HTTPException(status_code=400, detail=str(e))
 
325
  model = request.model
326
  model_kwargs = request.options
327
  encoding = tiktoken.get_encoding("cl100k_base")
328
+ embeddings = self.embeddings[model].encode([encoding.decode(inp) for inp in request.input])#, **model_kwargs)
329
  return {
330
  "object":"list",
331
  "data":[
332
+ {"object": "embedding", "index": i, "embedding": emb} for i,emb in enumerate(embeddings.tolist())
333
  ],
334
  "model": model,
335
  "usage":{},
 
341
  try:
342
  model = request.model
343
  model_kwargs = request.options
344
+ embeddings = self.embeddings[model].encode(request.prompt)#, **model_kwargs)
345
  return {"embedding": embeddings.tolist()}
346
  except ValueError as e:
347
  raise HTTPException(status_code=400, detail=str(e))