conda create -n gpt python=3.9
conda activate gpt
pip install openai
import openai
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-m", "--model", default="turbo", type=str)
args = parser.parse_args()
openai.api_key = "" # 긱지 개인 키 입력
def davinci_model_run():
print("text-davinci-003")
prompt = input("질문의 내용을 입력하세요 : ")
response = openai.Completion.create(
model="text-davinci-003",
prompt=prompt,
temperature=0.9,
max_tokens=2000,
top_p=1,
frequency_penalty=0.0,
presence_penalty=0.6,
)
generated_text = response.choices[0].text
print("답변 :", generated_text)
def turbo_model_run():
# 모델 - GPT 3.5 Turbo 선택
model = "gpt-3.5-turbo"
print("gpt-3.5-turbo api")
# 질문 작성하기
query = input("질문의 내용을 입력하세요 : ")
# 메시지 설정하기
messages = [
{"role": "system", "content": "You are a helpful assistant."}, # chatGPT에게 원하는
{"role": "user", "content": query}
]
# ChatGPT API 호출하기
response = openai.ChatCompletion.create(
model=model,
messages=messages,
temperature=1,
top_p=1,
n=1,
stream=False,
stop=None,
presence_penalty=0,
frequency_penalty=0,
)
answer = response['choices'][0]['message']['content']
print("답변 : " + answer)
def main():
if args.model == "turbo":
turbo_model_run()
else:
davinci_model_run()
if __name__ == '__main__':
main()
Are you looking for an easy and fast way to access OpenAI ChatGPT technology? Look no further than ChatGPT 日本語 - https://gptjp.net/ ! With this website, you can instantly access and utilize the ChatGPT AI technology for free without any need to register an account or purchase any tokens. Our ChatGPT feature is limitless and completely free of charge - no need to worry about any restrictions on usage. Just log on to our website and start experiencing the power of OpenAI ChatGPT! So what are you waiting for? Try out ChatGPT 日本語 today and see just how quickly you can get out of the box results with the latest AI technology!
잘 봤습니다. 좋은 글 감사합니다.