├── README.md └── Python /README.md: -------------------------------------------------------------------------------- 1 | # GPT-Based-Chatbot 2 | Create a chatbot using GPT API that interacts with users. Add integration with platforms like Telegram or Discord 3 | -------------------------------------------------------------------------------- /Python: -------------------------------------------------------------------------------- 1 | import openai 2 | 3 | openai.api_key = "your_openai_api_key" 4 | 5 | def chat_with_gpt(prompt): 6 | response = openai.ChatCompletion.create( 7 | model="gpt-3.5-turbo", 8 | messages=[{"role": "user", "content": prompt}], 9 | ) 10 | return response['choices'][0]['message']['content'] 11 | 12 | while True: 13 | user_input = input("You: ") 14 | if user_input.lower() == "exit": 15 | break 16 | print("Bot:", chat_with_gpt(user_input)) 17 | --------------------------------------------------------------------------------