-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae26772
commit 0ec2521
Showing
9 changed files
with
80 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ | |
### 接入的模型: | ||
* ChatGPT 3.5 | ||
* 通义千问 | ||
* 文心一言 | ||
* DALL-E 2 | ||
|
||
### 技术 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
adi-common/src/main/java/com/moyz/adi/common/service/QianFanLLMService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.moyz.adi.common.service; | ||
|
||
import com.moyz.adi.common.cosntant.AdiConstant; | ||
import com.moyz.adi.common.interfaces.AbstractLLMService; | ||
import com.moyz.adi.common.vo.QianFanSetting; | ||
import dev.langchain4j.model.chat.ChatLanguageModel; | ||
import dev.langchain4j.model.chat.StreamingChatLanguageModel; | ||
import dev.langchain4j.model.qianfan.QianfanChatModel; | ||
import dev.langchain4j.model.qianfan.QianfanStreamingChatModel; | ||
import lombok.experimental.Accessors; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
/** | ||
* QianFan LLM service | ||
*/ | ||
@Slf4j | ||
@Accessors(chain = true) | ||
public class QianFanLLMService extends AbstractLLMService<QianFanSetting> { | ||
|
||
public QianFanLLMService(String modelName) { | ||
super(modelName, AdiConstant.SysConfigKey.QIANFAN_SETTING, QianFanSetting.class, null); | ||
} | ||
|
||
@Override | ||
public boolean isEnabled() { | ||
return StringUtils.isNoneBlank(setting.getApiKey(), setting.getSecretKey()); | ||
} | ||
|
||
@Override | ||
protected ChatLanguageModel buildChatLLM() { | ||
return QianfanChatModel.builder() | ||
.modelName(modelName) | ||
.temperature(0.7) | ||
.topP(1.0) | ||
.maxRetries(1) | ||
.apiKey(setting.getApiKey()) | ||
.secretKey(setting.getSecretKey()) | ||
.build(); | ||
} | ||
|
||
@Override | ||
protected StreamingChatLanguageModel buildStreamingChatLLM() { | ||
return QianfanStreamingChatModel.builder() | ||
.modelName(modelName) | ||
.temperature(0.7) | ||
.topP(1.0) | ||
.apiKey(setting.getApiKey()) | ||
.secretKey(setting.getSecretKey()) | ||
.build(); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
adi-common/src/main/java/com/moyz/adi/common/vo/QianFanSetting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.moyz.adi.common.vo; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class QianFanSetting { | ||
|
||
@JsonProperty("api_key") | ||
private String apiKey; | ||
|
||
@JsonProperty("secret_key") | ||
private String secretKey; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters