|
@@ -10,7 +10,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
-import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.chatgpt.prop.AiChatProperties;
|
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.jeecg.common.util.SpringContextUtils;
|
|
@@ -49,12 +49,15 @@ public class ChatServiceImpl implements ChatService {
|
|
|
|
|
|
@Autowired private OpenAiStreamClient openAiStreamClient;
|
|
|
|
|
|
+ @Autowired private AiChatProperties aiChatProperties;
|
|
|
+
|
|
|
@Autowired private IChatHistoryService chatHistoryService;
|
|
|
|
|
|
/** 防止client不能成功注入 */
|
|
|
private OpenAiStreamClient ensureClient() {
|
|
|
if (Objects.isNull(this.openAiStreamClient)) {
|
|
|
this.openAiStreamClient = SpringContextUtils.getBean(OpenAiStreamClient.class);
|
|
|
+ this.aiChatProperties = SpringContextUtils.getBean(AiChatProperties.class);
|
|
|
}
|
|
|
return this.openAiStreamClient;
|
|
|
}
|
|
@@ -146,7 +149,7 @@ public class ChatServiceImpl implements ChatService {
|
|
|
ChatCompletion completion =
|
|
|
ChatCompletion.builder()
|
|
|
.messages(topicContext)
|
|
|
- .model(ChatCompletion.Model.GPT_3_5_TURBO.getName())
|
|
|
+ .model(aiChatProperties.getModel())
|
|
|
.build();
|
|
|
ensureClient().streamChatCompletion(completion, openAIEventSourceListener);
|
|
|
|
|
@@ -161,7 +164,7 @@ public class ChatServiceImpl implements ChatService {
|
|
|
// 话题context TTL设置为3小时
|
|
|
3 * 60 * 60);
|
|
|
|
|
|
- Result.ok(completion.tokens());
|
|
|
+ // Result.ok(completion.tokens());
|
|
|
}
|
|
|
|
|
|
@Override
|