mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-04-03 23:16:12 +00:00
feat: 默认使用openai向量化模型
This commit is contained in:
@@ -39,19 +39,11 @@ public class OpenAiVectorization implements Vectorization {
|
||||
|
||||
@Override
|
||||
public List<List<Double>> batchVectorization(List<String> chunkList, String kid) {
|
||||
List<List<Double>> vectorList = new ArrayList<>();
|
||||
|
||||
List<List<Double>> vectorList;
|
||||
openAiStreamClient = chatConfig.getOpenAiStreamClient();
|
||||
// 获取知识库信息
|
||||
KnowledgeInfoVo knowledgeInfoVo = knowledgeInfoService.queryById(Long.valueOf(kid));
|
||||
|
||||
// 如果使用本地模型
|
||||
try {
|
||||
return localModelsVectorization.batchVectorization(chunkList, kid);
|
||||
} catch (Exception e) {
|
||||
log.error("Local models vectorization failed, falling back to OpenAI embeddings", e);
|
||||
}
|
||||
|
||||
// 如果本地模型失败,则调用 OpenAI 服务进行向量化
|
||||
Embedding embedding = buildEmbedding(chunkList, knowledgeInfoVo);
|
||||
EmbeddingResponse embeddings = openAiStreamClient.embeddings(embedding);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user