|
@@ -23,6 +23,7 @@ import cn.tycoding.langchat.biz.entity.AigcModel;
|
|
import cn.tycoding.langchat.biz.service.AigcModelService;
|
|
import cn.tycoding.langchat.biz.service.AigcModelService;
|
|
import cn.tycoding.langchat.common.component.SpringContextHolder;
|
|
import cn.tycoding.langchat.common.component.SpringContextHolder;
|
|
import cn.tycoding.langchat.core.consts.EmbedConst;
|
|
import cn.tycoding.langchat.core.consts.EmbedConst;
|
|
|
|
+import dev.langchain4j.model.anthropic.AnthropicStreamingChatModel;
|
|
import dev.langchain4j.model.azure.AzureOpenAiEmbeddingModel;
|
|
import dev.langchain4j.model.azure.AzureOpenAiEmbeddingModel;
|
|
import dev.langchain4j.model.azure.AzureOpenAiImageModel;
|
|
import dev.langchain4j.model.azure.AzureOpenAiImageModel;
|
|
import dev.langchain4j.model.azure.AzureOpenAiStreamingChatModel;
|
|
import dev.langchain4j.model.azure.AzureOpenAiStreamingChatModel;
|
|
@@ -81,13 +82,13 @@ public class ProviderInitialize implements ApplicationContextAware {
|
|
// Uninstall previously registered beans before registering them
|
|
// Uninstall previously registered beans before registering them
|
|
contextHolder.unregisterBean(model.getId());
|
|
contextHolder.unregisterBean(model.getId());
|
|
|
|
|
|
- llmHandler(model);
|
|
|
|
|
|
+ chatHandler(model);
|
|
embeddingHandler(model);
|
|
embeddingHandler(model);
|
|
imageHandler(model);
|
|
imageHandler(model);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- private void llmHandler(AigcModel model) {
|
|
|
|
|
|
+ private void chatHandler(AigcModel model) {
|
|
String type = model.getType();
|
|
String type = model.getType();
|
|
String provider = model.getProvider();
|
|
String provider = model.getProvider();
|
|
|
|
|
|
@@ -154,6 +155,18 @@ public class ProviderInitialize implements ApplicationContextAware {
|
|
.build();
|
|
.build();
|
|
contextHolder.registerBean(model.getId(), build);
|
|
contextHolder.registerBean(model.getId(), build);
|
|
}
|
|
}
|
|
|
|
+ if (ProviderEnum.CLAUDE.name().equals(provider)) {
|
|
|
|
+ AnthropicStreamingChatModel build = AnthropicStreamingChatModel
|
|
|
|
+ .builder()
|
|
|
|
+ .baseUrl(model.getBaseUrl())
|
|
|
|
+ .modelName(model.getModel())
|
|
|
|
+ .temperature(model.getTemperature())
|
|
|
|
+ .topP(model.getTopP())
|
|
|
|
+ .logRequests(true)
|
|
|
|
+ .logResponses(true)
|
|
|
|
+ .build();
|
|
|
|
+ contextHolder.registerBean(model.getId(), build);
|
|
|
|
+ }
|
|
if (ProviderEnum.Q_FAN.name().equals(provider)) {
|
|
if (ProviderEnum.Q_FAN.name().equals(provider)) {
|
|
QianfanStreamingChatModel build = QianfanStreamingChatModel
|
|
QianfanStreamingChatModel build = QianfanStreamingChatModel
|
|
.builder()
|
|
.builder()
|