Skip to content

Commit

Permalink
增加会话id
Browse files Browse the repository at this point in the history
  • Loading branch information
xigua0824 committed Dec 19, 2023
1 parent 0b72bc3 commit 18ee3b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/main/java/com/beauty/aide/adaptor/TongYiAdaptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ public void afterPropertiesSet() {
AccessTokenClient tokenClient = new AccessTokenClient(adminAk, adminSk, agentKey);
String token = tokenClient.getToken();
BaiLianConfig config = new BaiLianConfig().setApiKey(token);
ApplicationClient client = new ApplicationClient(config);
client = new ApplicationClient(config);
this.client = new ApplicationClient(config);
}


Expand All @@ -41,13 +40,14 @@ public void afterPropertiesSet() {
* @param prompt
* @return
*/
public String sendChatRequest(String prompt) {
public String sendChatRequest(String prompt, String uuid) {
CompletionsRequest request = new CompletionsRequest()
.setAppId(appId)
// 上下文会话id
.setSessionId(uuid)
.setPrompt(prompt);
CompletionsResponse response = client.completions(request);
String content = response.getData().getText();
content = content.substring(0, content.lastIndexOf("<sup>"));
return content;
}

Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/beauty/aide/manager/AccountManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,13 @@ public AccountDO vo2Do(AccountVO accountVO) {
* @return
*/
public AccountVO getLoginUser(HttpServletRequest request) {
if (request == null) {
return null;
}
AccountVO accountVO = (AccountVO) request.getSession().getAttribute(UserConstant.USER_LOGIN_STATE);
if (accountVO == null) {
throw new BusinessException(UserErrorCode.USER_NOT_LOGIN.getMessage());
// throw new BusinessException(UserErrorCode.USER_NOT_LOGIN.getMessage());
return null;
}
return accountVO;
}
Expand Down

0 comments on commit 18ee3b9

Please sign in to comment.