└── AI └── ai.py /AI/ai.py: -------------------------------------------------------------------------------- 1 | import openai 2 | openai.api_key="" 3 | def chat_with_gpt(prompt): 4 | response=openai.ChatCompletion.create( 5 | model="gpt-3.5-turbo", 6 | messages=[{"role":"user","content":prompt}] 7 | ) 8 | return response.choices[0].message.content.strip() 9 | 10 | if __name__ == "__main__": 11 | while True: 12 | user_input = input("You: ") 13 | if user_input.lower() in ["quit","exit","bye"]: 14 | break 15 | 16 | response = chat_with_gpt(user_input) 17 | print("Chatbot:", response) --------------------------------------------------------------------------------