feat(cv): expand builder studio tools
This commit is contained in:
@@ -224,9 +224,11 @@ public sealed class CvVariantController : ControllerBase
|
||||
if (user is null) return Unauthorized();
|
||||
var text = (request.Text ?? string.Empty).Trim();
|
||||
if (text.Length == 0) return BadRequest("Provide text to work on.");
|
||||
if (text.Length > 60_000) return BadRequest("The requested CV content is too large to process in one operation.");
|
||||
|
||||
var instruction = BuildAiInstruction(request.Action, request.Role, request.Language, request.Context);
|
||||
var result = await _ai.SummarizeSectionAsync(instruction, text, 1200, 300);
|
||||
var isDocumentAction = (request.Action ?? string.Empty).StartsWith("document-", StringComparison.OrdinalIgnoreCase);
|
||||
var result = await _ai.SummarizeSectionAsync(instruction, text, isDocumentAction ? 16_000 : 1200, isDocumentAction ? 50 : 300);
|
||||
if (string.IsNullOrWhiteSpace(result))
|
||||
{
|
||||
var metrics = await _ai.GetMetricsAsync(ct);
|
||||
@@ -239,11 +241,15 @@ public sealed class CvVariantController : ControllerBase
|
||||
|
||||
private static string BuildAiInstruction(string? action, string? role, string? language, string? context)
|
||||
{
|
||||
var normalizedAction = (action ?? "improve").Trim().ToLowerInvariant();
|
||||
var target = string.IsNullOrWhiteSpace(role) ? null : role.Trim();
|
||||
var lang = string.IsNullOrWhiteSpace(language) ? "the same language as the input" : language.Trim();
|
||||
var extra = string.IsNullOrWhiteSpace(context) ? string.Empty : $" Context: {context.Trim()}.";
|
||||
var task = (action ?? "improve").Trim().ToLowerInvariant() switch
|
||||
var task = normalizedAction switch
|
||||
{
|
||||
"document-translate" => "Translate every user-facing CV value into the requested language. Return only valid JSON with the exact same array structure, ids and fields. Preserve names, employers, dates, qualifications, URLs and technical terms unless they have a standard translation.",
|
||||
"document-improve" => "Improve clarity, concision and professional impact across the CV. Return only valid JSON with the exact same array structure, ids and fields. Preserve every fact and never invent achievements, metrics, skills or experience.",
|
||||
"document-grammar" => "Correct spelling, grammar and punctuation across the CV without changing meaning. Return only valid JSON with the exact same array structure, ids and fields.",
|
||||
"professional" => "Rewrite the text in a more professional, confident tone.",
|
||||
"shorten" => "Make the text more concise without losing meaning.",
|
||||
"expand" => "Expand the text with more concrete, relevant detail — but never invent facts.",
|
||||
@@ -256,7 +262,10 @@ public sealed class CvVariantController : ControllerBase
|
||||
"tailor" => $"Rewrite the text to align with the target role{(target is null ? string.Empty : $" '{target}'")}, emphasising the most relevant experience. Do not invent facts.",
|
||||
_ => "Improve the clarity, impact and phrasing of the text while preserving all facts.",
|
||||
};
|
||||
return $"{task} Preserve every factual claim — never invent employers, titles, dates, or metrics. Write in {lang}. Return only the rewritten text with no preamble.{extra}";
|
||||
var outputInstruction = normalizedAction.StartsWith("document-", StringComparison.Ordinal)
|
||||
? "Return only the JSON array with no Markdown fence or preamble."
|
||||
: "Return only the rewritten text with no preamble.";
|
||||
return $"{task} Preserve every factual claim — never invent employers, titles, dates, or metrics. Write in {lang}. {outputInstruction}{extra}";
|
||||
}
|
||||
|
||||
private async Task<bool> CanUseThemeAsync(ApplicationUser user, string? themeId) =>
|
||||
|
||||
Reference in New Issue
Block a user