feat: Phase 1-3 全部完成 — 沙盒增强、学情分析、学习路径

This commit is contained in:
yuzhiran-dev
2026-05-18 09:48:51 +08:00
commit 11bb86854c
277 changed files with 37755 additions and 0 deletions
@@ -0,0 +1,44 @@
import { Controller, Post, Get, Delete, Patch, Body, Param, Query, UseGuards, Req, ParseIntPipe } from '@nestjs/common';
import { ApiTags, ApiBearerAuth, ApiBody } from '@nestjs/swagger';
import { AuthGuard } from '@nestjs/passport';
import { SandboxService } from './sandbox.service';
import { ChatOptions } from '../ai/ai-gateway.service';
@ApiTags('AI沙箱')
@Controller('sandbox')
@UseGuards(AuthGuard('jwt'))
@ApiBearerAuth()
export class SandboxController {
constructor(private sandboxService: SandboxService) {}
@Post('chat')
@ApiBody({ schema: { example: { conversationId: 'uuid', model: 'general', messages: [{ role: 'user', content: 'hi' }], temperature: 0.7, top_p: 1, max_tokens: 2000 } } })
async chat(@Req() req: any, @Body() body: { conversationId?: string; model: string; messages: { role: string; content: string }[] } & ChatOptions) {
return this.sandboxService.chat(req.user.userId, body.conversationId, body.model, body.messages, body);
}
@Get('sessions')
async sessions(@Req() req: any, @Query() query: { page?: number; pageSize?: number; search?: string }) {
return this.sandboxService.getSessions(req.user.userId, query);
}
@Get('sessions/:id')
async getSession(@Req() req: any, @Param('id', ParseIntPipe) id: number) {
return this.sandboxService.getSession(req.user.userId, id);
}
@Patch('sessions/:id/feedback')
async setFeedback(@Req() req: any, @Param('id', ParseIntPipe) id: number, @Body() body: { feedback: 'LIKE' | 'DISLIKE' | null }) {
return this.sandboxService.setFeedback(req.user.userId, id, body.feedback);
}
@Delete('sessions/:id')
async deleteSession(@Req() req: any, @Param('id', ParseIntPipe) id: number) {
return this.sandboxService.deleteSession(req.user.userId, id);
}
@Get('quota')
async quota(@Req() req: any) {
return this.sandboxService.getQuota(req.user.userId);
}
}