feat: добавил изменение промта для админа
Backend CI / build-and-test (push) Failing after 11m26s
🚀 Create and publish a Docker image / Detect changes in backend and frontend (push) Failing after 14m2s
Frontend CI / build-and-check (push) Failing after 19m55s
🚀 Create and publish a Docker image / Build & publish frontend image (push) Failing after 14m7s
🚀 Create and publish a Docker image / Build & publish backend image (push) Failing after 14m59s
🚀 Create and publish a Docker image / Update stack on Portainer (push) Failing after 15m0s
Backend CI / build-and-test (push) Failing after 11m26s
🚀 Create and publish a Docker image / Detect changes in backend and frontend (push) Failing after 14m2s
Frontend CI / build-and-check (push) Failing after 19m55s
🚀 Create and publish a Docker image / Build & publish frontend image (push) Failing after 14m7s
🚀 Create and publish a Docker image / Build & publish backend image (push) Failing after 14m59s
🚀 Create and publish a Docker image / Update stack on Portainer (push) Failing after 15m0s
This commit is contained in:
@@ -15,8 +15,13 @@ namespace UniVerse.Api.Controllers;
|
||||
public class ReviewsController : ControllerBase
|
||||
{
|
||||
private readonly IReviewService _reviews;
|
||||
private readonly IReviewPromptService _reviewPrompts;
|
||||
|
||||
public ReviewsController(IReviewService reviews) => _reviews = reviews;
|
||||
public ReviewsController(IReviewService reviews, IReviewPromptService reviewPrompts)
|
||||
{
|
||||
_reviews = reviews;
|
||||
_reviewPrompts = reviewPrompts;
|
||||
}
|
||||
|
||||
private int CurrentUserId => int.Parse(
|
||||
User.FindFirstValue(ClaimTypes.NameIdentifier) ?? User.FindFirstValue("sub") ?? "0");
|
||||
@@ -57,6 +62,35 @@ public class ReviewsController : ControllerBase
|
||||
public async Task<ActionResult> List([FromQuery] PaginationRequest pagination) =>
|
||||
Ok(await _reviews.GetAllAsync(pagination));
|
||||
|
||||
/// <summary>Получить текущий промпт LLM-анализа отзывов.</summary>
|
||||
/// <remarks>Только Admin. Если настройка ещё не сохранена, возвращает базовый промпт.</remarks>
|
||||
/// <response code="200">Текущий шаблон промпта.</response>
|
||||
/// <response code="401">Требуется аутентификация.</response>
|
||||
/// <response code="403">Требуется роль Admin.</response>
|
||||
[Authorize(Roles = "Admin")]
|
||||
[HttpGet("llm-prompt")]
|
||||
[ProducesResponseType(typeof(ReviewPromptDto), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
public async Task<ActionResult<ReviewPromptDto>> GetLlmPrompt() =>
|
||||
Ok(await _reviewPrompts.GetAsync());
|
||||
|
||||
/// <summary>Обновить промпт LLM-анализа отзывов.</summary>
|
||||
/// <remarks>Только Admin. Промпт применяется к следующим анализам и ручным повторам.</remarks>
|
||||
/// <param name="request">Новый шаблон с плейсхолдерами {lectureContext} и {reviewText}.</param>
|
||||
/// <response code="200">Сохранённый шаблон промпта.</response>
|
||||
/// <response code="400">Промпт пустой или не содержит обязательные плейсхолдеры.</response>
|
||||
/// <response code="401">Требуется аутентификация.</response>
|
||||
/// <response code="403">Требуется роль Admin.</response>
|
||||
[Authorize(Roles = "Admin")]
|
||||
[HttpPut("llm-prompt")]
|
||||
[ProducesResponseType(typeof(ReviewPromptDto), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
public async Task<ActionResult<ReviewPromptDto>> UpdateLlmPrompt([FromBody] UpdateReviewPromptRequest request) =>
|
||||
Ok(await _reviewPrompts.UpdateAsync(request));
|
||||
|
||||
/// <summary>Получить отзыв по ID.</summary>
|
||||
/// <remarks>Только Admin или Teacher.</remarks>
|
||||
/// <param name="id">ID отзыва.</param>
|
||||
|
||||
@@ -24,6 +24,7 @@ public class ExceptionHandlingMiddleware
|
||||
{
|
||||
var (statusCode, title) = exception switch
|
||||
{
|
||||
BadRequestException => ((int)HttpStatusCode.BadRequest, "Bad Request"),
|
||||
NotFoundException => ((int)HttpStatusCode.NotFound, "Not Found"),
|
||||
ForbiddenException => ((int)HttpStatusCode.Forbidden, "Forbidden"),
|
||||
ConflictException => ((int)HttpStatusCode.Conflict, "Conflict"),
|
||||
|
||||
@@ -89,6 +89,7 @@ builder.Services.AddScoped<ILocationService, LocationService>();
|
||||
builder.Services.AddScoped<ICourseService, CourseService>();
|
||||
builder.Services.AddScoped<ILectureService, LectureService>();
|
||||
builder.Services.AddScoped<IReviewService, ReviewService>();
|
||||
builder.Services.AddScoped<IReviewPromptService, ReviewPromptService>();
|
||||
builder.Services.AddScoped<IGamificationService, GamificationService>();
|
||||
builder.Services.AddScoped<IAchievementService, AchievementService>();
|
||||
builder.Services.AddScoped<ILlmAnalysisService, LlmAnalysisService>();
|
||||
|
||||
@@ -2587,6 +2587,126 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/reviews/llm-prompt": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Reviews"
|
||||
],
|
||||
"summary": "Получить текущий промпт LLM-анализа отзывов.",
|
||||
"description": "Только Admin. Если настройка ещё не сохранена, возвращает базовый промпт.\n\n**Required roles:** Admin",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Текущий шаблон промпта.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ReviewPromptDto"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Требуется аутентификация.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Требуется роль Admin.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"Bearer": [ ]
|
||||
}
|
||||
]
|
||||
},
|
||||
"put": {
|
||||
"tags": [
|
||||
"Reviews"
|
||||
],
|
||||
"summary": "Обновить промпт LLM-анализа отзывов.",
|
||||
"description": "Только Admin. Промпт применяется к следующим анализам и ручным повторам.\n\n**Required roles:** Admin",
|
||||
"requestBody": {
|
||||
"description": "Новый шаблон с плейсхолдерами {lectureContext} и {reviewText}.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UpdateReviewPromptRequest"
|
||||
}
|
||||
},
|
||||
"text/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UpdateReviewPromptRequest"
|
||||
}
|
||||
},
|
||||
"application/*+json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/UpdateReviewPromptRequest"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Сохранённый шаблон промпта.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ReviewPromptDto"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Промпт пустой или не содержит обязательные плейсхолдеры.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Требуется аутентификация.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Требуется роль Admin.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ProblemDetails"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"Bearer": [ ]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/reviews/{id}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -5506,6 +5626,21 @@
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"ReviewPromptDto": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"prompt": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"nullable": true
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"ReviewRating": {
|
||||
"enum": [
|
||||
"Like",
|
||||
@@ -5853,6 +5988,16 @@
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"UpdateReviewPromptRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"prompt": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"UpdateReviewRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
Reference in New Issue
Block a user