修改自动推广的相关任务

This commit is contained in:
wangjinlei
2026-04-24 17:26:55 +08:00
parent d21c33fcd0
commit e50decedcd
3 changed files with 26 additions and 11 deletions

View File

@@ -97,6 +97,11 @@ class PromotionLlmService
$journalAims = trim((string)($journal['aims'] ?? ''));
$journalDbs = trim((string)($journal['databases'] ?? ''));
// advised_topics 目标数量:期望邮件里总是体现 3 个推荐方向
$targetTopicCount = 3;
$overlapCount = count($overlapList);
$needFill = max(0, $targetTopicCount - $overlapCount);
$system = 'You are an academic editorial assistant. '
. 'You will receive context about an author, their recent paper, and a target journal, '
. 'and you must produce TWO English paragraphs for an invitation email. '
@@ -106,12 +111,17 @@ class PromotionLlmService
. '(a) briefly appreciate the author\'s recent paper, '
. '(b) explain why it fits the journal\'s scope, '
. '(c) gently invite a future submission. '
. 'Rules for "advised_topics": 1-2 sentences, <=40 words; '
. 'emphasize that the journal is particularly interested in the research directions '
. 'where the journal\'s focus and the author\'s work overlap; '
. 'mention the overlapping topics explicitly (use the provided overlap list when non-empty, '
. 'otherwise choose the best semantic overlap between journal focus and author fields); '
. 'end by inviting contributions leaning toward those directions. '
. 'Rules for "advised_topics": 1-2 sentences, <=60 words; '
. 'Must recommend EXACTLY ' . $targetTopicCount . ' research directions the journal is particularly interested in, '
. 'and explicitly list these ' . $targetTopicCount . ' topics in the sentence. '
. 'Topic selection rules, in order: '
. '(i) include all items from "Overlap topics (exact match)" first, preserving their order; '
. '(ii) if overlap has fewer than ' . $targetTopicCount . ' items, fill the remaining slots '
. 'with topics that are semantically close to BOTH the journal\'s focus fields and the author\'s research fields '
. '(prefer concrete sub-topics over generic umbrella terms; '
. 'do NOT invent topics unrelated to either list); '
. '(iii) never repeat topics, keep wording concise (2-4 words each). '
. 'End the paragraph by inviting contributions leaning toward those directions. '
. 'No greetings, no signatures, no placeholders, no markdown, no code fences. '
. 'If a section genuinely cannot be produced, return an empty string for that key.';
@@ -129,9 +139,13 @@ class PromotionLlmService
$userLines[] = 'Journal focus fields: ' . implode(', ', $journalList);
}
if (!empty($overlapList)) {
$userLines[] = 'Overlap topics (exact match): ' . implode(', ', $overlapList);
$userLines[] = 'Overlap topics (exact match): ' . implode(', ', $overlapList)
. ' [count=' . $overlapCount . ', need_fill=' . $needFill . ']';
} else {
$userLines[] = 'Overlap topics (exact match): (none, infer semantically from the two field lists above)';
$userLines[] = 'Overlap topics (exact match): (none) '
. '[count=0, need_fill=' . $targetTopicCount
. '; please pick ' . $targetTopicCount
. ' semantically related topics from the two field lists above]';
}
if ($journalAims !== '') {
$userLines[] = 'Journal aims & scope: ' . mb_substr($journalAims, 0, 500);
@@ -139,6 +153,7 @@ class PromotionLlmService
if ($journalDbs !== '') {
$userLines[] = 'Journal indexing: ' . mb_substr($journalDbs, 0, 200);
}
$userLines[] = 'Advised topics required count: ' . $targetTopicCount;
$userLines[] = 'Return only minified JSON {"description":"...","advised_topics":"..."}.';
$user = implode("\n", $userLines);