Yasu777 commited on
Commit
5601f03
·
1 Parent(s): 24ef813

Update third.py

Browse files
Files changed (1) hide show
  1. third.py +19 -2
third.py CHANGED
@@ -17,6 +17,12 @@ openai.api_key = os.getenv("OPENAI_API_KEY")
17
  GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
18
  CUSTOM_SEARCH_ENGINE_ID = os.getenv("CUSTOM_SEARCH_ENGINE_ID")
19
 
 
 
 
 
 
 
20
  async def main(editable_output2, keyword_id):
21
  search = GoogleSearchAPIWrapper(google_cse_id=CUSTOM_SEARCH_ENGINE_ID, google_api_key=GOOGLE_API_KEY)
22
 
@@ -66,7 +72,12 @@ async def main(editable_output2, keyword_id):
66
  instruction = f"Can you research {purpose} and include specific details such as names, ages, careers, product names, service names, store names, locations, times, and any relevant numerical data or statistics in your response?"
67
 
68
  # Run the instruction
69
- output_text = agent.run(instruction)
 
 
 
 
 
70
 
71
  # Prepare the system message
72
  system_message = {
@@ -75,9 +86,10 @@ async def main(editable_output2, keyword_id):
75
  }
76
 
77
  # Prepare the user message
 
78
  user_message = {
79
  "role": "user",
80
- "content": f'"{h1_text}"という記事タイトルに沿った導入文を日本語で作成してください。その後、各見出し"{", ".join(h2_texts)}"についての導入文を作成してください。導入文はそれぞれの見出しの直下にある"{", ".join(h3_texts)}"の内容を考慮に入れて作成してください。その後、"{", ".join(h3_texts)}"についての詳細な本文を提供してください。各セクションは、読者の興味を引き、記事の主題を明確に示すものであるべきです。最後に、記事全体のまとめ、<h2>まとめ</h2>としてクローズしてください。以下に取得した情報を示します:{output_text}'
81
  }
82
 
83
  # Generate a new text using the ChatCompletion API
@@ -97,3 +109,8 @@ async def main(editable_output2, keyword_id):
97
 
98
  # Print the generated message
99
  print(result)
 
 
 
 
 
 
17
  GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
18
  CUSTOM_SEARCH_ENGINE_ID = os.getenv("CUSTOM_SEARCH_ENGINE_ID")
19
 
20
+ # 追加: 実行された指示を追跡するリスト
21
+ executed_instructions = []
22
+
23
+ # 追加: 調査結果を保存するリスト
24
+ research_results = []
25
+
26
  async def main(editable_output2, keyword_id):
27
  search = GoogleSearchAPIWrapper(google_cse_id=CUSTOM_SEARCH_ENGINE_ID, google_api_key=GOOGLE_API_KEY)
28
 
 
72
  instruction = f"Can you research {purpose} and include specific details such as names, ages, careers, product names, service names, store names, locations, times, and any relevant numerical data or statistics in your response?"
73
 
74
  # Run the instruction
75
+ if instruction not in executed_instructions:
76
+ output_text = agent.run(instruction)
77
+ executed_instructions.append(instruction)
78
+ research_results.append(output_text)
79
+ else:
80
+ output_text = "This instruction has already been executed."
81
 
82
  # Prepare the system message
83
  system_message = {
 
86
  }
87
 
88
  # Prepare the user message
89
+ research_summary = "\n".join(research_results) # 調査結果をまとめる
90
  user_message = {
91
  "role": "user",
92
+ "content": f'"{h1_text}"という記事タイトルに沿った導入文を日本語で作成してください。その後、各見出し"{", ".join(h2_texts)}"についての導入文を作成してください。導入文はそれぞれの見出しの直下にある"{", ".join(h3_texts)}"の内容を考慮に入れて作成してください。その後、"{", ".join(h3_texts)}"についての詳細な本文を提供してください。各セクションは、読者の興味を引き、記事の主題を明確に示すものであるべきです。最後に、記事全体のまとめ、<h2>まとめ</h2>としてクローズしてください。以下に取得した情報を示します:{research_summary}'
93
  }
94
 
95
  # Generate a new text using the ChatCompletion API
 
109
 
110
  # Print the generated message
111
  print(result)
112
+
113
+ # 以下の部分は、このスクリプトを実際に実行するためのものです。
114
+ # このスクリプトを直接実行する場合は、この部分をコメントアウトしてください。
115
+ # if __name__ == "__main__":
116
+ # asyncio.run(main("editable_output2のサンプルテキスト", "keyword_idのサンプル"))