mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-04-14 12:23:39 +00:00
v1.0.3
This commit is contained in:
@@ -12,22 +12,27 @@ public class OpenAIConst {
|
||||
|
||||
public final static int SUCCEED_CODE = 200;
|
||||
|
||||
/** GPT3扣除费用 */
|
||||
public final static double GPT3_COST = 0.05;
|
||||
|
||||
public final static double GPT4_COST = 0.3;
|
||||
/** GPT4扣除费用 */
|
||||
public final static double GPT4_COST = 0.2;
|
||||
|
||||
public final static double GPT4_ALL_COST = 0.3;
|
||||
/** DALL普通绘图扣除费用 */
|
||||
public final static double DALL3_COST = 0.3;
|
||||
|
||||
/** 绘图费用 */
|
||||
public final static double DALL3_COST = 0.4;
|
||||
/** DALL高清绘图扣除费用 */
|
||||
public final static double DALL3_HD_COST = 0.5;
|
||||
|
||||
/** 绘图费用-高清 */
|
||||
public final static double DALL3_HD_COST = 0.8;
|
||||
/** MJ操作类型1(变化、变焦、文生图、图生图、局部重绘、混图)扣除费用 */
|
||||
public final static double MJ_COST_TYPE1 = 0.3;
|
||||
|
||||
/** mdjourney绘图费用 */
|
||||
public final static double MJ_COST = 0.3;
|
||||
/** MJ操作类型2(换脸、放大、图生文、prompt分析)扣除费用 */
|
||||
public final static double MJ_COST_TYPE2 = 0.1;
|
||||
|
||||
/** MJ操作类型3(查询任务进度、获取seed)扣除费用 */
|
||||
public final static double MJ_COST_TYPE3 = 0.0;
|
||||
|
||||
/** 默认账户余额 */
|
||||
public final static double USER_BALANCE = 5;
|
||||
|
||||
}
|
||||
|
||||
@@ -22,16 +22,16 @@ public class ChatRequest {
|
||||
@NotEmpty(message = "对话消息不能为空")
|
||||
List<Message> messages;
|
||||
|
||||
List<Content> content;
|
||||
List<Content> imageContent;
|
||||
|
||||
private String prompt;
|
||||
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 需要识别的图片地址
|
||||
* 知识库id
|
||||
*/
|
||||
private String imgurl;
|
||||
private String kid;
|
||||
|
||||
/**
|
||||
* gpt的默认设置
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.xmzs.common.chat.domain.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author WangLe
|
||||
*/
|
||||
@Data
|
||||
public class RoleRequest {
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 角色描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 音频地址
|
||||
*/
|
||||
private String prompt;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
|
||||
private String preProcess;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.xmzs.common.chat.domain.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author WangLe
|
||||
*/
|
||||
@Data
|
||||
public class SimpleGenerateRequest {
|
||||
|
||||
/**
|
||||
* 要使用的模型ID (目前统一为reecho-neural-voice-001)
|
||||
*/
|
||||
private String model = "reecho-neural-voice-001";
|
||||
|
||||
/**
|
||||
* 多样性 (0-100,默认为97)
|
||||
*/
|
||||
private Integer randomness;
|
||||
|
||||
/**
|
||||
* 稳定性过滤 (0-100,默认为0)
|
||||
*/
|
||||
private Integer stability_boost;
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
private String voiceId;
|
||||
|
||||
/**
|
||||
* 要生成的文本内容
|
||||
*/
|
||||
private String text;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.xmzs.common.chat.domain.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author WangLe
|
||||
*/
|
||||
@Data
|
||||
public class MetadataResponse {
|
||||
private String promptMP3StorageUrl;
|
||||
private String promptOriginAudioStorageUrl;
|
||||
private String description;
|
||||
private boolean preProcess;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xmzs.common.chat.domain.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author WangLe
|
||||
*/
|
||||
@Data
|
||||
public class RoleDataResponse {
|
||||
private String id;
|
||||
private String name;
|
||||
private String status;
|
||||
private String from;
|
||||
private String originId;
|
||||
private MetadataResponse metadata;
|
||||
private String createdAt;
|
||||
private String updatedAt;
|
||||
private String deletedAt;
|
||||
private String userId;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.xmzs.common.chat.domain.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author WangLe
|
||||
*/
|
||||
@Data
|
||||
public class RoleResponse {
|
||||
private String status;
|
||||
private String message;
|
||||
private RoleDataResponse data;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.xmzs.common.chat.domain.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author WangLe
|
||||
*/
|
||||
@Data
|
||||
public class SimpleGenerateDataResponse {
|
||||
|
||||
/**
|
||||
* 本次生成的ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 本次生成结果的音频文件地址
|
||||
*/
|
||||
private String audio;
|
||||
|
||||
/**
|
||||
* 本次生成所消耗的点数
|
||||
*/
|
||||
private Integer credit_used;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.xmzs.common.chat.domain.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author WangLe
|
||||
*/
|
||||
@Data
|
||||
public class SimpleGenerateResponse {
|
||||
|
||||
/**
|
||||
* 状态码,失败时则为500
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 状态消息
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 生成详情
|
||||
*/
|
||||
private SimpleGenerateDataResponse data;
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.xmzs.common.chat.entity.chat;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import com.xmzs.common.chat.constant.OpenAIConst;
|
||||
import com.xmzs.common.chat.entity.chat.tool.Tools;
|
||||
import lombok.*;
|
||||
@@ -217,6 +216,23 @@ public class BaseChatCompletion implements Serializable {
|
||||
* gpt-4-0613,支持函数
|
||||
*/
|
||||
GPT_4_0125_PREVIEW("gpt-4-0125-preview"),
|
||||
|
||||
/**
|
||||
* GPT_4_ALL
|
||||
*/
|
||||
GPT_4_ALL("gpt-4-all"),
|
||||
|
||||
GPT_4_GIZMO("gpt-4-gizmo"),
|
||||
|
||||
NET("net"),
|
||||
|
||||
CLAUDE_3_SONNET("claude-3-sonnet-20240229"),
|
||||
|
||||
GEMINI_PRO("gemini-pro"),
|
||||
|
||||
STABLE_DIFFUSION("stable-diffusion"),
|
||||
|
||||
SUNO_V3("suno-v3"),
|
||||
;
|
||||
private final String name;
|
||||
}
|
||||
@@ -238,9 +254,10 @@ public class BaseChatCompletion implements Serializable {
|
||||
}
|
||||
|
||||
public static double getModelCost(String modelName) {
|
||||
return switch (modelName) {
|
||||
case "gpt-3.5-turbo-0613" -> OpenAIConst.GPT3_COST;
|
||||
default -> OpenAIConst.GPT4_COST;
|
||||
};
|
||||
if(modelName.startsWith("gpt-3.5")){
|
||||
return OpenAIConst.GPT3_COST;
|
||||
}else {
|
||||
return OpenAIConst.GPT4_COST;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,20 @@ import java.io.Serializable;
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class File implements Serializable {
|
||||
|
||||
private String id;
|
||||
private String object;
|
||||
// private String id;
|
||||
// private String object;
|
||||
// private long bytes;
|
||||
// private long created_at;
|
||||
// private String filename;
|
||||
// private String purpose;
|
||||
// private String status;
|
||||
// @JsonProperty("status_details")
|
||||
// private String statusDetails;
|
||||
|
||||
private long bytes;
|
||||
private long created_at;
|
||||
private String filename;
|
||||
private String purpose;
|
||||
private String status;
|
||||
@JsonProperty("status_details")
|
||||
private String statusDetails;
|
||||
private String id;
|
||||
private String object;
|
||||
private String url;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.xmzs.common.chat.entity.billing.Subscription;
|
||||
import com.xmzs.common.chat.entity.chat.BaseChatCompletion;
|
||||
import com.xmzs.common.chat.entity.chat.ChatCompletionResponse;
|
||||
import com.xmzs.common.chat.entity.chat.ChatCompletionWithPicture;
|
||||
import com.xmzs.common.chat.entity.files.UploadFileResponse;
|
||||
import com.xmzs.common.chat.entity.images.Image;
|
||||
import com.xmzs.common.chat.entity.images.ImageResponse;
|
||||
import com.xmzs.common.chat.entity.models.Model;
|
||||
@@ -231,6 +232,23 @@ public class OpenAiStreamClient {
|
||||
return chatCompletionResponse.blockingGet();
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @param purpose purpose
|
||||
* @param file 文件对象
|
||||
* @return UploadFileResponse
|
||||
*/
|
||||
public UploadFileResponse uploadFile(String purpose, java.io.File file) {
|
||||
// 创建 RequestBody,用于封装构建RequestBody
|
||||
RequestBody fileBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
|
||||
MultipartBody.Part multipartBody = MultipartBody.Part.createFormData("file", file.getName(), fileBody);
|
||||
|
||||
RequestBody purposeBody = RequestBody.create(MediaType.parse("multipart/form-data"), purpose);
|
||||
Single<UploadFileResponse> uploadFileResponse = this.openAiApi.uploadFile(multipartBody, purposeBody);
|
||||
return uploadFileResponse.blockingGet();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取openKey账户信息(近90天)
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user