feat: изменил логику анализа отзывов
Backend CI / build-and-test (push) Failing after 14m19s
🚀 Create and publish a Docker image / Detect changes in backend and frontend (push) Failing after 12m5s
Frontend CI / build-and-check (push) Failing after 17m58s
🚀 Create and publish a Docker image / Build & publish frontend image (push) Failing after 10m11s
🚀 Create and publish a Docker image / Build & publish backend image (push) Failing after 11m3s
🚀 Create and publish a Docker image / Update stack on Portainer (push) Failing after 14m58s
Backend CI / build-and-test (push) Failing after 14m19s
🚀 Create and publish a Docker image / Detect changes in backend and frontend (push) Failing after 12m5s
Frontend CI / build-and-check (push) Failing after 17m58s
🚀 Create and publish a Docker image / Build & publish frontend image (push) Failing after 10m11s
🚀 Create and publish a Docker image / Build & publish backend image (push) Failing after 11m3s
🚀 Create and publish a Docker image / Update stack on Portainer (push) Failing after 14m58s
This commit is contained in:
@@ -31,10 +31,10 @@ public class LlmAnalysisService : ILlmAnalysisService
|
||||
var result = await _llm.AnalyzeReviewAsync(review.Text ?? "", context);
|
||||
|
||||
review.QualityScore = result.QualityScore;
|
||||
review.Sentiment = Enum.TryParse<ReviewSentiment>(result.Sentiment, true, out var s)
|
||||
? s : ReviewSentiment.Neutral;
|
||||
review.Sentiment = ParseSentiment(result.Sentiment);
|
||||
review.LlmTags = result.Tags;
|
||||
review.IsInformative = result.IsInformative;
|
||||
review.LlmRawOutput = result.RawOutput;
|
||||
review.LlmStatus = ReviewLlmStatus.Analyzed;
|
||||
review.UpdatedAt = DateTime.UtcNow;
|
||||
await _db.SaveChangesAsync();
|
||||
@@ -53,14 +53,16 @@ public class LlmAnalysisService : ILlmAnalysisService
|
||||
}
|
||||
}
|
||||
|
||||
public async Task ProcessPendingReviewsAsync()
|
||||
private static ReviewSentiment ParseSentiment(string value)
|
||||
{
|
||||
var pending = await _db.Reviews
|
||||
.Where(r => r.LlmStatus == ReviewLlmStatus.Pending)
|
||||
.OrderBy(r => r.CreatedAt).Take(10)
|
||||
.Select(r => r.Id).ToListAsync();
|
||||
|
||||
foreach (var id in pending)
|
||||
await AnalyzeReviewAsync(id);
|
||||
var normalized = value.Trim().ToLowerInvariant();
|
||||
return normalized switch
|
||||
{
|
||||
"positive" or "положительный" or "положительная" or "позитивный" or "позитивная" => ReviewSentiment.Positive,
|
||||
"negative" or "отрицательный" or "отрицательная" or "негативный" or "негативная" => ReviewSentiment.Negative,
|
||||
"neutral" or "нейтральный" or "нейтральная" => ReviewSentiment.Neutral,
|
||||
_ when Enum.TryParse<ReviewSentiment>(value, true, out var sentiment) => sentiment,
|
||||
_ => ReviewSentiment.Neutral
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user