GenerateEmbedding 生成文本的向量表示
(eid int64, content string, channel *model.Channel, config *ChunkConfig, ctx *EmbeddingContext)
| 1052 | |
| 1053 | // GenerateEmbedding 生成文本的向量表示 |
| 1054 | func (s *EmbeddingService) GenerateEmbedding(eid int64, content string, channel *model.Channel, config *ChunkConfig, ctx *EmbeddingContext) ([]float64, error) { |
| 1055 | // 验证输入 |
| 1056 | if config == nil { |
| 1057 | return nil, fmt.Errorf("配置不能为空") |
| 1058 | } |
| 1059 | |
| 1060 | if channel == nil { |
| 1061 | return nil, fmt.Errorf("渠道配置不能为空") |
| 1062 | } |
| 1063 | |
| 1064 | return s.callEmbeddingAPI(content, channel, config, ctx) |
| 1065 | } |
| 1066 | |
| 1067 | // truncateContentForEmbedding 截断内容到指定的token长度 |
| 1068 | func (s *EmbeddingService) truncateContentForEmbedding(content string, maxTokens int) string { |
no test coverage detected