diff --git a/src/appUrl.js b/src/appUrl.js
new file mode 100644
index 0000000..d1f8272
--- /dev/null
+++ b/src/appUrl.js
@@ -0,0 +1,27 @@
+export function getAppUrl() {
+ return `
+
+---
+
+**📢 关于 AI日报 的一次小调整**
+>
+坦白说,想要长久地把**AI日报**做下去,单靠“为爱发电”确实面临现实压力。为了更有热情的**投入精力**,我在网站接入了少量 Google 广告。
+>
+由于 RSS 无法展示广告带来收入,即日起 RSS 将**试运行“摘要模式”一段时间**。
+>
+**💡 您的每一次点击,都是对我最大的支持**
+诚挚邀请您移步官网阅读全文。那里不仅有更舒适的**排版**和清晰的**代码高亮**,还能在评论区与大家交流。
+>
+感谢您的理解与陪伴,让我们一起走得更远!
+>
+👇 **点击下方链接,阅读今日完整资讯**
+### [🚀 前往官网查看完整版 (ai.hubtoday.app)](https://ai.hubtoday.app/)
+>
+如有建议,欢迎随时邮件沟通:[justlikemaki@foxmail.com](mailto:justlikemaki@foxmail.com)
+
+或直接扫码进群提供建议:
+
+
+
+ `;
+}
\ No newline at end of file
diff --git a/src/github.js b/src/github.js
old mode 100644
new mode 100755
index cbc2365..c237a74
--- a/src/github.js
+++ b/src/github.js
@@ -106,7 +106,7 @@ export async function getDailyReportContent(env, filePath) {
const data = await callGitHubApi(env, `/contents/${filePath}?ref=${GITHUB_BRANCH}`);
return b64DecodeUnicode(data.content);
} catch (error) {
- console.error(`Error fetching daily report content from ${rawUrl}:`, error);
+ console.error(`Error fetching daily report content from ${filePath}:`, error);
throw error;
}
}
diff --git a/src/handlers/genAIContent.js b/src/handlers/genAIContent.js
old mode 100644
new mode 100755
index 68b587a..2fe22cd
--- a/src/handlers/genAIContent.js
+++ b/src/handlers/genAIContent.js
@@ -77,7 +77,7 @@ export async function handleGenAIPodcastScript(request, env) {
let promptsMarkdownContent = `# Prompts for ${dateStr}\n\n`;
promptsMarkdownContent += `## Call 3: Podcast Formatting\n\n`;
if (fullPromptForCall3_System) promptsMarkdownContent += `### System One Instruction\n\`\`\`\n${fullPromptForCall3_System}\n\`\`\`\n\n`;
-
+
let fullPromptForCall4_System = getSystemPromptShortPodcastFormatting(env);
console.log("Call 4 to Chat (Podcast Formatting): User prompt length:", userPromptPodcastFormattingData.length);
@@ -105,13 +105,13 @@ export async function handleGenAIPodcastScript(request, env) {
let podcastScriptMarkdownContent = `# ${env.PODCAST_TITLE} ${formatDateToChinese(dateStr)}\n\n${removeMarkdownCodeBlock(finalAiResponseOut)}`;
const successHtml = generateGenAiPageHtml(
- env,
+ env,
'AI播客脚本',
- escapeHtml(finalAiResponseOut),
+ escapeHtml(finalAiResponseOut),
dateStr, false, selectedItemsParams,
null, null, // No Call 1 prompts for this page
fullPromptForCallSystem, fullPromptForCall3_User,
- convertEnglishQuotesToChinese(removeMarkdownCodeBlock(promptsMarkdownContent)),
+ convertEnglishQuotesToChinese(removeMarkdownCodeBlock(promptsMarkdownContent)),
outputOfCall1, // No daily summary for this page
convertEnglishQuotesToChinese(podcastScriptMarkdownContent)
);
@@ -119,7 +119,7 @@ export async function handleGenAIPodcastScript(request, env) {
} catch (error) {
console.error("Error in /genAIPodcastScript (outer try-catch):", error);
- const pageDateForError = dateStr || getISODate();
+ const pageDateForError = dateStr || getISODate();
const itemsForActionOnError = Array.isArray(selectedItemsParams) ? selectedItemsParams : [];
const errorHtml = generateGenAiPageHtml(env, '生成AI播客脚本出错', `
Unexpected error: ${escapeHtml(error.message)}
${error.stack ? `${escapeHtml(error.stack)}` : ''}`, pageDateForError, true, itemsForActionOnError, null, null, fullPromptForCall3_System, fullPromptForCall3_User);
return new Response(errorHtml, { status: 500, headers: { 'Content-Type': 'text/html; charset=utf-8' } });
@@ -146,7 +146,7 @@ export async function handleGenAIContent(request, env) {
const errorHtml = generateGenAiPageHtml(env, '生成AI日报出错,未选生成条目', 'No items were selected. Please go back and select at least one item.
', dateStr, true, null); return new Response(errorHtml, { status: 400, headers: { 'Content-Type': 'text/html; charset=utf-8' } }); } - + console.log(`Generating AI content for ${selectedItemsParams.length} selected item references from date ${dateStr}`); const allFetchedData = {}; @@ -195,7 +195,7 @@ export async function handleGenAIContent(request, env) { if (item.details && item.details.content_html) itemText += `\nContent: ${stripHtml(item.details.content_html)}`; break; } - + if (itemText) { selectedContentItems.push(itemText); validItemsProcessedCount++; @@ -209,7 +209,7 @@ export async function handleGenAIContent(request, env) { const errorHtml = generateGenAiPageHtml(env, '生成AI日报出错,可生成条目为空', 'Selected items could not be retrieved or resulted in no content. Please check the data or try different selections.
', dateStr, true, selectedItemsParams); return new Response(errorHtml, { status: 404, headers: { 'Content-Type': 'text/html; charset=utf-8' } }); } - + //提示词内不能有英文引号,否则会存储数据缺失。 // fullPromptForCall1_System = getSystemPromptSummarizationStepOne(); // fullPromptForCall1_User = '\n\n------\n\n'+selectedContentItems.join('\n\n------\n\n')+'\n\n------\n\n'; // Keep this for logging/error reporting if needed @@ -218,11 +218,11 @@ export async function handleGenAIContent(request, env) { // try { // const chunkSize = 3; // const summaryPromises = []; - + // for (let i = 0; i < selectedContentItems.length; i += chunkSize) { // const chunk = selectedContentItems.slice(i, i + chunkSize); // const chunkPrompt = chunk.join('\n\n---\n\n'); // Join selected items with the separator - + // summaryPromises.push((async () => { // let summarizedChunks = []; // for await (const streamChunk of callChatAPIStream(env, chunkPrompt, fullPromptForCall1_System)) { @@ -264,7 +264,7 @@ export async function handleGenAIContent(request, env) { const errorHtml = generateGenAiPageHtml(env, '生成AI日报出错(格式化)', `Failed during processing of summarized content: ${escapeHtml(error.message)}
${error.stack ? `${escapeHtml(error.stack)}` : ''}`, dateStr, true, selectedItemsParams, fullPromptForCall2_System, fullPromptForCall2_User);
return new Response(errorHtml, { status: 500, headers: { 'Content-Type': 'text/html; charset=utf-8' } });
}
-
+
let promptsMarkdownContent = `# Prompts for ${dateStr}\n\n`;
// promptsMarkdownContent += `## Call 1: Content Summarization\n\n`;
// if (fullPromptForCall1_System) promptsMarkdownContent += `### System Instruction\n\`\`\`\n${fullPromptForCall1_System}\n\`\`\`\n\n`;
@@ -295,27 +295,27 @@ export async function handleGenAIContent(request, env) {
return new Response(errorHtml, { status: 500, headers: { 'Content-Type': 'text/html; charset=utf-8' } });
}
dailySummaryMarkdownContent += '\n\n### **今日摘要**\n\n```\n' + outputOfCall3 + '\n```\n\n';
+ if (env.INSERT_AD=='true') dailySummaryMarkdownContent += insertAd() +`\n`;
dailySummaryMarkdownContent += `\n\n${removeMarkdownCodeBlock(outputOfCall2)}`;
- if (env.INSERT_AD=='true') dailySummaryMarkdownContent += insertAd() +`\n`;
if (env.INSERT_FOOT=='true') dailySummaryMarkdownContent += insertFoot() +`\n\n`;
const successHtml = generateGenAiPageHtml(
- env,
+ env,
'AI日报', // Title for Call 1 page
- escapeHtml(dailySummaryMarkdownContent),
+ escapeHtml(dailySummaryMarkdownContent),
dateStr, false, selectedItemsParams,
fullPromptForCall2_System, fullPromptForCall2_User,
null, null, // Pass Call 2 prompts
- convertEnglishQuotesToChinese(removeMarkdownCodeBlock(promptsMarkdownContent)),
- convertEnglishQuotesToChinese(dailySummaryMarkdownContent),
+ convertEnglishQuotesToChinese(removeMarkdownCodeBlock(promptsMarkdownContent)),
+ convertEnglishQuotesToChinese(dailySummaryMarkdownContent),
null, // No podcast script for this page
);
return new Response(successHtml, { headers: { 'Content-Type': 'text/html; charset=utf-8' } });
} catch (error) {
console.error("Error in /genAIContent (outer try-catch):", error);
- const pageDateForError = dateStr || getISODate();
+ const pageDateForError = dateStr || getISODate();
const itemsForActionOnError = Array.isArray(selectedItemsParams) ? selectedItemsParams : [];
const errorHtml = generateGenAiPageHtml(env, '生成AI日报出错', `Unexpected error: ${escapeHtml(error.message)}
${error.stack ? `${escapeHtml(error.stack)}` : ''}`, pageDateForError, true, itemsForActionOnError, fullPromptForCall2_System, fullPromptForCall2_User);
return new Response(errorHtml, { status: 500, headers: { 'Content-Type': 'text/html; charset=utf-8' } });
diff --git a/src/handlers/writeRssData.js b/src/handlers/writeRssData.js
old mode 100644
new mode 100755
index 8a796db..89e859b
--- a/src/handlers/writeRssData.js
+++ b/src/handlers/writeRssData.js
@@ -1,10 +1,80 @@
import { replaceImageProxy, formatMarkdownText, formatDateToGMT8WithTime, removeMarkdownCodeBlock } from '../helpers.js';
-import { getDailyReportContent } from '../github.js';
+import { getDailyReportContent, getGitHubFileSha, createOrUpdateGitHubFile } from '../github.js';
import { storeInKV } from '../kv.js';
import { marked } from '../marked.esm.js';
import { callChatAPI } from '../chatapi.js'; // 导入 callChatAPI
import { getSummarizationSimplifyPrompt } from "../prompt/summarizationSimplifyPrompt";
+import { getAppUrl } from '../appUrl.js';
+/**
+ * 处理生成RSS内容的请求(从daily目录读取,生成AI内容,写入rss目录)
+ * @param {Request} request - 请求对象
+ * @param {object} env - 环境对象
+ * @returns {PromisePlease contact the administrator.