-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboyfrndai.py
37 lines (29 loc) · 1.09 KB
/
boyfrndai.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
36
37
import openai
def boybrend_ai_chat():
# Set your OpenAI API key
openai.api_key = "your-openai-api-key"
print("Boybrend.ai Chatbot Initialized!")
print("Type 'exit' to end the conversation.")
while True:
# User input
user_input = input("You: ")
if user_input.lower() == 'exit':
print("Boybrend.ai: Goodbye!")
break
try:
# OpenAI GPT API request
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are Boybrend.ai, a helpful and friendly AI chatbot."},
{"role": "user", "content": user_input}
]
)
# Get the assistant's response
reply = response['choices'][0]['message']['content']
print(f"Boybrend.ai: {reply}")
except Exception as e:
print("Boybrend.ai: Sorry, something went wrong. Please try again later.")
print(f"Error: {e}")
if __name__ == "__main__":
boybrend_ai_chat()