Yasu777 commited on
Commit
cecb5a1
·
1 Parent(s): cbb00b4

Update third.py

Browse files
Files changed (1) hide show
  1. third.py +12 -1
third.py CHANGED
@@ -89,12 +89,23 @@ async def main(editable_output2, keyword_id):
89
  # 記事タイトルに関する指示
90
  instructions.append(f'1. "{h1_text}"に関する導入文を作成してください。')
91
 
 
 
 
92
  # 各見出しと小見出しに関する指示
93
  for idx, h2_text in enumerate(h2_texts):
94
  h3_for_this_h2 = [h3 for h3 in h3_texts if h3.startswith(f"{idx+1}-")]
95
  instructions.append(f'{idx+2}. "{h2_text}"に関する導入文を作成してください。この導入文は、以下の小見出しの内容を考慮してください:{"、".join(h3_for_this_h2)}。')
96
  for h3 in h3_for_this_h2:
97
- instructions.append(f'次に、"{h3}"に関する詳細な内容記述してください。')
 
 
 
 
 
 
 
 
98
 
99
  # 記事全体のまとめに関する指示
100
  instructions.append(f'最後に、記事全体のまとめとして、<h2>まとめ</h2>を記述してください。')
 
89
  # 記事タイトルに関する指示
90
  instructions.append(f'1. "{h1_text}"に関する導入文を作成してください。')
91
 
92
+ # research_summaryを文単位に分割
93
+ sentences = research_summary.split('。')
94
+
95
  # 各見出しと小見出しに関する指示
96
  for idx, h2_text in enumerate(h2_texts):
97
  h3_for_this_h2 = [h3 for h3 in h3_texts if h3.startswith(f"{idx+1}-")]
98
  instructions.append(f'{idx+2}. "{h2_text}"に関する導入文を作成してください。この導入文は、以下の小見出しの内容を考慮してください:{"、".join(h3_for_this_h2)}。')
99
  for h3 in h3_for_this_h2:
100
+ # h3のテキストをキーワードとして使用し、する探す
101
+ related_sentences = [sentence for sentence in sentences if h3 in sentence]
102
+
103
+ # 関連する文を基に、<h3>の内容に関する記事本文を生成
104
+ if related_sentences:
105
+ content_for_h3 = "。".join(related_sentences) + "。"
106
+ instructions.append(f'次に、"{h3}"に関する詳細な内容として、以下の情報を記述してください:{content_for_h3}')
107
+ else:
108
+ instructions.append(f'次に、"{h3}"に関する詳細な内容を記述してください。')
109
 
110
  # 記事全体のまとめに関する指示
111
  instructions.append(f'最後に、記事全体のまとめとして、<h2>まとめ</h2>を記述してください。')