server: return empty slice on empty /api/embed
request (#5713)
* server: return empty slice on empty `/api/embed` request * fix tests
This commit is contained in:
parent
8288ec8824
commit
7ac6d462ec
2 changed files with 7 additions and 3 deletions
|
@ -206,7 +206,7 @@ type EmbedRequest struct {
|
||||||
// EmbedResponse is the response from [Client.Embed].
|
// EmbedResponse is the response from [Client.Embed].
|
||||||
type EmbedResponse struct {
|
type EmbedResponse struct {
|
||||||
Model string `json:"model"`
|
Model string `json:"model"`
|
||||||
Embeddings [][]float32 `json:"embeddings,omitempty"`
|
Embeddings [][]float32 `json:"embeddings"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// EmbeddingRequest is the request passed to [Client.Embeddings].
|
// EmbeddingRequest is the request passed to [Client.Embeddings].
|
||||||
|
|
|
@ -306,8 +306,12 @@ func Test_Routes(t *testing.T) {
|
||||||
t.Fatalf("expected model t-bone, got %s", embedResp.Model)
|
t.Fatalf("expected model t-bone, got %s", embedResp.Model)
|
||||||
}
|
}
|
||||||
|
|
||||||
if embedResp.Embeddings != nil {
|
if embedResp.Embeddings == nil {
|
||||||
t.Fatalf("expected embeddings to be nil, got %v", embedResp.Embeddings)
|
t.Fatalf("expected embeddings to not be nil, got %v", embedResp.Embeddings)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(embedResp.Embeddings) != 0 {
|
||||||
|
t.Fatalf("expected embeddings to be empty, got %v", embedResp.Embeddings)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue