Spaces:
Sleeping
Sleeping
Update third.py
Browse files
third.py
CHANGED
|
@@ -87,7 +87,7 @@ async def main(editable_output2, keyword_id):
|
|
| 87 |
# Prepare the system message
|
| 88 |
system_message = {
|
| 89 |
"role": "system",
|
| 90 |
-
"content": "あなたはプロのライターです。"
|
| 91 |
}
|
| 92 |
|
| 93 |
# Prepare the user message
|
|
@@ -95,7 +95,7 @@ async def main(editable_output2, keyword_id):
|
|
| 95 |
instructions = []
|
| 96 |
|
| 97 |
# 記事タイトルに関する指示
|
| 98 |
-
instructions.append(f'1. "{h1_text}"に関する導入文を作成してください。直接的なコピーまたは近いフレーズを避けて、オリジナルな内容にしてください。')
|
| 99 |
|
| 100 |
# research_summaryを文単位に分割
|
| 101 |
sentences = research_summary.split('。')
|
|
@@ -103,7 +103,7 @@ async def main(editable_output2, keyword_id):
|
|
| 103 |
# 各見出しと小見出しに関する指示
|
| 104 |
for idx, h2_text in enumerate(h2_texts):
|
| 105 |
h3_for_this_h2 = [h3 for h3 in h3_texts if h3.startswith(f"{idx+1}-")]
|
| 106 |
-
instructions.append(f'{idx+2}. "{h2_text}"に関する導入文を作成してください。この導入文は、以下の小見出しの内容を考慮してください:{"、".join(h3_for_this_h2)}。直接的なコピーまたは近いフレーズを避けて、オリジナルな内容にしてください。')
|
| 107 |
for h3 in h3_for_this_h2:
|
| 108 |
# h3のテキストをキーワードとして使用し、関連する文を探す
|
| 109 |
related_sentences = [sentence for sentence in sentences if h3 in sentence]
|
|
@@ -111,9 +111,9 @@ async def main(editable_output2, keyword_id):
|
|
| 111 |
# 関連する文を基に、<h3>の内容に関する記事本文を生成
|
| 112 |
if related_sentences:
|
| 113 |
content_for_h3 = "。".join(related_sentences) + "。"
|
| 114 |
-
instructions.append(f'次に、"{h3}"に関する詳細な内容として、以下の情報を記述してください:{content_for_h3} ここでも、オリジナルな内容を心がけてください。')
|
| 115 |
else:
|
| 116 |
-
instructions.append(f'次に、"{h3}"に関する詳細な内容を記述してください。オリジナルな内容を心がけてください。')
|
| 117 |
|
| 118 |
|
| 119 |
user_message = {
|
|
@@ -126,7 +126,6 @@ async def main(editable_output2, keyword_id):
|
|
| 126 |
model="gpt-3.5-turbo-16k",
|
| 127 |
messages=[system_message, user_message],
|
| 128 |
temperature=0.7,
|
| 129 |
-
suffix="この回答は日本語でお願いします。"
|
| 130 |
)
|
| 131 |
result = response.choices[0]["message"]["content"]
|
| 132 |
|
|
|
|
| 87 |
# Prepare the system message
|
| 88 |
system_message = {
|
| 89 |
"role": "system",
|
| 90 |
+
"content": "あなたはプロのライターです。すべての回答を日本語でお願いします。"
|
| 91 |
}
|
| 92 |
|
| 93 |
# Prepare the user message
|
|
|
|
| 95 |
instructions = []
|
| 96 |
|
| 97 |
# 記事タイトルに関する指示
|
| 98 |
+
instructions.append(f'1. "{h1_text}"に関する導入文を日本語で作成してください。直接的なコピーまたは近いフレーズを避けて、オリジナルな内容にしてください。')
|
| 99 |
|
| 100 |
# research_summaryを文単位に分割
|
| 101 |
sentences = research_summary.split('。')
|
|
|
|
| 103 |
# 各見出しと小見出しに関する指示
|
| 104 |
for idx, h2_text in enumerate(h2_texts):
|
| 105 |
h3_for_this_h2 = [h3 for h3 in h3_texts if h3.startswith(f"{idx+1}-")]
|
| 106 |
+
instructions.append(f'{idx+2}. "{h2_text}"に関する導入文を日本語で作成してください。この導入文は、以下の小見出しの内容を考慮してください:{"、".join(h3_for_this_h2)}。直接的なコピーまたは近いフレーズを避けて、オリジナルな内容にしてください。')
|
| 107 |
for h3 in h3_for_this_h2:
|
| 108 |
# h3のテキストをキーワードとして使用し、関連する文を探す
|
| 109 |
related_sentences = [sentence for sentence in sentences if h3 in sentence]
|
|
|
|
| 111 |
# 関連する文を基に、<h3>の内容に関する記事本文を生成
|
| 112 |
if related_sentences:
|
| 113 |
content_for_h3 = "。".join(related_sentences) + "。"
|
| 114 |
+
instructions.append(f'次に、"{h3}"に関する詳細な内容として、以下の情報を日本語で記述してください:{content_for_h3} ここでも、オリジナルな内容を心がけてください。')
|
| 115 |
else:
|
| 116 |
+
instructions.append(f'次に、"{h3}"に関する詳細な内容を日本語で記述してください。オリジナルな内容を心がけてください。')
|
| 117 |
|
| 118 |
|
| 119 |
user_message = {
|
|
|
|
| 126 |
model="gpt-3.5-turbo-16k",
|
| 127 |
messages=[system_message, user_message],
|
| 128 |
temperature=0.7,
|
|
|
|
| 129 |
)
|
| 130 |
result = response.choices[0]["message"]["content"]
|
| 131 |
|