use float32

This commit is contained in:
Roy Han
2024-07-02 10:30:29 -07:00
parent 512e0a7bde
commit 00a4cb26ca
6 changed files with 27 additions and 27 deletions

View File

@@ -414,12 +414,12 @@ func (s *Server) EmbedHandler(c *gin.Context) {
return s, nil
}
embeddings := [][]float64{}
embeddings := [][]float32{}
switch reqEmbed := req.Input.(type) {
case string:
if reqEmbed == "" {
c.JSON(http.StatusOK, api.EmbedResponse{Embeddings: [][]float64{}})
c.JSON(http.StatusOK, api.EmbedResponse{Embeddings: [][]float32{}})
return
}
reqEmbed, err = checkFit(reqEmbed, *req.Truncate)
@@ -430,7 +430,7 @@ func (s *Server) EmbedHandler(c *gin.Context) {
embeddings, err = runner.llama.Embed(c.Request.Context(), []string{reqEmbed})
case []any:
if reqEmbed == nil {
c.JSON(http.StatusOK, api.EmbedResponse{Embeddings: [][]float64{}})
c.JSON(http.StatusOK, api.EmbedResponse{Embeddings: [][]float32{}})
return
}

View File

@@ -610,7 +610,7 @@ type mockLlm struct {
completionResp error
embeddingResp []float64
embeddingRespErr error
embedResp [][]float64
embedResp [][]float32
embedRespErr error
tokenizeResp []int
tokenizeRespErr error
@@ -631,7 +631,7 @@ func (s *mockLlm) Completion(ctx context.Context, req llm.CompletionRequest, fn
func (s *mockLlm) Embedding(ctx context.Context, prompt string) ([]float64, error) {
return s.embeddingResp, s.embeddingRespErr
}
func (s *mockLlm) Embed(ctx context.Context, input []string) ([][]float64, error) {
func (s *mockLlm) Embed(ctx context.Context, input []string) ([][]float32, error) {
return s.embedResp, s.embedRespErr
}
func (s *mockLlm) Tokenize(ctx context.Context, content string) ([]int, error) {