simplfied logic and added tests

This commit is contained in:
nicole pardal
2025-10-21 13:57:01 -07:00
parent 53add2e0f5
commit c563286e63
2 changed files with 3 additions and 8 deletions

View File

@@ -383,15 +383,11 @@ 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 encodingFormat == "base64" {
embedding = convertFloatsToBase64(e)
if strings.EqualFold(encodingFormat, "base64") {
embedding = floatsToBase64(e)
} else {
embedding = e
}