Fix hardcoded user-facing strings — localize email fallbacks, API errors, AI parse messages
- Frontend: update extractApiError to check body.code first via i18n 'error.<code>' keys; add en/ro translations for cv_file_missing, captcha_verification_failed, request_cancelled - email-data migration: seed 6 fallback template keys (match N/A, subject label, unknown IP, job search results empty states for keywords/providers/location) - EmailApiEmailSender: replace "N/A", "Job", "Unknown" literals with template lookups - CvSearchEmailSender: replace "none detected", "none", "-" literals with template lookups - cv-matcher-data migration: seed parse-error.summary and parse-error.recommendation in AiPrompts - CvMatcherService: look up localized parse-error messages from AiPrompts before calling ParseResult Closes #53 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -141,7 +141,9 @@ public sealed class CvMatcherService : ICvMatcherService
|
||||
""";
|
||||
|
||||
var json = await _ai.CreateChatCompletionAsync(systemPrompt, userPrompt, 0.2m, ct);
|
||||
var result = ParseResult(json);
|
||||
var errorSummary = await _aiPrompts.GetAsync("parse-error.summary", language, ct);
|
||||
var errorRec = await _aiPrompts.GetAsync("parse-error.recommendation", language, ct);
|
||||
var result = ParseResult(json, errorSummary, errorRec);
|
||||
result.JobDocumentId = job.Id;
|
||||
result.JobUrl = job.SourceUrl;
|
||||
result.Cached = false;
|
||||
@@ -153,7 +155,10 @@ public sealed class CvMatcherService : ICvMatcherService
|
||||
/// Deserialises the LLM's JSON output into a <see cref="JobMatchResponse"/>.
|
||||
/// Returns a safe fallback response instead of throwing when the JSON cannot be parsed.
|
||||
/// </summary>
|
||||
private static JobMatchResponse ParseResult(string json)
|
||||
private static JobMatchResponse ParseResult(
|
||||
string json,
|
||||
string? errorSummary = null,
|
||||
string? errorRec = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -168,8 +173,8 @@ public sealed class CvMatcherService : ICvMatcherService
|
||||
return new JobMatchResponse
|
||||
{
|
||||
Score = 0,
|
||||
Summary = "The AI response could not be parsed as structured JSON.",
|
||||
Recommendations = ["Inspect the raw model output and tune the scoring prompt."]
|
||||
Summary = errorSummary ?? "The AI response could not be parsed as structured JSON.",
|
||||
Recommendations = [errorRec ?? "Inspect the raw model output and tune the scoring prompt."]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user