Skip to content

Markhor AI Chatbot πŸ€– A smart AI chatbot powered by ChatGPT-4, represented by Coding Moves. This chatbot interacts with users in real-time and provides intelligent responses. Features βœ… Interactive AI-powered chatbot βœ… Uses OpenAI API (GPT-4) βœ… Secure API key handling with .gitignore βœ… Continuous chat loop with an exit option

Notifications You must be signed in to change notification settings

Muawiya-contact/AI-Chatbot-on-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– AI Chatbot on Python

Welcome to Markhor AI Chatbot, a Python-based chatbot powered by ChatGPT-4! πŸš€
This chatbot is designed to have intelligent conversations using OpenAI's API.


🌟 Features

βœ… Uses GPT-4 API for natural conversations
βœ… Interactive CLI chat interface
βœ… Secure API key handling using .gitignore
βœ… Simple and easy-to-use Python script
βœ… Exit command (exit, quit, bye) to stop the chat


πŸ› οΈ Installation

1️⃣ Clone the Repository

git clone https://github.com/Muawiya-contact/AI-Chatbot-on-Python.git
cd AI-Chatbot-on-Python

2️⃣ Create a Virtual Environment (Recommended)

python -m venv venv
source venv/bin/activate  # On Windows use: venv\Scripts\activate

3️⃣ Install Required Dependencies

pip install -r requirements.txt

πŸ”‘ Secure API Key Handling

DO NOT hardcode your API key in the script! Instead, follow these steps:

  1. Create a config.py file in the project directory:
    API_KEY = "your-secret-api-key"
  2. Add config.py to .gitignore to prevent it from being uploaded:
    config.py
    
  3. Now, import the key securely in your script:
    from config import API_KEY

πŸš€ Usage

  1. Run the chatbot:

    python chatbot.py
  2. Chat with Markhor AI:

    Hi there! I am Markhor, the AI chatbot powered by ChatGPT-4, represented by Coding Moves.
    How can I assist you today?
    
    You: Hello!
    Markhor AI: Hi! How can I help you today?
    
  3. Exit the chat by typing: "exit", "quit", or "bye".


πŸ“Œ Example Code

import requests
from config import API_KEY  # Secure API key handling

API_URL = "https://api.openai.com/v1/chat/completions"

def chat_with_ai(user_message):
    headers = {
        "Authorization": f"Bearer {API_KEY}",
        "Content-Type": "application/json"
    }
    data = {
        "model": "gpt-4",
        "messages": [{"role": "user", "content": user_message}]
    }
    response = requests.post(API_URL, json=data, headers=headers)
    return response.json()["choices"][0]["message"]["content"] if response.status_code == 200 else "Error occurred!"

# Run chatbot
while True:
    user_input = input("You: ")
    if user_input.lower() in ["exit", "quit", "bye"]:
        print("Markhor AI: Goodbye!")
        break
    print("Markhor AI:", chat_with_ai(user_input))

πŸš€ How to Contribute

πŸ”Ή Fork the repository
πŸ”Ή Create a new branch (git checkout -b feature-branch)
πŸ”Ή Make changes and commit (git commit -m "Added new feature")
πŸ”Ή Push to the branch (git push origin feature-branch)
πŸ”Ή Open a Pull Request

Contributions are welcome! Feel free to improve and enhance the chatbot.


πŸ“ License

This project is open-source and available under the MIT License.


πŸ’‘ Developed By

πŸ‘¨β€πŸ’» Muawiya
πŸ”— GitHub
πŸ“’ Powered by Coding Moves


🎯 Support

⭐ Star this repository if you found it helpful!
πŸ“’ Share it with others!
πŸ’¬ Feel free to open an issue for suggestions or bugs!


Happy Coding! πŸš€πŸ€–

About

Markhor AI Chatbot πŸ€– A smart AI chatbot powered by ChatGPT-4, represented by Coding Moves. This chatbot interacts with users in real-time and provides intelligent responses. Features βœ… Interactive AI-powered chatbot βœ… Uses OpenAI API (GPT-4) βœ… Secure API key handling with .gitignore βœ… Continuous chat loop with an exit option

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages