-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchatgpt.py
35 lines (30 loc) · 849 Bytes
/
chatgpt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Uhmm A simple script that uses the openai wrapper
# You can use it however you want
# Author : Yoru
# Insta : soooricky
# twitter : chimshoubae
# Github : Yorubae
import openai
from dotenv import load_dotenv
import os
load_dotenv()
api_key = os.environ["apiID"]
model = "gpt-3.5-turbo"
print("Chatgpt enterned the chat!")
while True:
try:
query = input("You: ")
if query == "exit":
break
response = openai.ChatCompletion.create(
api_key=api_key,
model=model,
messages=[
{"role": "system", "content": "Say hello to chatgpt!"},
{"role": "user", "content": query},
],
)
print(f"Chatgpt: {response['choices'][0]['message']['content']}")
except Exception as e:
print(f"Error: {e}")
print("Quiting")