Add attachment-aware AI drafting and CV section tools
This commit is contained in:
@@ -36,6 +36,8 @@ public sealed class ProfileCvController : ControllerBase
|
||||
_aiService = aiService;
|
||||
}
|
||||
|
||||
public sealed record RewriteSectionRequest(string SectionName, string? Style, string? TargetRole);
|
||||
|
||||
[HttpPost("upload")]
|
||||
[RequestSizeLimit(MaxFileSizeBytes)]
|
||||
public async Task<IActionResult> Upload([FromForm] IFormFile file)
|
||||
@@ -119,6 +121,31 @@ public sealed class ProfileCvController : ControllerBase
|
||||
return Ok(new { rebuilt = true, characters = user.ProfileCvText.Length, text = user.ProfileCvText });
|
||||
}
|
||||
|
||||
[HttpPost("rewrite-section")]
|
||||
public async Task<IActionResult> RewriteSection([FromBody] RewriteSectionRequest request)
|
||||
{
|
||||
var user = await _users.GetUserAsync(User);
|
||||
if (user is null) return Unauthorized();
|
||||
if (string.IsNullOrWhiteSpace(user.ProfileCvText)) return BadRequest("Add or import CV text before rewriting a section.");
|
||||
|
||||
var sectionName = string.IsNullOrWhiteSpace(request.SectionName) ? "Professional Summary" : request.SectionName.Trim();
|
||||
var style = string.IsNullOrWhiteSpace(request.Style) ? "balanced" : request.Style.Trim();
|
||||
var targetRole = string.IsNullOrWhiteSpace(request.TargetRole) ? null : request.TargetRole.Trim();
|
||||
|
||||
var rewritten = await _aiService.SummarizeSectionAsync(
|
||||
$"Rewrite only the '{sectionName}' section of this CV. Preserve facts, avoid inventing employers or metrics, and output only the rewritten section text. Style: {style}. {(targetRole is not null ? $"Target role: {targetRole}." : "Make it broadly reusable for future tailoring.")}",
|
||||
user.ProfileCvText,
|
||||
900,
|
||||
180);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(rewritten))
|
||||
{
|
||||
return BadRequest("The AI service could not rewrite that CV section right now.");
|
||||
}
|
||||
|
||||
return Ok(new { sectionName, style, targetRole, text = rewritten.Trim() });
|
||||
}
|
||||
|
||||
[HttpPost("improve")]
|
||||
public async Task<IActionResult> Improve()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user