|
...
|
...
|
@@ -7,40 +7,34 @@ import com.ruoyi.common.core.controller.BaseController; |
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
import com.ruoyi.common.core.domain.Message;
|
|
|
|
import com.ruoyi.common.core.domain.MessageCode;
|
|
|
|
import com.ruoyi.common.core.redis.RedisCache;
|
|
|
|
import com.ruoyi.common.utils.Arith;
|
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
|
import com.ruoyi.common.utils.bean.BeanUtils;
|
|
|
|
import com.ruoyi.common.utils.html.HttpUtils;
|
|
|
|
import com.ruoyi.common.utils.http.OkHttpUtils;
|
|
|
|
import com.ruoyi.system.login.dto.OpenAiLoginUser;
|
|
|
|
import com.ruoyi.system.login.dto.OpenAiUserInfo;
|
|
|
|
import com.ruoyi.system.login.service.TokenService;
|
|
|
|
import com.ruoyi.system.service.PublicService;
|
|
|
|
import com.theokanning.openai.Usage;
|
|
|
|
import com.theokanning.openai.completion.CompletionChoice;
|
|
|
|
import com.theokanning.openai.completion.CompletionResult;
|
|
|
|
import com.zhonglai.luhui.openai.dto.*;
|
|
|
|
import com.zhonglai.luhui.openai.service.VipServiceImpl;
|
|
|
|
import com.zhonglai.luhui.openai.utils.OpenAiUtils;
|
|
|
|
import com.zhonglai.luhui.openai.utils.SysConfigKeyType;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import org.apache.catalina.Session;
|
|
|
|
import org.apache.commons.io.input.ReaderInputStream;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Api(tags = "chatGPT接口")
|
|
|
|
@RestController
|
|
...
|
...
|
@@ -54,6 +48,9 @@ public class ChatGPTController extends BaseController { |
|
|
|
|
|
|
|
private static String sessionkey = "CHAT_HISTORY_CONTEXT";//上下文关联存放地址
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private TokenService tokenService;
|
|
|
|
|
|
|
|
@ApiOperation("与AI机器进行聊天(废弃)")
|
|
|
|
@RequestMapping(value = "/aiChatbot",method = RequestMethod.POST)
|
|
|
|
public AjaxResult aiChatbot(HttpServletRequest httpServletRequest, @RequestBody String data)
|
|
...
|
...
|
@@ -250,7 +247,9 @@ public class ChatGPTController extends BaseController { |
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
jsonObject.put("model","gpt-3.5-turbo-0301");
|
|
|
|
jsonObject.put("messages",messageList);
|
|
|
|
String str = HttpUtil.post("https://chatgpt.njlaikun.com/v1/chat/completions",jsonObject.toString());
|
|
|
|
String str = HttpUtil.post("http://23.224.171.145:8086/chatGPTApi/sendNotFreeMessage",jsonObject.toString());
|
|
|
|
// String str = HttpUtil.post("https://free.chatgpt.njlaikun.com/v1/chat/completions",jsonObject.toString());
|
|
|
|
|
|
|
|
logger.info("返回的数据:{}",str);
|
|
|
|
CompletionResult3_5 completionResult = JSONObject.parseObject(str, CompletionResult3_5.class);
|
|
|
|
return completionResult;
|
|
...
|
...
|
@@ -267,7 +266,9 @@ public class ChatGPTController extends BaseController { |
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
jsonObject.put("model","gpt-3.5-turbo-0301");
|
|
|
|
jsonObject.put("messages",messageList);
|
|
|
|
String str = HttpUtil.post("https://free.chatgpt.njlaikun.com/v1/chat/completions",jsonObject.toString());
|
|
|
|
String str = HttpUtil.post("https://23.224.171.145:8086/chatGPTApi/sendFreeMessage",jsonObject.toString());
|
|
|
|
// String str = HttpUtil.post("https://free.chatgpt.njlaikun.com/v1/chat/completions",jsonObject.toString());
|
|
|
|
|
|
|
|
logger.info("返回的数据:{}",str);
|
|
|
|
CompletionResult3_5 completionResult = JSONObject.parseObject(str, CompletionResult3_5.class);
|
|
|
|
return completionResult;
|
...
|
...
|
|