feat(日报生成): 添加日报摘要步骤并更新相关配置
- 新增第三步摘要生成功能,添加 summarizationPromptStepThree.js - 在日报内容中插入摘要部分和最小化标题 - 更新 wrangler.toml 配置添加 DAILY_TITLE_MIN 变量 - 优化 HTML 预览样式支持视频元素 - 更新 README 添加日报前端项目链接 - 修改脚注样式并更新图片链接
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
|
||||
我们的目标是成为您在瞬息万变的 AI 浪潮中保持领先的得力助手,让您高效获取最有价值的信息。
|
||||
|
||||
> [!NOTE]
|
||||
> 日报前端项目已发布2.0: [Hextra-AI-Insight-Daily](https://github.com/justlovemaki/Hextra-AI-Insight-Daily) ,基于 Hugo 加 Hextra主题 构建。
|
||||
---
|
||||
|
||||
## ✨ 核心特性
|
||||
@@ -66,7 +68,7 @@
|
||||
* **唯一主站点 (GitHub Pages)**
|
||||
> [https://ai.hubtoday.app/](https://ai.hubtoday.app/)
|
||||
>
|
||||
> `✅ 推荐` `🚀 访问速度快`
|
||||
> `✅ 推荐` `🚀 访问速度快`
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@ export function insertFoot() {
|
||||
|
||||
---
|
||||
|
||||
**收听语音版**
|
||||
#### **收听语音版**
|
||||
|
||||
| 🎙️ **小宇宙** | 📹 **抖音** |
|
||||
| --- | --- |
|
||||
| [来生小酒馆](https://www.xiaoyuzhoufm.com/podcast/683c62b7c1ca9cf575a5030e) | [来生情报站](https://www.douyin.com/user/MS4wLjABAAAAwpwqPQlu38sO38VyWgw9ZjDEnN4bMR5j8x111UxpseHR9DpB6-CveI5KRXOWuFwG)|
|
||||
|  |  |
|
||||
|  |  |
|
||||
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -4,8 +4,9 @@ import { getFromKV } from '../kv.js';
|
||||
import { callChatAPIStream } from '../chatapi.js';
|
||||
import { generateGenAiPageHtml } from '../htmlGenerators.js';
|
||||
import { dataSources } from '../dataFetchers.js'; // Import dataSources
|
||||
import { getSystemPromptSummarizationStepOne } from '../prompt/summarizationPromptStepOne.js';
|
||||
import { getSystemPromptSummarizationStepTwo } from '../prompt/summarizationPromptStepTwo.js';
|
||||
import { getSystemPromptSummarizationStepOne } from "../prompt/summarizationPromptStepOne";
|
||||
import { getSystemPromptSummarizationStepTwo } from "../prompt/summarizationPromptStepTwo";
|
||||
import { getSystemPromptSummarizationStepThree } from "../prompt/summarizationPromptStepThree";
|
||||
import { getSystemPromptPodcastFormatting, getSystemPromptShortPodcastFormatting } from '../prompt/podcastFormattingPrompt.js';
|
||||
import { getSystemPromptDailyAnalysis } from '../prompt/dailyAnalysisPrompt.js'; // Import new prompt
|
||||
import { insertFoot } from '../foot.js';
|
||||
@@ -252,13 +253,33 @@ export async function handleGenAIContent(request, env) {
|
||||
if (fullPromptForCall2_System) promptsMarkdownContent += `### System Instruction\n\`\`\`\n${fullPromptForCall2_System}\n\`\`\`\n\n`;
|
||||
if (fullPromptForCall2_User) promptsMarkdownContent += `### User Input (Output of Call 1)\n\`\`\`\n${fullPromptForCall2_User}\n\`\`\`\n\n`;
|
||||
|
||||
let dailySummaryMarkdownContent = `# ${env.DAILY_TITLE} ${formatDateToChinese(dateStr)}\n\n${removeMarkdownCodeBlock(outputOfCall2)}`;
|
||||
let dailySummaryMarkdownContent = `# ${env.DAILY_TITLE} ${formatDateToChinese(dateStr)}` + '\n\n';
|
||||
dailySummaryMarkdownContent += '> '+ env.DAILY_TITLE_MIN + '\n\n';
|
||||
let outputOfCall3 = null;
|
||||
console.log("Call 3 to Chat (Processing Call 2 Output): User prompt length:", outputOfCall2.length);
|
||||
try {
|
||||
let processedChunks = [];
|
||||
for await (const chunk of callChatAPIStream(env, outputOfCall2, getSystemPromptSummarizationStepThree())) {
|
||||
processedChunks.push(chunk);
|
||||
}
|
||||
outputOfCall3 = processedChunks.join('');
|
||||
if (!outputOfCall3 || outputOfCall3.trim() === "") throw new Error("Chat processing call returned empty content.");
|
||||
outputOfCall3 = removeMarkdownCodeBlock(outputOfCall3); // Clean the output
|
||||
console.log("Call 3 (Processing Call 2 Output) successful. Output length:", outputOfCall3.length);
|
||||
} catch (error) {
|
||||
console.error("Error in Chat API Call 3 (Processing Call 2 Output):", error);
|
||||
const errorHtml = generateGenAiPageHtml(env, '生成AI日报出错(摘要)', `<p><strong>Failed during processing of summarized content:</strong> ${escapeHtml(error.message)}</p>${error.stack ? `<pre>${escapeHtml(error.stack)}</pre>` : ''}`, dateStr, true, selectedItemsParams, fullPromptForCall1_System, fullPromptForCall1_User, fullPromptForCall2_System, fullPromptForCall2_User);
|
||||
return new Response(errorHtml, { status: 500, headers: { 'Content-Type': 'text/html; charset=utf-8' } });
|
||||
}
|
||||
dailySummaryMarkdownContent += '\n\n#### **AI内容摘要**\n\n```\n' + outputOfCall3 + '\n```\n\n';
|
||||
|
||||
dailySummaryMarkdownContent += `\n\n${removeMarkdownCodeBlock(outputOfCall2)}`;
|
||||
if (env.INSERT_FOOT=='true') dailySummaryMarkdownContent += insertFoot() +`\n\n`;
|
||||
|
||||
const successHtml = generateGenAiPageHtml(
|
||||
env,
|
||||
'AI日报', // Title for Call 1 page
|
||||
escapeHtml(outputOfCall2),
|
||||
escapeHtml(dailySummaryMarkdownContent),
|
||||
dateStr, false, selectedItemsParams,
|
||||
fullPromptForCall1_System, fullPromptForCall1_User,
|
||||
null, null, // Pass Call 2 prompts
|
||||
|
||||
@@ -413,7 +413,7 @@ export function generateGenAiPageHtml(env, title, bodyContent, pageDate, isError
|
||||
function openContentInNewWindow() {
|
||||
const content = document.getElementById('outContentBox').innerHTML;
|
||||
const newWindow = window.open('', '_blank');
|
||||
newWindow.document.write('<!DOCTYPE html><html><head><title>内容预览</title><style> img{max-width: 100%;} div{max-width: 36%; margin: 0 auto;} body {font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; line-height: 1.6; padding: 1rem; }</style></head><body>');
|
||||
newWindow.document.write('<!DOCTYPE html><html><head><title>内容预览</title><style> img{max-width: 100%;} video{max-width: 100%;} div{max-width: 36%; margin: 0 auto;} body {font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; line-height: 1.6; padding: 1rem; }</style></head><body>');
|
||||
newWindow.document.write('<div>'+content+'</div>');
|
||||
newWindow.document.write('</body></html>');
|
||||
newWindow.document.close();
|
||||
|
||||
13
src/prompt/summarizationPromptStepThree.js
Normal file
13
src/prompt/summarizationPromptStepThree.js
Normal file
@@ -0,0 +1,13 @@
|
||||
export function getSystemPromptSummarizationStepThree() {
|
||||
return `
|
||||
你是一个专业的文本摘要助手。你的任务是根据给定的文本内容,生成一个简洁的100字的摘要。
|
||||
|
||||
**重要原则:**
|
||||
* 摘要内容必须严格来源于原文,不得捏造、歪曲或添加原文中未提及的信息。
|
||||
* 摘要应准确、客观地反映原文的核心要点和关键信息。
|
||||
* 输出语言为简体中文,并且必须以纯文本形式输出,不包含任何Markdown格式或特殊字符。
|
||||
* 输出3行文字,每1行必须是25至35个字。
|
||||
|
||||
请直接输出生成的摘要,不要包含任何解释性文字。
|
||||
`;
|
||||
}
|
||||
@@ -43,6 +43,7 @@ GITHUB_BRANCH = "main"
|
||||
LOGIN_USERNAME = "root"
|
||||
LOGIN_PASSWORD = "toor"
|
||||
DAILY_TITLE = "AI洞察日报"
|
||||
DAILY_TITLE_MIN = " `AI 日报` "
|
||||
PODCAST_TITLE = "来生小酒馆"
|
||||
PODCAST_BEGIN = "嘿,亲爱的V,欢迎收听新一期的来生情报站,我是你们的老朋友,何夕2077"
|
||||
PODCAST_END = "今天的情报就到这里,注意隐蔽,赶紧撤离"
|
||||
|
||||
Reference in New Issue
Block a user