(fix)(chat&headless)Agent references ChatModelConfig instead of ModelConfig.

This commit is contained in:
jerryjzhang
2024-07-12 11:58:38 +08:00
parent 37da1ac2ae
commit 5bf4a4160d
12 changed files with 37 additions and 36 deletions

View File

@@ -19,19 +19,18 @@ public class ModelProvider {
factories.put(provider, modelFactory);
}
public static ChatLanguageModel getChatModel(ModelConfig modelConfig) {
if (modelConfig == null || modelConfig.getChatModel() == null
|| StringUtils.isBlank(modelConfig.getChatModel().getProvider())
|| StringUtils.isBlank(modelConfig.getChatModel().getBaseUrl())) {
public static ChatLanguageModel getChatModel(ChatModelConfig modelConfig) {
if (modelConfig == null
|| StringUtils.isBlank(modelConfig.getProvider())
|| StringUtils.isBlank(modelConfig.getBaseUrl())) {
return ContextUtils.getBean(ChatLanguageModel.class);
}
ChatModelConfig chatModel = modelConfig.getChatModel();
ModelFactory modelFactory = factories.get(chatModel.getProvider().toUpperCase());
ModelFactory modelFactory = factories.get(modelConfig.getProvider().toUpperCase());
if (modelFactory != null) {
return modelFactory.createChatModel(chatModel);
return modelFactory.createChatModel(modelConfig);
}
throw new RuntimeException("Unsupported ChatLanguageModel provider: " + chatModel.getProvider());
throw new RuntimeException("Unsupported ChatLanguageModel provider: " + modelConfig.getProvider());
}
public static EmbeddingModel getEmbeddingModel(ModelConfig modelConfig) {