diff --git a/.env b/.env index 94c0fc4..2995b09 100644 --- a/.env +++ b/.env @@ -23,7 +23,7 @@ hmac = 8aU8WnITYhwaGTXH PROMOTION_LLM_URL=http://chat.taimed.cn/v1/chat/completions PROMOTION_LLM_MODEL=your-model-name PROMOTION_LLM_TIMEOUT=30 -PROMOTION_LLM_FALLBACK="" +PROMOTION_LLM_FALLBACK="We would like to cordially invite you to consider submitting a manuscript to {{journal_name}}." PROMOTION_LLM_ADVISED_FALLBACK="" [journal] diff --git a/application/common/PromotionLlmService.php b/application/common/PromotionLlmService.php index 9651b4f..208b387 100644 --- a/application/common/PromotionLlmService.php +++ b/application/common/PromotionLlmService.php @@ -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); diff --git a/application/common/PromotionService.php b/application/common/PromotionService.php index 9628ef7..666a332 100644 --- a/application/common/PromotionService.php +++ b/application/common/PromotionService.php @@ -603,9 +603,9 @@ class PromotionService $data = ['log_id' => intval($logId)]; if ($delay > 0) { - Queue::later($delay, $jobClass, $data, 'promotionmmm'); + Queue::later($delay, $jobClass, $data, 'PromotionPrepareEmail'); } else { - Queue::push($jobClass, $data, 'promotionmmm'); + Queue::push($jobClass, $data, 'PromotionPrepareEmail'); } }