30 lines
705 B
Go
30 lines
705 B
Go
package vector_data
|
|
|
|
import (
|
|
"ai-chat-service/pkg/config"
|
|
"context"
|
|
"fmt"
|
|
)
|
|
|
|
const CHAT_RECORDS = "chat_records"
|
|
|
|
type ChatRecord struct {
|
|
ID string
|
|
KVs map[string]string
|
|
}
|
|
type IChatRecordsData interface {
|
|
UpsertData(ctx context.Context, list []*ChatRecord) error
|
|
QueryData(ctx context.Context, text map[string][]string) (id string, score float32, err error)
|
|
}
|
|
|
|
func NewChatRecordsData(config *config.Config) (IChatRecordsData, error) {
|
|
switch config.Vector.Provider {
|
|
case "tencent", "":
|
|
return newTencentChatRecordsData(config)
|
|
case "pgvector":
|
|
return newPgvectorChatRecordsData(config)
|
|
default:
|
|
return nil, fmt.Errorf("unsupported vector provider: %s", config.Vector.Provider)
|
|
}
|
|
}
|