Monday, August 28, 2023

Use ChatGPT with Python

# API Key created on 28th August, 2023, valid for 3 months

# Email: bt25.bcrs@gmail.com Password: Bantuda25New

# Verification Mobile: 9847578833

# https://copyassignment.com/create-your-own-chatgpt-with-python/


import openai


openai.api_key = "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"


while True:

  model_engine = "text-davinci-003"

  prompt = input('Enter new prompt: ')


  if 'exit' in prompt or 'quit' in prompt:

    break


  completion = openai.Completion.create(

    engine=model_engine, prompt=prompt,

    max_tokens=1024, n=1, stop=None,

    temperature=0.5,

  )


  response = completion.choices[0].text

  print(response)


No comments:

Post a Comment