Skip to content

Commit 75eabb4

Browse files
Create README.md
1 parent 0c4c3f9 commit 75eabb4

File tree

1 file changed

+143
-0
lines changed

1 file changed

+143
-0
lines changed

β€ŽREADME.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# πŸ€– AI Chatbot on Python
2+
3+
Welcome to **Markhor AI Chatbot**, a Python-based chatbot powered by **ChatGPT-4**! πŸš€
4+
This chatbot is designed to have intelligent conversations using OpenAI's API.
5+
6+
---
7+
8+
## 🌟 Features
9+
10+
βœ… Uses **GPT-4 API** for natural conversations
11+
βœ… Interactive **CLI chat interface**
12+
βœ… Secure API key handling using `.gitignore`
13+
βœ… Simple and **easy-to-use Python script**
14+
βœ… Exit command (`exit`, `quit`, `bye`) to stop the chat
15+
16+
---
17+
18+
## πŸ› οΈ Installation
19+
20+
### **1️⃣ Clone the Repository**
21+
```sh
22+
git clone https://github.com/Muawiya-contact/AI-Chatbot-on-Python.git
23+
cd AI-Chatbot-on-Python
24+
```
25+
26+
### **2️⃣ Create a Virtual Environment (Recommended)**
27+
```sh
28+
python -m venv venv
29+
source venv/bin/activate # On Windows use: venv\Scripts\activate
30+
```
31+
32+
### **3️⃣ Install Required Dependencies**
33+
```sh
34+
pip install -r requirements.txt
35+
```
36+
37+
---
38+
39+
## πŸ”‘ Secure API Key Handling
40+
41+
**DO NOT** hardcode your API key in the script! Instead, follow these steps:
42+
43+
1. **Create a `config.py` file** in the project directory:
44+
```python
45+
API_KEY = "your-secret-api-key"
46+
```
47+
2. **Add `config.py` to `.gitignore`** to prevent it from being uploaded:
48+
```
49+
config.py
50+
```
51+
3. **Now, import the key securely in your script:**
52+
```python
53+
from config import API_KEY
54+
```
55+
56+
---
57+
58+
## πŸš€ Usage
59+
60+
1. **Run the chatbot**:
61+
```sh
62+
python chatbot.py
63+
```
64+
65+
2. **Chat with Markhor AI**:
66+
```
67+
Hi there! I am Markhor, the AI chatbot powered by ChatGPT-4, represented by Coding Moves.
68+
How can I assist you today?
69+
70+
You: Hello!
71+
Markhor AI: Hi! How can I help you today?
72+
```
73+
74+
3. **Exit the chat** by typing: `"exit"`, `"quit"`, or `"bye"`.
75+
76+
---
77+
78+
## πŸ“Œ Example Code
79+
80+
```python
81+
import requests
82+
from config import API_KEY # Secure API key handling
83+
84+
API_URL = "https://api.openai.com/v1/chat/completions"
85+
86+
def chat_with_ai(user_message):
87+
headers = {
88+
"Authorization": f"Bearer {API_KEY}",
89+
"Content-Type": "application/json"
90+
}
91+
data = {
92+
"model": "gpt-4",
93+
"messages": [{"role": "user", "content": user_message}]
94+
}
95+
response = requests.post(API_URL, json=data, headers=headers)
96+
return response.json()["choices"][0]["message"]["content"] if response.status_code == 200 else "Error occurred!"
97+
98+
# Run chatbot
99+
while True:
100+
user_input = input("You: ")
101+
if user_input.lower() in ["exit", "quit", "bye"]:
102+
print("Markhor AI: Goodbye!")
103+
break
104+
print("Markhor AI:", chat_with_ai(user_input))
105+
```
106+
107+
---
108+
109+
## πŸš€ How to Contribute
110+
111+
πŸ”Ή Fork the repository
112+
πŸ”Ή Create a new branch (`git checkout -b feature-branch`)
113+
πŸ”Ή Make changes and commit (`git commit -m "Added new feature"`)
114+
πŸ”Ή Push to the branch (`git push origin feature-branch`)
115+
πŸ”Ή Open a **Pull Request**
116+
117+
Contributions are welcome! Feel free to improve and enhance the chatbot.
118+
119+
---
120+
121+
## πŸ“ License
122+
123+
This project is open-source and available under the **MIT License**.
124+
125+
---
126+
127+
## πŸ’‘ Developed By
128+
129+
πŸ‘¨β€πŸ’» **Muawiya**
130+
πŸ”— [GitHub](https://github.com/Muawiya-contact)
131+
πŸ“’ **Powered by Coding Moves**
132+
133+
---
134+
135+
## 🎯 Support
136+
137+
⭐ **Star** this repository if you found it helpful!
138+
πŸ“’ Share it with others!
139+
πŸ’¬ Feel free to open an **issue** for suggestions or bugs!
140+
141+
---
142+
143+
**Happy Coding! πŸš€πŸ€–**

0 commit comments

Comments
Β (0)