import openai
 
# ChatGPT API anahtarınızı girin
openai.api_key = "burada key no var"
 
# xxx.txt dosyasını okuyun ve metni değişkenine atama yapar
with open(r"sentences.txt", "r") as file:
    sentences  = file.read().split('. ')
 
 
# Cümleler için döngü oluşturun
for sentence in sentences:
  # ChatGPT ile metin üzerinde çalışın
  model_engine = "text-davinci-002"
  prompt = (f"{sentence} hakkında 250 kelimelik makale yazınız.")
 
  completions = openai.Completion.create(
      engine=model_engine,
      prompt=prompt,
      max_tokens=1024,
      n=1,
      temperature=0.5,
  )
 
  # Makaleyi yazdırın
  with open(sentence+ '.txt', 'w') as f:
    f.write(completions.choices[0].text)