service 修改 Redis 存储 KV
This commit is contained in:
@@ -19,7 +19,6 @@ type openAICompatibleEmbedder struct {
|
||||
baseURL string
|
||||
apiKey string
|
||||
model string
|
||||
dimensions int
|
||||
httpClient *http.Client
|
||||
}
|
||||
|
||||
@@ -41,7 +40,6 @@ func NewEmbedder(cnf *config.Config) (Embedder, error) {
|
||||
baseURL: strings.TrimRight(cnf.Embedding.BaseUrl, "/"),
|
||||
apiKey: cnf.Embedding.ApiKey,
|
||||
model: cnf.Embedding.Model,
|
||||
dimensions: cnf.Vector.Pgvector.Dimensions,
|
||||
httpClient: &http.Client{Timeout: time.Duration(cnf.Embedding.Timeout) * time.Second},
|
||||
}, nil
|
||||
default:
|
||||
@@ -108,8 +106,5 @@ func (e *openAICompatibleEmbedder) Embed(ctx context.Context, text string) ([]fl
|
||||
if len(result.Data) == 0 || len(result.Data[0].Embedding) == 0 {
|
||||
return nil, fmt.Errorf("embedding response is empty")
|
||||
}
|
||||
if e.dimensions > 0 && len(result.Data[0].Embedding) != e.dimensions {
|
||||
return nil, fmt.Errorf("embedding dimension mismatch: got=%d want=%d", len(result.Data[0].Embedding), e.dimensions)
|
||||
}
|
||||
return result.Data[0].Embedding, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user