fix: restrict NAV2 prebuilt artifacts to amd64
This commit is contained in:
@@ -2,6 +2,7 @@ import { Body, Controller, Delete, Get, Param, Post, Query, Req } from '@nestjs/
|
||||
import { Request } from 'express';
|
||||
|
||||
import { ChatService } from './chat.service';
|
||||
import { CancelActiveAiResponseDto } from './dto/cancel-active-ai-response.dto';
|
||||
import { CreateAiResponseDto } from './dto/create-ai-response.dto';
|
||||
import { CreateChatMessageDto } from './dto/create-chat-message.dto';
|
||||
import { CreateInstructorChatMessageDto } from './dto/create-instructor-chat-message.dto';
|
||||
@@ -64,10 +65,11 @@ export class ChatController {
|
||||
@Post('ai/cancel-active')
|
||||
cancelActiveAiResponse(
|
||||
@Req() request: Request,
|
||||
@Body() body: { week?: number },
|
||||
@Body() body: CancelActiveAiResponseDto,
|
||||
) {
|
||||
return this.chatService.cancelActiveAiResponse(
|
||||
this.getBearerToken(request),
|
||||
body.courseId,
|
||||
body.week,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ type FutureDriveLlmChatResponse = {
|
||||
|
||||
const STUDENT_CHAT_VISIBLE_MESSAGE_LIMIT = 20;
|
||||
const AI_CHAT_CONTEXT_MESSAGE_LIMIT = 6;
|
||||
const PUBLIC_GUIDE_COURSE_SLUG = 'autonomy-studio-lms-guide';
|
||||
|
||||
@Injectable()
|
||||
export class ChatService {
|
||||
@@ -79,7 +80,7 @@ export class ChatService {
|
||||
|
||||
async listThreads(accessToken: string | undefined, query: ListChatThreadsDto) {
|
||||
const student = await this.getLmsUser(accessToken);
|
||||
const course = await this.getActiveCourse();
|
||||
const course = await this.getStudentCourse(student.id, query.courseId);
|
||||
const week = query.week
|
||||
? await this.getCourseWeek(course.id, query.week)
|
||||
: null;
|
||||
@@ -122,7 +123,7 @@ export class ChatService {
|
||||
|
||||
async clearStudentThreads(accessToken: string | undefined, query: ListChatThreadsDto) {
|
||||
const student = await this.getLmsUser(accessToken);
|
||||
const course = await this.getActiveCourse();
|
||||
const course = await this.getStudentCourse(student.id, query.courseId);
|
||||
const week = query.week
|
||||
? await this.getCourseWeek(course.id, query.week)
|
||||
: null;
|
||||
@@ -167,7 +168,7 @@ export class ChatService {
|
||||
dto: CreateChatMessageDto,
|
||||
) {
|
||||
const student = await this.getLmsUser(accessToken);
|
||||
const course = await this.getActiveCourse();
|
||||
const course = await this.getStudentCourse(student.id, dto.courseId);
|
||||
const week = dto.week ? await this.getCourseWeek(course.id, dto.week) : null;
|
||||
const thread = await this.getOrCreateThread({
|
||||
courseId: course.id,
|
||||
@@ -220,7 +221,7 @@ export class ChatService {
|
||||
dto: CreateAiResponseDto,
|
||||
) {
|
||||
const student = await this.getLmsUser(accessToken);
|
||||
const course = await this.getActiveCourse();
|
||||
const course = await this.getStudentCourse(student.id, dto.courseId);
|
||||
const week = dto.week ? await this.getCourseWeek(course.id, dto.week) : null;
|
||||
const thread = await this.getOrCreateThread({
|
||||
courseId: course.id,
|
||||
@@ -425,10 +426,11 @@ export class ChatService {
|
||||
|
||||
async cancelActiveAiResponse(
|
||||
accessToken: string | undefined,
|
||||
courseId: string,
|
||||
weekNumber?: number,
|
||||
) {
|
||||
const student = await this.getLmsUser(accessToken);
|
||||
const course = await this.getActiveCourse();
|
||||
const course = await this.getStudentCourse(student.id, courseId);
|
||||
const week = weekNumber ? await this.getCourseWeek(course.id, weekNumber) : null;
|
||||
const message = await this.prisma.chatMessage.findFirst({
|
||||
where: {
|
||||
@@ -487,7 +489,7 @@ export class ChatService {
|
||||
query: ListChatThreadsDto,
|
||||
) {
|
||||
const instructor = await this.getInstructorLmsUser(accessToken);
|
||||
const course = await this.getActiveCourse();
|
||||
const course = await this.getInstructorCourse(instructor.id, query.courseId);
|
||||
const week = query.week
|
||||
? await this.getCourseWeek(course.id, query.week)
|
||||
: null;
|
||||
@@ -680,11 +682,41 @@ export class ChatService {
|
||||
};
|
||||
}
|
||||
|
||||
private async getActiveCourse() {
|
||||
private async getStudentCourse(studentId: string, courseId?: string) {
|
||||
if (!courseId) throw new NotFoundException('Course not found');
|
||||
|
||||
const course = await this.prisma.course.findFirst({
|
||||
where: { slug: 'futuredrive-autonomy-basic', isActive: true },
|
||||
where: {
|
||||
id: courseId,
|
||||
isActive: true,
|
||||
OR: [
|
||||
{ slug: PUBLIC_GUIDE_COURSE_SLUG },
|
||||
{
|
||||
enrollments: {
|
||||
some: {
|
||||
userId: studentId,
|
||||
status: 'ACTIVE',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
if (!course) throw new NotFoundException('Curriculum course not found');
|
||||
if (!course) throw new NotFoundException('Course not found');
|
||||
return course;
|
||||
}
|
||||
|
||||
private async getInstructorCourse(instructorId: string, courseId?: string) {
|
||||
if (!courseId) throw new NotFoundException('Course not found');
|
||||
|
||||
const course = await this.prisma.course.findFirst({
|
||||
where: {
|
||||
id: courseId,
|
||||
isActive: true,
|
||||
teacherId: instructorId,
|
||||
},
|
||||
});
|
||||
if (!course) throw new NotFoundException('Course not found');
|
||||
return course;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { IsInt, IsOptional, IsUUID, Max, Min } from 'class-validator';
|
||||
|
||||
export class CancelActiveAiResponseDto {
|
||||
@IsUUID()
|
||||
courseId: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@Max(100)
|
||||
week?: number;
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
import { IsInt, IsOptional, IsString, Max, Min } from 'class-validator';
|
||||
import { IsInt, IsOptional, IsString, IsUUID, Max, Min } from 'class-validator';
|
||||
|
||||
export class CreateAiResponseDto {
|
||||
@IsUUID()
|
||||
courseId: string;
|
||||
|
||||
@IsString()
|
||||
content: string;
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { IsIn, IsInt, IsOptional, IsString, Max, Min } from 'class-validator';
|
||||
import { IsIn, IsInt, IsOptional, IsString, IsUUID, Max, Min } from 'class-validator';
|
||||
|
||||
export class CreateChatMessageDto {
|
||||
@IsUUID()
|
||||
courseId: string;
|
||||
|
||||
@IsIn(['ai', 'teacher'])
|
||||
mode: 'ai' | 'teacher';
|
||||
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import { Transform } from 'class-transformer';
|
||||
import { IsBoolean, IsIn, IsInt, IsOptional, Max, Min } from 'class-validator';
|
||||
import { IsBoolean, IsIn, IsInt, IsOptional, IsUUID, Max, Min } from 'class-validator';
|
||||
|
||||
export class ListChatThreadsDto {
|
||||
@IsOptional()
|
||||
@IsUUID()
|
||||
courseId?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsIn(['ai', 'teacher'])
|
||||
mode?: 'ai' | 'teacher';
|
||||
|
||||
Reference in New Issue
Block a user