embedding type 64

This commit is contained in:
Roy Han 2024-07-09 13:41:48 -07:00
parent bcb63e6e0e
commit fb390b8902
2 changed files with 9 additions and 3 deletions

View File

@ -215,7 +215,7 @@ type EmbeddingRequest struct {
// EmbeddingResponse is the response from [Client.Embeddings].
type EmbeddingResponse struct {
Embedding []float32 `json:"embedding"`
Embedding []float64 `json:"embedding"`
}
// CreateRequest is the request passed to [Client.Create].

View File

@ -504,7 +504,7 @@ func (s *Server) EmbeddingsHandler(c *gin.Context) {
// an empty request loads the model
if req.Prompt == "" {
c.JSON(http.StatusOK, api.EmbeddingResponse{Embedding: []float32{}})
c.JSON(http.StatusOK, api.EmbeddingResponse{Embedding: []float64{}})
return
}
@ -515,8 +515,14 @@ func (s *Server) EmbeddingsHandler(c *gin.Context) {
return
}
embedding64 := make([]float64, len(embedding[0]))
for i, v := range embedding[0] {
embedding64[i] = float64(v)
}
resp := api.EmbeddingResponse{
Embedding: embedding[0],
Embedding: embedding64,
}
c.JSON(http.StatusOK, resp)
}