Spaces:
Runtime error
Runtime error
Download src/modules/template/template.controller.ts from MuhammadNoman7600/qwen_2.5_model: direct link, hf CLI and curl.
- Browser
- Download file 3.21 kB
-
https://huggingface.co/spaces/MuhammadNoman7600/qwen_2.5_model/resolve/main/src/modules/template/template.controller.ts
- Command line
-
hf download hf://spaces/MuhammadNoman7600/qwen_2.5_model/src/modules/template/template.controller.ts
-
curl -L -o template.controller.ts https://huggingface.co/spaces/MuhammadNoman7600/qwen_2.5_model/resolve/main/src/modules/template/template.controller.ts
3.21 kB
| import { Controller, Get, Post, Put, Delete, Param, Body, HttpCode, HttpStatus } from '@nestjs/common'; | |
| import { ApiTags, ApiOperation, ApiResponse, ApiParam } from '@nestjs/swagger'; | |
| import { TemplateService } from './template.service'; | |
| import { CreateTemplateDto, UpdateTemplateDto, TemplateResponseDto } from './dto'; | |
| import { Template } from './entities/template.entity'; | |
| import { RequireRole } from '../auth/decorators/auth.decorators'; | |
| import { ApiKeyRole } from '../auth/entities/api-key.entity'; | |
| ('templates') | |
| ('sessions/:sessionId/templates') | |
| export class TemplateController { | |
| constructor(private readonly templateService: TemplateService) {} | |
| () | |
| (ApiKeyRole.OPERATOR) | |
| ({ summary: 'Create a message template for the session' }) | |
| ({ name: 'sessionId', description: 'Session ID' }) | |
| ({ status: 201, description: 'Template created', type: TemplateResponseDto }) | |
| async create(('sessionId') sessionId: string, () dto: CreateTemplateDto): Promise<Template> { | |
| return this.templateService.create(sessionId, dto); | |
| } | |
| () | |
| (ApiKeyRole.OPERATOR) | |
| ({ summary: 'List all templates for a session' }) | |
| ({ name: 'sessionId', description: 'Session ID' }) | |
| ({ status: 200, description: 'List of templates', type: [TemplateResponseDto] }) | |
| async findBySession(('sessionId') sessionId: string): Promise<Template[]> { | |
| return this.templateService.findBySession(sessionId); | |
| } | |
| (':id') | |
| (ApiKeyRole.OPERATOR) | |
| ({ summary: 'Get a template by ID' }) | |
| ({ name: 'sessionId', description: 'Session ID' }) | |
| ({ name: 'id', description: 'Template ID' }) | |
| ({ status: 200, description: 'Template details', type: TemplateResponseDto }) | |
| ({ status: 404, description: 'Template not found' }) | |
| async findOne(('sessionId') sessionId: string, ('id') id: string): Promise<Template> { | |
| return this.templateService.findOne(sessionId, id); | |
| } | |
| (':id') | |
| (ApiKeyRole.OPERATOR) | |
| ({ summary: 'Update a template' }) | |
| ({ name: 'sessionId', description: 'Session ID' }) | |
| ({ name: 'id', description: 'Template ID' }) | |
| ({ status: 200, description: 'Template updated', type: TemplateResponseDto }) | |
| ({ status: 404, description: 'Template not found' }) | |
| async update( | |
| ('sessionId') sessionId: string, | |
| ('id') id: string, | |
| () dto: UpdateTemplateDto, | |
| ): Promise<Template> { | |
| return this.templateService.update(sessionId, id, dto); | |
| } | |
| (':id') | |
| (ApiKeyRole.OPERATOR) | |
| (HttpStatus.NO_CONTENT) | |
| ({ summary: 'Delete a template' }) | |
| ({ name: 'sessionId', description: 'Session ID' }) | |
| ({ name: 'id', description: 'Template ID' }) | |
| ({ status: 204, description: 'Template deleted' }) | |
| ({ status: 404, description: 'Template not found' }) | |
| async delete(('sessionId') sessionId: string, ('id') id: string): Promise<void> { | |
| return this.templateService.delete(sessionId, id); | |
| } | |
| } | |