mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-03-30 04:53:49 +08:00
init v1.0.0
This commit is contained in:
@@ -94,7 +94,7 @@ public class CaptchaController {
|
||||
String code = RandomUtil.randomNumbers(4);
|
||||
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
||||
try {
|
||||
MailUtils.sendText(emailRequest.getUsername(), "【GPT助手】登录验证码", "您本次验证码为:" + code + ",有效性为" + Constants.CAPTCHA_EXPIRATION + "分钟,请尽快填写。");
|
||||
MailUtils.sendText(emailRequest.getUsername(), "【熊猫助手】登录验证码", "您本次验证码为:" + code + ",有效性为" + Constants.CAPTCHA_EXPIRATION + "分钟,请尽快填写。");
|
||||
} catch (Exception e) {
|
||||
log.error("验证码短信发送异常 => {}", e.getMessage());
|
||||
return R.fail(e.getMessage());
|
||||
|
||||
@@ -3,7 +3,10 @@ package com.xmzs.controller;
|
||||
|
||||
import com.xmzs.common.chat.domain.request.ChatRequest;
|
||||
import com.xmzs.common.chat.domain.request.Dall3Request;
|
||||
import com.xmzs.common.chat.domain.request.MjTaskRequest;
|
||||
import com.xmzs.common.chat.entity.Tts.TextToSpeech;
|
||||
import com.xmzs.common.chat.entity.images.Item;
|
||||
import com.xmzs.common.chat.entity.whisper.WhisperResponse;
|
||||
import com.xmzs.common.core.domain.R;
|
||||
import com.xmzs.common.core.domain.model.LoginUser;
|
||||
import com.xmzs.common.core.exception.base.BaseException;
|
||||
@@ -13,19 +16,30 @@ import com.xmzs.common.satoken.utils.LoginHelper;
|
||||
import com.xmzs.system.domain.bo.ChatMessageBo;
|
||||
import com.xmzs.system.domain.vo.ChatMessageVo;
|
||||
import com.xmzs.system.service.IChatMessageService;
|
||||
import com.xmzs.system.service.SseService;
|
||||
import com.xmzs.system.service.ISseService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
@@ -37,38 +51,58 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
public class ChatController {
|
||||
|
||||
private final SseService sseService;
|
||||
private final ISseService ISseService;
|
||||
|
||||
private final IChatMessageService chatMessageService;
|
||||
private final IChatMessageService chatMessageService;
|
||||
|
||||
/**
|
||||
* 聊天接口
|
||||
*/
|
||||
@PostMapping("/chat")
|
||||
@ResponseBody
|
||||
public SseEmitter sseChat(@RequestBody @Valid ChatRequest chatRequest) {
|
||||
if("gpt-4-all".equals(chatRequest.getModel())
|
||||
|| chatRequest.getModel().startsWith("gpt-4-gizmo")
|
||||
|| chatRequest.getModel().startsWith("net-")
|
||||
){
|
||||
return sseService.transitChat(chatRequest);
|
||||
}
|
||||
if("azure-gpt-3.5".equals(chatRequest.getModel())){
|
||||
return sseService.azureChat(chatRequest);
|
||||
}
|
||||
return sseService.sseChat(chatRequest);
|
||||
public SseEmitter sseChat(@RequestBody @Valid ChatRequest chatRequest, HttpServletResponse response) {
|
||||
return ISseService.sseChat(chatRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* 语音转文本
|
||||
*
|
||||
* @param file
|
||||
*/
|
||||
@PostMapping("/audio")
|
||||
@ResponseBody
|
||||
public WhisperResponse audio(@RequestParam("file") MultipartFile file) {
|
||||
WhisperResponse whisperResponse = ISseService.speechToTextTranscriptionsV2(file);
|
||||
return whisperResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文本转语音
|
||||
*
|
||||
* @param textToSpeech
|
||||
*/
|
||||
@PostMapping("/speech")
|
||||
@ResponseBody
|
||||
public ResponseEntity<Resource> speech(@RequestBody TextToSpeech textToSpeech) {
|
||||
return ISseService.textToSpeed(textToSpeech);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/dall3")
|
||||
@ResponseBody
|
||||
public R<List<Item>> dall3(@RequestBody @Valid Dall3Request request) {
|
||||
return R.ok(sseService.dall3(request));
|
||||
return R.ok(ISseService.dall3(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* 扣除mj绘图费用
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/mjTask")
|
||||
@ResponseBody
|
||||
public R<String> mjTask() {
|
||||
sseService.mjTask();
|
||||
public R<String> mjTask(@RequestBody MjTaskRequest mjTaskRequest) {
|
||||
ISseService.mjTask(mjTaskRequest);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -77,7 +111,7 @@ public class ChatController {
|
||||
*/
|
||||
@PostMapping("/chatList")
|
||||
@ResponseBody
|
||||
public R<TableDataInfo<ChatMessageVo>> list(@RequestBody @Valid ChatMessageBo chatRequest,@RequestBody PageQuery pageQuery) {
|
||||
public R<TableDataInfo<ChatMessageVo>> list(@RequestBody @Valid ChatMessageBo chatRequest, @RequestBody PageQuery pageQuery) {
|
||||
// 默认查询当前登录用户消息记录
|
||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||
if (loginUser == null) {
|
||||
|
||||
@@ -73,7 +73,6 @@ public class PayController {
|
||||
return R.ok(paymentOrdersVo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 跳转通知地址
|
||||
*
|
||||
@@ -138,6 +137,9 @@ public class PayController {
|
||||
BeanUtil.copyProperties(paymentOrdersVo,paymentOrdersBo);
|
||||
paymentOrdersService.updateByBo(paymentOrdersBo);
|
||||
SysUserVo sysUserVo = userService.selectUserById(paymentOrdersVo.getUserId());
|
||||
if(money>9.9){
|
||||
money = money*2;
|
||||
}
|
||||
sysUserVo.setUserBalance(sysUserVo.getUserBalance()+money);
|
||||
SysUserBo sysUserBo = new SysUserBo();
|
||||
BeanUtil.copyProperties(sysUserVo,sysUserBo);
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.xmzs.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.xmzs.common.wechat.Wechat;
|
||||
import com.xmzs.system.cofing.KeywordConfig;
|
||||
import com.xmzs.system.cofing.QqConfig;
|
||||
import com.xmzs.system.cofing.WechatConfig;
|
||||
import com.xmzs.system.handler.WechatMessageHandler;
|
||||
import com.xmzs.system.service.ISseService;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 个人微信扩展控制器
|
||||
*
|
||||
* @author WangLe
|
||||
*/
|
||||
@SaIgnore
|
||||
@Slf4j
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
public class WeChatController {
|
||||
|
||||
@Getter
|
||||
private Wechat wechatBot;
|
||||
|
||||
private final WechatConfig wechatConfig;
|
||||
|
||||
private final ISseService sseService;
|
||||
|
||||
private final KeywordConfig keywordConfig;
|
||||
|
||||
/**
|
||||
* 获取微信登录二维码
|
||||
*
|
||||
*/
|
||||
@PostMapping("/getQr")
|
||||
public void getQr() {
|
||||
//微信
|
||||
if (wechatConfig.getEnable()){
|
||||
log.info("正在登录微信,请按提示操作:");
|
||||
wechatBot = new Wechat(new WechatMessageHandler(sseService, keywordConfig), wechatConfig.getQrPath());
|
||||
wechatBot.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ spring:
|
||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
||||
url: jdbc:mysql://127.0.0.1:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||
username: ry-vue
|
||||
password: ry-vue
|
||||
password: xxx
|
||||
|
||||
# 从库数据源
|
||||
# slave:
|
||||
|
||||
@@ -220,11 +220,11 @@ mail:
|
||||
# 是否需要用户名密码验证
|
||||
auth: true
|
||||
# 发送方,遵循RFC-822标准
|
||||
from: xxx@163.com
|
||||
from: ageerle@163.com
|
||||
# 用户名(注意:如果使用foxmail邮箱,此处user为qq号)
|
||||
user: xxx@163.com
|
||||
user: ageerle@163.com
|
||||
# 密码(填写授权码)
|
||||
pass: pass
|
||||
pass: TOGXBVPYFVPFRQMQ
|
||||
# 使用 STARTTLS安全连接,STARTTLS是对纯文本通信协议的扩展。
|
||||
starttlsEnable: true
|
||||
# 使用SSL安全连接
|
||||
@@ -318,14 +318,10 @@ websocket:
|
||||
path: ''
|
||||
# 设置访问源地址
|
||||
allowedOrigins: '*'
|
||||
# AI助手配置信息
|
||||
# chatgpt配置信息
|
||||
chat:
|
||||
apiKey: ''
|
||||
apiHost: ''
|
||||
# 中转接口
|
||||
transit:
|
||||
apiKey: ''
|
||||
apiHost: 'https://api.gptgod.online/'
|
||||
apiKey: 'sk-uMCP3lTg1dQ9L7Xs2bF352Fa216a4c9280577b205dE67e12'
|
||||
apiHost: 'https://api.pandarobot.chat/'
|
||||
# 微信小程序配置信息
|
||||
wx:
|
||||
miniapp:
|
||||
@@ -343,3 +339,37 @@ baidu:
|
||||
apiKey: '' # apiKey
|
||||
secretKey: '' # secretKey
|
||||
|
||||
wechat:
|
||||
# 是否使用微信 true/false
|
||||
enable: true
|
||||
# 生成的登录二维码路径 默认与项目同级
|
||||
qrPath: "./"
|
||||
|
||||
keyword:
|
||||
# 重置会话指令
|
||||
reset: "重置会话"
|
||||
# ai画图指令(DALL·E模型 https://platform.openai.com/docs/models/dall-e)
|
||||
# generation 根据关键词生成图片(https://platform.openai.com/docs/guides/images/generations)
|
||||
image: "ai画图"
|
||||
# ai语音指令(TTS模型 https://platform.openai.com/docs/api-reference/audio)
|
||||
audio: "ai语音"
|
||||
mj:
|
||||
api-secret:
|
||||
task-store:
|
||||
type: in_memory
|
||||
timeout: 30d
|
||||
translate-way: gpt
|
||||
# proxy:
|
||||
# host: 127.0.0.1
|
||||
# port: 10809
|
||||
ng-discord:
|
||||
server: https://discord.pandarobot.chat/
|
||||
cdn: https://app.pandarobot.chat/
|
||||
wss: https://gateway.pandarobot.chat/
|
||||
openai:
|
||||
gpt-api-url: 'https://api.pandarobot.chat/'
|
||||
gpt-api-key: 'sk-xxx'
|
||||
accounts:
|
||||
- guild-id: 'xxxxx'
|
||||
channel-id: 'xxxxx'
|
||||
user-token: 'xx.xx'
|
||||
|
||||
Reference in New Issue
Block a user