Update
This commit is contained in:
		@@ -14,7 +14,7 @@ export async function openAI_ClassifyFeed(title: string): Promise<string> {
 | 
				
			|||||||
  if (!title || title.trim() === "") {
 | 
					  if (!title || title.trim() === "") {
 | 
				
			||||||
    throw new Error("Feed title is required for classification");
 | 
					    throw new Error("Feed title is required for classification");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  const prompt = `
 | 
					  const prompt = `
 | 
				
			||||||
以下のRSSフィードのタイトルを見て、適切なトピックカテゴリに分類してください。
 | 
					以下のRSSフィードのタイトルを見て、適切なトピックカテゴリに分類してください。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -34,24 +34,26 @@ export async function openAI_ClassifyFeed(title: string): Promise<string> {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
分類結果を上記カテゴリのいずれか1つだけ返してください。
 | 
					分類結果を上記カテゴリのいずれか1つだけ返してください。
 | 
				
			||||||
`;
 | 
					`;
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  try {
 | 
					  try {
 | 
				
			||||||
    const response = await openai.chat.completions.create({
 | 
					    const response = await openai.chat.completions.create({
 | 
				
			||||||
      model: config.openai.modelName,
 | 
					      model: config.openai.modelName,
 | 
				
			||||||
      messages: [{ role: "user", content: prompt.trim() }],
 | 
					      messages: [{ role: "user", content: prompt.trim() }],
 | 
				
			||||||
      temperature: 0.3,
 | 
					      temperature: 0.3,
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    const category = response.choices[0]?.message?.content?.trim();
 | 
					    const category = response.choices[0]?.message?.content?.trim();
 | 
				
			||||||
    if (!category) {
 | 
					    if (!category) {
 | 
				
			||||||
      console.warn("OpenAI returned empty category, using default");
 | 
					      console.warn("OpenAI returned empty category, using default");
 | 
				
			||||||
      return "その他";
 | 
					      return "その他";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    return category;
 | 
					    return category;
 | 
				
			||||||
  } catch (error) {
 | 
					  } catch (error) {
 | 
				
			||||||
    console.error("Error classifying feed:", error);
 | 
					    console.error("Error classifying feed:", error);
 | 
				
			||||||
    throw new Error(`Failed to classify feed: ${error instanceof Error ? error.message : 'Unknown error'}`);
 | 
					    throw new Error(
 | 
				
			||||||
 | 
					      `Failed to classify feed: ${error instanceof Error ? error.message : "Unknown error"}`,
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -62,17 +64,19 @@ export async function openAI_GeneratePodcastContent(
 | 
				
			|||||||
  if (!title || title.trim() === "") {
 | 
					  if (!title || title.trim() === "") {
 | 
				
			||||||
    throw new Error("Feed title is required for podcast content generation");
 | 
					    throw new Error("Feed title is required for podcast content generation");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  if (!items || items.length === 0) {
 | 
					  if (!items || items.length === 0) {
 | 
				
			||||||
    throw new Error("At least one news item is required for podcast content generation");
 | 
					    throw new Error(
 | 
				
			||||||
 | 
					      "At least one news item is required for podcast content generation",
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  // Validate items
 | 
					  // Validate items
 | 
				
			||||||
  const validItems = items.filter(item => item.title && item.link);
 | 
					  const validItems = items.filter((item) => item.title && item.link);
 | 
				
			||||||
  if (validItems.length === 0) {
 | 
					  if (validItems.length === 0) {
 | 
				
			||||||
    throw new Error("No valid news items found (title and link required)");
 | 
					    throw new Error("No valid news items found (title and link required)");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  const prompt = `
 | 
					  const prompt = `
 | 
				
			||||||
あなたはプロのポッドキャスタです。以下に示すフィードタイトルに基づき、そのトピックに関する詳細なポッドキャスト原稿を作成してください。
 | 
					あなたはプロのポッドキャスタです。以下に示すフィードタイトルに基づき、そのトピックに関する詳細なポッドキャスト原稿を作成してください。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -82,30 +86,33 @@ export async function openAI_GeneratePodcastContent(
 | 
				
			|||||||
${validItems.map((item, i) => `${i + 1}. ${item.title} - ${item.link}`).join("\n")}
 | 
					${validItems.map((item, i) => `${i + 1}. ${item.title} - ${item.link}`).join("\n")}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
以下の要件を満たしてください:
 | 
					以下の要件を満たしてください:
 | 
				
			||||||
1. 各ニュース記事の内容を要約し、関連性を説明してください
 | 
					1. もし英単語が含まれている場合は、すべてカタカナに変換してください (例: "Google" → "グーグル")
 | 
				
			||||||
2. 視聴者にとっての価値や興味ポイントを解説してください
 | 
					2. 各ニュース記事の内容を要約し、関連性を説明してください
 | 
				
			||||||
3. 約1000文字〜1500文字程度の長さにしてください
 | 
					3. 視聴者にとっての価値や興味ポイントを解説してください
 | 
				
			||||||
4. 自然な日本語の口語表現を使ってください
 | 
					4. 約1000文字〜1500文字程度の長さにしてください
 | 
				
			||||||
5. トピック全体のまとめで締めくくってください
 | 
					5. 自然な日本語の口語表現を使ってください
 | 
				
			||||||
 | 
					6. トピック全体のまとめで締めくくってください
 | 
				
			||||||
 | 
					
 | 
				
			||||||
この構成でポッドキャスト原稿を書いてください。
 | 
					この構成でポッドキャスト原稿を書いてください。
 | 
				
			||||||
`;
 | 
					`;
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  try {
 | 
					  try {
 | 
				
			||||||
    const response = await openai.chat.completions.create({
 | 
					    const response = await openai.chat.completions.create({
 | 
				
			||||||
      model: config.openai.modelName,
 | 
					      model: config.openai.modelName,
 | 
				
			||||||
      messages: [{ role: "user", content: prompt.trim() }],
 | 
					      messages: [{ role: "user", content: prompt.trim() }],
 | 
				
			||||||
      temperature: 0.7,
 | 
					      temperature: 0.7,
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    const scriptText = response.choices[0]?.message?.content?.trim();
 | 
					    const scriptText = response.choices[0]?.message?.content?.trim();
 | 
				
			||||||
    if (!scriptText) {
 | 
					    if (!scriptText) {
 | 
				
			||||||
      throw new Error("OpenAI returned empty podcast content");
 | 
					      throw new Error("OpenAI returned empty podcast content");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    return scriptText;
 | 
					    return scriptText;
 | 
				
			||||||
  } catch (error) {
 | 
					  } catch (error) {
 | 
				
			||||||
    console.error("Error generating podcast content:", error);
 | 
					    console.error("Error generating podcast content:", error);
 | 
				
			||||||
    throw new Error(`Failed to generate podcast content: ${error instanceof Error ? error.message : 'Unknown error'}`);
 | 
					    throw new Error(
 | 
				
			||||||
 | 
					      `Failed to generate podcast content: ${error instanceof Error ? error.message : "Unknown error"}`,
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user