├── system.txt ├── Screenshot 2024-08-11 132115.png ├── Screenshot 2024-08-11 132203.png ├── README.md ├── brain.py └── ui.py /system.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Screenshot 2024-08-11 132115.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AnubhavChaturvedi-GitHub/LLAMA3-Chatbot/HEAD/Screenshot 2024-08-11 132115.png -------------------------------------------------------------------------------- /Screenshot 2024-08-11 132203.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AnubhavChaturvedi-GitHub/LLAMA3-Chatbot/HEAD/Screenshot 2024-08-11 132203.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LLAMA3 Chatbot 2 | [Download](https://drive.google.com/file/d/1EiA6V2H5FG0Q-GTYpyMv0P5zaqKg4OcJ/view?usp=sharing) 3 | 4 | Welcome to the Net Hi-Tech Chatbot project! This chatbot is powered by Llama3 and offers a dynamic, interactive, and sci-fi inspired user experience. 5 | 6 | 7 |  8 | 9 |  10 | 11 | 12 | ## Features 13 | 14 | - **Login System**: Secure login with credentials. 15 | - **Chat Interface**: Sci-fi themed chat interface with customizable colors and animations. 16 | - **Conversation History**: Manage and display previous chat histories. 17 | - **Dynamic UI**: Engaging and modern design with color gradients and text animations. 18 | - **File Management**: Save and load chat history in .rtx format. 19 | - **AI Integration**: Powered by Llama3 for intelligent responses. 20 | 21 | ## Installation 22 | 23 | ### Prerequisites 24 | 25 | Ensure you have the following installed: 26 | - Python 3.11.4 27 | - PyQt5 28 | - Llama3 29 | 30 | ### Install Dependencies 31 | 32 | Clone this repository and install the required Python packages: 33 | 34 | ```bash 35 | git clone https://github.com/yourusername/net-hi-tech-chatbot.git 36 | cd net-hi-tech-chatbot 37 | pip install -r requirements.txt 38 | ``` 39 | 40 | ### Setting Up Llama3 41 | 42 | Ensure that Llama3 is properly configured in your environment. You may need to follow the Llama3 documentation for setup details. 43 | 44 | ## Usage 45 | 46 | ### Running the Application 47 | 48 | To start the application, run the following command: 49 | 50 | ```bash 51 | python main.py 52 | ``` 53 | -------------------------------------------------------------------------------- /brain.py: -------------------------------------------------------------------------------- 1 | 2 | from webscout import LLAMA3 as brain 3 | from rich import print 4 | import os 5 | 6 | # Define file paths 7 | history_file = r"C:\Users\chatu\OneDrive\Desktop\Chatbot\system.txt" 8 | 9 | def load_history(): 10 | if os.path.exists(history_file): 11 | with open(history_file, 'r') as file: 12 | return file.read() 13 | return "" 14 | 15 | def save_history(history): 16 | with open(history_file, 'w') as file: 17 | file.write(history) 18 | 19 | # Load existing history 20 | conversation_history = load_history() 21 | 22 | # Initialize the AI 23 | ai = brain( 24 | is_conversation=True, # AI will remember conversations 25 | max_tokens=800, 26 | timeout=30, 27 | intro=None, 28 | filepath=None, # Memory file not used as we handle it manually 29 | update_file=False, # No need to update the memory file 30 | proxies={}, 31 | history_offset=10250, # Use a high context window model 32 | act=None, 33 | model="llama3-8b", 34 | system="You are a Helpful AI" 35 | ) 36 | 37 | def Main_Brain(text): 38 | conversation_history = load_history() 39 | # Append the prompt to the conversation history 40 | conversation_history += f"\nUser: {text}" 41 | 42 | # Generate the full prompt including the conversation history 43 | full_prompt = conversation_history + "\nAI:" 44 | 45 | # Get the AI's response 46 | response_chunks = [] 47 | for chunk in ai.chat(full_prompt): 48 | response_chunks.append(chunk) 49 | print(chunk, end="", flush=True) 50 | 51 | # Combine the response chunks into a single response 52 | response_text = "".join(response_chunks) 53 | 54 | # Append the AI's response to the conversation history 55 | conversation_history += f"\nAI: {response_text}" 56 | 57 | # Check if the user input contains "remember this" 58 | if "remember this" in text.lower(): 59 | # Save the updated conversation history 60 | save_history(conversation_history) 61 | return response_text 62 | -------------------------------------------------------------------------------- /ui.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit, QPushButton, QTextEdit 2 | from PyQt5.QtGui import QFont, QColor, QTextCursor 3 | from PyQt5.QtCore import Qt, QTimer 4 | from brain import Main_Brain # Importing the Main_Brain class 5 | 6 | class LoginWindow(QWidget): 7 | def __init__(self): 8 | super().__init__() 9 | self.setWindowTitle("Net Hi-Tech Chatbot Login") 10 | self.setGeometry(100, 100, 400, 300) 11 | self.setStyleSheet("background-color: #1b1f23; color: white;") 12 | 13 | layout = QVBoxLayout() 14 | 15 | self.username_label = QLabel("Username:") 16 | self.username_label.setFont(QFont("Arial", 12)) 17 | layout.addWidget(self.username_label) 18 | 19 | self.username_input = QLineEdit() 20 | self.username_input.setFont(QFont("Arial", 12)) 21 | self.username_input.setStyleSheet("background-color: #2c3136; color: white; border: none; padding: 10px;") 22 | layout.addWidget(self.username_input) 23 | 24 | self.password_label = QLabel("Password:") 25 | self.password_label.setFont(QFont("Arial", 12)) 26 | layout.addWidget(self.password_label) 27 | 28 | self.password_input = QLineEdit() 29 | self.password_input.setFont(QFont("Arial", 12)) 30 | self.password_input.setStyleSheet("background-color: #2c3136; color: white; border: none; padding: 10px;") 31 | self.password_input.setEchoMode(QLineEdit.Password) 32 | layout.addWidget(self.password_input) 33 | 34 | self.login_button = QPushButton("Login") 35 | self.login_button.setFont(QFont("Arial", 12, QFont.Bold)) 36 | self.login_button.setStyleSheet("background-color: #ff5e6c; color: white; padding: 10px; border-radius: 10px;") 37 | self.login_button.clicked.connect(self.check_login) 38 | layout.addWidget(self.login_button) 39 | 40 | self.setLayout(layout) 41 | 42 | def check_login(self): 43 | username = self.username_input.text() 44 | password = self.password_input.text() 45 | 46 | if username == "admin" and password == "admin@123": 47 | self.close() 48 | self.open_chatbot() 49 | else: 50 | self.username_input.clear() 51 | self.password_input.clear() 52 | self.username_input.setPlaceholderText("Invalid credentials, try again.") 53 | 54 | def open_chatbot(self): 55 | self.chatbot_window = ChatbotWindow() 56 | self.chatbot_window.show() 57 | 58 | class ChatbotWindow(QWidget): 59 | def __init__(self): 60 | super().__init__() 61 | self.setWindowTitle("Net Hi-Tech Chatbot") 62 | self.setGeometry(100, 100, 1200, 800) 63 | self.setStyleSheet("background-color: #1b1f23; color: white;") 64 | 65 | main_layout = QVBoxLayout() 66 | 67 | # Chat display area 68 | self.chat_display = QTextEdit() 69 | self.chat_display.setFont(QFont("Arial", 14)) 70 | self.chat_display.setStyleSheet(""" 71 | background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #262b30, stop:1 #1e2126); 72 | color: white; 73 | border: 2px solid #ff5e6c; 74 | border-radius: 15px; 75 | padding: 10px; 76 | """) 77 | self.chat_display.setReadOnly(True) 78 | main_layout.addWidget(self.chat_display) 79 | 80 | # Input area 81 | input_layout = QHBoxLayout() 82 | self.input_field = QLineEdit() 83 | self.input_field.setFont(QFont("Arial", 14)) 84 | self.input_field.setStyleSheet(""" 85 | background-color: #2c3136; 86 | color: white; 87 | border-radius: 10px; 88 | padding: 10px; 89 | border: 2px solid #ff5e6c; 90 | """) 91 | self.input_field.returnPressed.connect(self.handle_return_pressed) 92 | input_layout.addWidget(self.input_field) 93 | 94 | # Sci-Fi styled send button 95 | self.send_button = QPushButton("🚀 Send") 96 | self.send_button.setFont(QFont("Arial", 14, QFont.Bold)) 97 | self.send_button.setStyleSheet(""" 98 | QPushButton { 99 | background-color: #ff5e6c; 100 | color: white; 101 | padding: 15px; 102 | border-radius: 45px; 103 | border: 2px solid #ff5e6c; 104 | 105 | 106 | } 107 | QPushButton:hover { 108 | background-color: #ff7489; 109 | 110 | } 111 | """) 112 | self.send_button.clicked.connect(self.send_message) 113 | input_layout.addWidget(self.send_button) 114 | 115 | main_layout.addLayout(input_layout) 116 | self.setLayout(main_layout) 117 | 118 | def handle_return_pressed(self): 119 | if self.input_field.text().strip(): 120 | self.send_message() 121 | 122 | def send_message(self): 123 | message = self.input_field.text() 124 | if message: 125 | self.chat_display.append(f"
You: {message}
") 126 | self.input_field.clear() 127 | 128 | # Simulate typing animation 129 | self.chat_display.append("Net Hi-Tech Chatbot is thinking...
") 130 | QTimer.singleShot(2000, lambda: self.display_response(message)) # 2-second delay to simulate thinking 131 | 132 | def display_response(self, user_message): 133 | response = Main_Brain(user_message) # Use Main_Brain to generate the response 134 | self.chat_display.append(f"Net Hi-Tech Chatbot: {response}
") 135 | cursor = self.chat_display.textCursor() 136 | cursor.movePosition(cursor.End) 137 | self.chat_display.setTextCursor(cursor) 138 | 139 | # Main application 140 | def main(): 141 | app = QApplication([]) 142 | login = LoginWindow() 143 | login.show() 144 | app.exec_() 145 | 146 | if __name__ == "__main__": 147 | main() 148 | --------------------------------------------------------------------------------