mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2025-09-10 17:14:36 +00:00
embeddings handle base64
This commit is contained in:
parent
7de88802f9
commit
82d7c53b85
1 changed files with 6 additions and 1 deletions
|
@ -3770,7 +3770,12 @@ Change Mode<br>
|
|||
outdatas = []
|
||||
odidx = 0
|
||||
for od in gen["data"]:
|
||||
outdatas.append({"object":"embedding","index":odidx,"embedding":od})
|
||||
if genparams.get("encoding_format", "")=="base64":
|
||||
binary_data = struct.pack('<' + 'f' * len(od), *od)
|
||||
b64_string = base64.b64encode(binary_data).decode('utf-8')
|
||||
outdatas.append({"object":"embedding","index":odidx,"embedding":b64_string})
|
||||
else:
|
||||
outdatas.append({"object":"embedding","index":odidx,"embedding":od})
|
||||
odidx += 1
|
||||
genresp = (json.dumps({"object":"list","data":outdatas,"model":friendlyembeddingsmodelname,"usage":{"prompt_tokens":gen["count"],"total_tokens":gen["count"]}}).encode())
|
||||
self.send_response(200)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue