This commit is contained in:
vastxie
2025-03-04 17:36:53 +08:00
parent cf7dc1d1e7
commit 1e9b9f7ba4
649 changed files with 23183 additions and 1925 deletions

View File

@@ -0,0 +1,123 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChatController = void 0;
const swagger_1 = require("@nestjs/swagger");
const jwtAuth_guard_1 = require("../../common/auth/jwtAuth.guard");
const chat_service_1 = require("./chat.service");
const common_1 = require("@nestjs/common");
const chatProcess_dto_1 = require("./dto/chatProcess.dto");
const aiPPT_1 = require("../ai/aiPPT");
const globalConfig_service_1 = require("../globalConfig/globalConfig.service");
let ChatController = class ChatController {
constructor(chatService, globalConfigService, aiPptService) {
this.chatService = chatService;
this.globalConfigService = globalConfigService;
this.aiPptService = aiPptService;
}
chatProcess(body, req, res) {
return this.chatService.chatProcess(body, req, res);
}
chatProcessSync(body, req) {
return this.chatService.chatProcess(Object.assign({}, body), req);
}
async mjFanyi(body, req) {
return this.chatService.chatProcess(Object.assign(Object.assign({}, body), { specialModel: 'PromptOptimization' }), req);
}
async chatmind(body, req, res) {
return this.chatService.chatProcess(Object.assign(Object.assign({}, body), { specialModel: 'MindMap' }), req, res);
}
ttsProcess(body, req, res) {
return this.chatService.ttsProcess(body, req, res);
}
pptCover(body) {
return this.aiPptService.pptCover(body);
}
};
__decorate([
(0, common_1.Post)('chat-process'),
(0, swagger_1.ApiOperation)({ summary: 'gpt聊天对话' }),
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
(0, swagger_1.ApiBearerAuth)(),
__param(0, (0, common_1.Body)()),
__param(1, (0, common_1.Req)()),
__param(2, (0, common_1.Res)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [chatProcess_dto_1.ChatProcessDto, Object, Object]),
__metadata("design:returntype", void 0)
], ChatController.prototype, "chatProcess", null);
__decorate([
(0, common_1.Post)('chat-sync'),
(0, swagger_1.ApiOperation)({ summary: 'gpt聊天对话' }),
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
(0, swagger_1.ApiBearerAuth)(),
__param(0, (0, common_1.Body)()),
__param(1, (0, common_1.Req)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [chatProcess_dto_1.ChatProcessDto, Object]),
__metadata("design:returntype", void 0)
], ChatController.prototype, "chatProcessSync", null);
__decorate([
(0, common_1.Post)('mj-fy'),
(0, swagger_1.ApiOperation)({ summary: 'gpt描述词绘画翻译' }),
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
(0, swagger_1.ApiBearerAuth)(),
__param(0, (0, common_1.Body)()),
__param(1, (0, common_1.Req)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [chatProcess_dto_1.ChatProcessDto, Object]),
__metadata("design:returntype", Promise)
], ChatController.prototype, "mjFanyi", null);
__decorate([
(0, common_1.Post)('chat-mind'),
(0, swagger_1.ApiOperation)({ summary: 'mind思维导图提示' }),
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
(0, swagger_1.ApiBearerAuth)(),
__param(0, (0, common_1.Body)()),
__param(1, (0, common_1.Req)()),
__param(2, (0, common_1.Res)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [chatProcess_dto_1.ChatProcessDto, Object, Object]),
__metadata("design:returntype", Promise)
], ChatController.prototype, "chatmind", null);
__decorate([
(0, common_1.Post)('tts-process'),
(0, swagger_1.ApiOperation)({ summary: 'tts语音播报' }),
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
(0, swagger_1.ApiBearerAuth)(),
__param(0, (0, common_1.Body)()),
__param(1, (0, common_1.Req)()),
__param(2, (0, common_1.Res)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Object]),
__metadata("design:returntype", void 0)
], ChatController.prototype, "ttsProcess", null);
__decorate([
(0, common_1.Post)('ppt-cover'),
(0, swagger_1.ApiOperation)({ summary: 'ppt封面获取' }),
(0, common_1.UseGuards)(jwtAuth_guard_1.JwtAuthGuard),
(0, swagger_1.ApiBearerAuth)(),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], ChatController.prototype, "pptCover", null);
ChatController = __decorate([
(0, swagger_1.ApiTags)('chatgpt'),
(0, common_1.Controller)('chatgpt'),
__metadata("design:paramtypes", [chat_service_1.ChatService,
globalConfig_service_1.GlobalConfigService,
aiPPT_1.AiPptService])
], ChatController);
exports.ChatController = ChatController;

View File

@@ -0,0 +1,87 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChatModule = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const aiPPT_1 = require("../ai/aiPPT");
const cogVideo_service_1 = require("../ai/cogVideo.service");
const fluxDraw_service_1 = require("../ai/fluxDraw.service");
const lumaVideo_service_1 = require("../ai/lumaVideo.service");
const midjourneyDraw_service_1 = require("../ai/midjourneyDraw.service");
const openaiChat_service_1 = require("../ai/openaiChat.service");
const openaiDraw_service_1 = require("../ai/openaiDraw.service");
const stableDiffusion_service_1 = require("../ai/stableDiffusion.service");
const suno_service_1 = require("../ai/suno.service");
const app_entity_1 = require("../app/app.entity");
const chatGroup_entity_1 = require("../chatGroup/chatGroup.entity");
const chatLog_entity_1 = require("../chatLog/chatLog.entity");
const chatLog_service_1 = require("../chatLog/chatLog.service");
const cramiPackage_entity_1 = require("../crami/cramiPackage.entity");
const config_entity_1 = require("../globalConfig/config.entity");
const mailer_service_1 = require("../mailer/mailer.service");
const plugin_entity_1 = require("../plugin/plugin.entity");
const redisCache_service_1 = require("../redisCache/redisCache.service");
const user_entity_1 = require("../user/user.entity");
const user_service_1 = require("../user/user.service");
const accountLog_entity_1 = require("../userBalance/accountLog.entity");
const balance_entity_1 = require("../userBalance/balance.entity");
const fingerprint_entity_1 = require("../userBalance/fingerprint.entity");
const userBalance_entity_1 = require("../userBalance/userBalance.entity");
const userBalance_service_1 = require("../userBalance/userBalance.service");
const verification_service_1 = require("../verification/verification.service");
const verifycation_entity_1 = require("../verification/verifycation.entity");
const chat_controller_1 = require("./chat.controller");
const chat_service_1 = require("./chat.service");
const netSearch_service_1 = require("../ai/netSearch.service");
let ChatModule = class ChatModule {
};
ChatModule = __decorate([
(0, common_1.Global)(),
(0, common_1.Module)({
imports: [
typeorm_1.TypeOrmModule.forFeature([
balance_entity_1.BalanceEntity,
user_entity_1.UserEntity,
plugin_entity_1.PluginEntity,
verifycation_entity_1.VerifycationEntity,
chatLog_entity_1.ChatLogEntity,
accountLog_entity_1.AccountLogEntity,
config_entity_1.ConfigEntity,
user_entity_1.UserEntity,
cramiPackage_entity_1.CramiPackageEntity,
chatGroup_entity_1.ChatGroupEntity,
app_entity_1.AppEntity,
userBalance_entity_1.UserBalanceEntity,
fingerprint_entity_1.FingerprintLogEntity,
]),
],
controllers: [chat_controller_1.ChatController],
providers: [
chat_service_1.ChatService,
userBalance_service_1.UserBalanceService,
user_service_1.UserService,
verification_service_1.VerificationService,
chatLog_service_1.ChatLogService,
redisCache_service_1.RedisCacheService,
mailer_service_1.MailerService,
suno_service_1.SunoService,
openaiChat_service_1.OpenAIChatService,
stableDiffusion_service_1.StableDiffusionService,
midjourneyDraw_service_1.MidjourneyService,
openaiDraw_service_1.OpenAIDrawService,
lumaVideo_service_1.LumaVideoService,
cogVideo_service_1.CogVideoService,
fluxDraw_service_1.FluxDrawService,
aiPPT_1.AiPptService,
netSearch_service_1.netSearchService,
],
exports: [chat_service_1.ChatService],
})
], ChatModule);
exports.ChatModule = ChatModule;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,78 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChatDrawDto = void 0;
const class_validator_1 = require("class-validator");
const swagger_1 = require("@nestjs/swagger");
class ChatDrawDto {
}
__decorate([
(0, swagger_1.ApiProperty)({ example: 'Draw a cute little dog', description: '绘画描述信息' }),
__metadata("design:type", String)
], ChatDrawDto.prototype, "prompt", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: 1, description: '绘画张数', required: true }),
__metadata("design:type", Number)
], ChatDrawDto.prototype, "n", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: '1024x1024', description: '图片尺寸', required: true }),
__metadata("design:type", String)
], ChatDrawDto.prototype, "size", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: 'standard', description: '图片质量', required: true }),
__metadata("design:type", String)
], ChatDrawDto.prototype, "quality", void 0);
__decorate([
(0, swagger_1.ApiProperty)({
example: 'close-up polaroid photo, of a little joyful cute panda, in the forest, sun rays coming, photographic, sharp focus, depth of field, soft lighting, heigh quality, 24mm, Nikon Z FX',
description: '绘画提示词!',
required: true,
}),
(0, swagger_1.ApiProperty)({ example: '--ar 16:9 --c 0', description: '除了prompt的额外参数' }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ChatDrawDto.prototype, "extraParam", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: 'https://xsdasdasd.com', description: '垫图图片地址' }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ChatDrawDto.prototype, "imgUrl", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: 'IMAGINE', description: '任务类型,可用值:IMAGINE,UPSCALE,VARIATION,ZOOM,PAN,DESCRIBE,BLEND,SHORTEN,SWAP_FACE' }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ChatDrawDto.prototype, "action", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: 1, description: '变体或者放大的序号' }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Number)
], ChatDrawDto.prototype, "orderId", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: 1, description: '绘画的DBID' }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Number)
], ChatDrawDto.prototype, "drawId", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: 1, description: 'customId' }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ChatDrawDto.prototype, "customId", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: 1, description: 'base64' }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ChatDrawDto.prototype, "base64", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: 1, description: '任务ID' }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Number)
], ChatDrawDto.prototype, "taskId", void 0);
exports.ChatDrawDto = ChatDrawDto;

View File

@@ -0,0 +1,57 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChatProcessDto = exports.Options = void 0;
const class_validator_1 = require("class-validator");
const swagger_1 = require("@nestjs/swagger");
const class_transformer_1 = require("class-transformer");
class Options {
}
__decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], Options.prototype, "parentMessageId", void 0);
exports.Options = Options;
class ChatProcessDto {
}
__decorate([
(0, swagger_1.ApiProperty)({ example: 'hello, Who are you', description: '对话信息' }),
(0, class_validator_1.IsNotEmpty)({ message: '提问信息不能为空!' }),
__metadata("design:type", String)
], ChatProcessDto.prototype, "prompt", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: 'https://aiweb.com', description: '对话附带的链接', required: false }),
__metadata("design:type", String)
], ChatProcessDto.prototype, "url", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: '{ parentMessageId: 0 }', description: '上次对话信息', required: false }),
(0, class_transformer_1.Type)(() => Options),
__metadata("design:type", Options)
], ChatProcessDto.prototype, "options", void 0);
__decorate([
(0, swagger_1.ApiProperty)({
example: "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.",
description: '系统预设信息',
}),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ChatProcessDto.prototype, "systemMessage", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: 1, description: '应用id', required: false }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Number)
], ChatProcessDto.prototype, "appId", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: "gpt-3.5-turbo", description: '使用模型', required: false }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], ChatProcessDto.prototype, "model", void 0);
exports.ChatProcessDto = ChatProcessDto;

View File

@@ -0,0 +1,46 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addOneIfOdd = exports.unifiedFormattingResponse = void 0;
function unifiedFormattingResponse(keyType, response, others) {
let formatRes = {
keyType,
parentMessageId: '',
text: '',
usage: {
prompt_tokens: 0,
completion_tokens: 0,
total_tokens: 0,
}
};
const { parentMessageId } = response === null || response === void 0 ? void 0 : response.detail;
let { usage } = response === null || response === void 0 ? void 0 : response.detail;
if (!usage) {
usage = {
prompt_tokens: 0,
completion_tokens: 0,
total_tokens: 0
};
}
const { prompt_tokens, completion_tokens, total_tokens } = usage;
formatRes = {
keyType,
parentMessageId,
text: response.text,
usage: {
prompt_tokens,
completion_tokens,
total_tokens
}
};
return formatRes;
}
exports.unifiedFormattingResponse = unifiedFormattingResponse;
function addOneIfOdd(num) {
if (num % 2 !== 0) {
return num + 1;
}
else {
return num;
}
}
exports.addOneIfOdd = addOneIfOdd;