#!/usr/bin/env python3 """ Easy launcher for the terminal chatbot """ import subprocess import sys import os def main(): print("๐Ÿค– AI Coding Assistant Terminal Launcher") print("=" * 50) # Check if model_server.py exists if not os.path.exists("model_server.py"): print("โŒ model_server.py not found!") print("Make sure all files are in the same directory.") sys.exit(1) # Check if terminal_chatbot.py exists if not os.path.exists("terminal_chatbot.py"): print("โŒ terminal_chatbot.py not found!") print("Make sure all files are in the same directory.") sys.exit(1) print("๐Ÿ“‹ Files found:") print(" โœ… model_server.py") print(" โœ… terminal_chatbot.py") print(" โœ… models.py") print(" โœ… utils.py") print() # Ask user what they want to run print("What would you like to run?") print("1. Start model server (required for chatbot)") print("2. Start terminal chatbot (requires running server)") print("3. Start both (server in background, then chatbot)") try: choice = input("\nEnter your choice (1-3): ").strip() except KeyboardInterrupt: print("\n๐Ÿ‘‹ Goodbye!") sys.exit(0) if choice == "1": print("\n๐Ÿš€ Starting model server...") print("๐Ÿ’ก Server will run on http://localhost:8000") print("๐Ÿ’ก Press Ctrl+C to stop") try: subprocess.run([sys.executable, "model_server.py"]) except KeyboardInterrupt: print("\n๐Ÿ›‘ Server stopped") elif choice == "2": print("\n๐Ÿค– Starting terminal chatbot...") print("๐Ÿ’ก Make sure the server is running first!") print("๐Ÿ’ก If you get connection errors, run option 1 first") try: subprocess.run([sys.executable, "terminal_chatbot.py"]) except KeyboardInterrupt: print("\n๐Ÿ‘‹ Chatbot stopped") elif choice == "3": print("\n๐Ÿš€ Starting server in background...") print("๐Ÿ’ก Server will run on http://localhost:8000") # Start server in background server_process = subprocess.Popen([sys.executable, "model_server.py"]) try: # Wait a bit for server to start print("โณ Waiting for server to start...") import time time.sleep(5) print("๐Ÿค– Starting terminal chatbot...") subprocess.run([sys.executable, "terminal_chatbot.py"]) except KeyboardInterrupt: print("\n๐Ÿ›‘ Stopping...") finally: # Clean up server process print("๐Ÿงน Stopping server...") server_process.terminate() server_process.wait() print("โœ… Server stopped") else: print("โŒ Invalid choice. Please run again and select 1, 2, or 3.") sys.exit(1) if __name__ == "__main__": main() This creates a complete client-server architecture: ## ๐Ÿš€ **Key Features:** ### **Terminal Chatbot (`terminal_chatbot.py`)** - Beautiful CLI interface with Rich formatting - Command support (`/help`, `/lang`, `/temp`, `/clear`, etc.) - Real-time API communication - Syntax-highlighted code display - Conversation history management ### **Model Server (`model_server.py`)** - FastAPI server hosting the 5B+ parameter model - RESTful API endpoints for chat and model info - Health monitoring and status checking - CORS enabled for web clients - Background model loading ### **Updated Gradio App (`updated_app.py`)** - Works with the API server - Real-time status monitoring - Same features as before but via API ### **Easy Launcher (`run_client.py`)** - Simple menu-driven interface - Can start server, client, or both - Error checking and guidance ## ๐Ÿ“‹ **How to Use:** 1. **Start the server:** python model_server.py 2. **Start the terminal chatbot:** python terminal_chatbot.py 3. **Or use the easy launcher:** python run_client.py 4. **For the Gradio web interface:** python updated_app.py ## ๐Ÿ”— **API Endpoints:** - `GET /health` - Check server status - `GET /model/info` - Get model information - `POST /api/chat` - Send chat messages - `POST /api/validate-code` - Validate code syntax - `GET /api/languages` - Get supported languages The terminal chatbot provides a professional CLI experience with syntax highlighting, command support, and real-time API communication!