From fabee6255b2de5e28e7e2fae4a099951904422e1 Mon Sep 17 00:00:00 2001 From: "devin.yf" Date: Tue, 28 May 2024 10:18:05 +0800 Subject: [PATCH] use float64 for embedding --- embedding/dtypes.go | 2 +- tongyiclient.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/embedding/dtypes.go b/embedding/dtypes.go index 4fbe0d6..858874b 100644 --- a/embedding/dtypes.go +++ b/embedding/dtypes.go @@ -24,7 +24,7 @@ type Response struct { type Embedding struct { TextIndex int `json:"text_index"` - Embedding []float32 `json:"embedding"` + Embedding []float64 `json:"embedding"` } type Output struct { diff --git a/tongyiclient.go b/tongyiclient.go index ee86839..bbeef91 100644 --- a/tongyiclient.go +++ b/tongyiclient.go @@ -224,7 +224,7 @@ func (q *TongyiClient) CreateSpeechToTextGeneration(ctx context.Context, request return nil } -func (q *TongyiClient) CreateEmbedding(ctx context.Context, r *embedding.Request) ([][]float32, int, error) { +func (q *TongyiClient) CreateEmbedding(ctx context.Context, r *embedding.Request) ([][]float64, int, error) { resp, err := embedding.CreateEmbedding(ctx, r, q.httpCli, q.token) if err != nil { return nil, 0, err @@ -235,7 +235,7 @@ func (q *TongyiClient) CreateEmbedding(ctx context.Context, r *embedding.Request return nil, 0, ErrEmptyResponse } - embeddings := make([][]float32, 0) + embeddings := make([][]float64, 0) for i := 0; i < len(resp.Output.Embeddings); i++ { embeddings = append(embeddings, resp.Output.Embeddings[i].Embedding) }