allowed base64 encoding

This commit is contained in:
nicole pardal
2025-10-20 17:38:42 -07:00
parent 0334e67ffd
commit 53add2e0f5
2 changed files with 8 additions and 3 deletions

View File

@@ -383,11 +383,15 @@ func ToListCompletion(r api.ListResponse) ListCompletion {
// encodingFormat can be "float", "base64", or empty (defaults to "float")
func ToEmbeddingList(model string, r api.EmbedResponse, encodingFormat string) EmbeddingList {
if r.Embeddings != nil {
if encodingFormat == "" {
encodingFormat = "float"
}
var data []Embedding
for i, e := range r.Embeddings {
var embedding any
if strings.EqualFold(encodingFormat, "base64") {
embedding = floatsToBase64(e)
if encodingFormat == "base64" {
embedding = convertFloatsToBase64(e)
} else {
embedding = e
}