(improvement)(Headless) Initialize meta vectors after initializing the model but before querying. (#964)

This commit is contained in:
lexluo09
2024-04-29 16:34:45 +08:00
committed by GitHub
parent b313494b12
commit 20be3e6601
2 changed files with 35 additions and 1 deletions

View File

@@ -0,0 +1,33 @@
package com.tencent.supersonic.headless.server.listener;
import com.tencent.supersonic.headless.core.chat.parser.JavaLLMProxy;
import com.tencent.supersonic.headless.core.utils.ComponentFactory;
import com.tencent.supersonic.headless.server.schedule.EmbeddingTask;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@Slf4j
@Component
@Order(2)
public class FullMetaEmbeddingListener implements CommandLineRunner {
@Autowired
private EmbeddingTask embeddingTask;
@Override
public void run(String... args) {
initMetaEmbedding();
}
public void initMetaEmbedding() {
try {
if (ComponentFactory.getLLMProxy() instanceof JavaLLMProxy) {
embeddingTask.reloadMetaEmbedding();
}
} catch (Exception e) {
log.error("initMetaEmbedding error", e);
}
}
}

View File

@@ -10,12 +10,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import java.util.List;
@Slf4j
@Component
@Order(0)
public class EmbeddingInitListener implements CommandLineRunner {
public class SqlEmbeddingListener implements CommandLineRunner {
@Autowired
private SqlExamplarLoader sqlExamplarLoader;