Rendering markdown & diagrams...
   1  # NovaChat: Advanced AI Assistant with Multiple Features
   2  
   3  NovaChat is a versatile AI assistant with multiple capabilities, including different conversation personas, web search integration, torrent functionality, and local LLM integration.
   4  
   5  ## Project Overview
   6  
   7  ### 1. AI Chat with Multiple Personas
   8  The system can switch between different conversation modes:
   9     
  10  - **COGITO**: Standard helpful assistant mode
  11  - **FLIRTY**: A flirtatious persona
  12  - **COMPANION**: An empathetic, supportive friend
  13  - **INVESTIGATE**: An analytical persona focused on Indian politics and current affairs
  14  
  15  ### 2. Web Search Integration
  16  Fetches real-time information from:
  17     
  18  - Google Search
  19  - DuckDuckGo
  20  - News sources
  21  - arXiv (for academic papers)
  22  
  23  ### 3. Torrent Functionality
  24  Allows searching, downloading, and streaming of torrents via magnet links
  25  
  26  ### 4. Local LLM Integration
  27  Uses Ollama to run local AI models including:
  28     
  29  - Cogito models
  30  - Various specialized models
  31  
  32  ### 5. Model Management
  33  - Real-time listing of available Ollama models
  34  - Display model sizes and last modified dates
  35  - Pull new models directly from Ollama registry
  36  - Error handling for model operations
  37  
  38  ## Project Structure
  39  
  40  ```
  41  agent_prod/
  42  ├── app.py                      # Main application entry point
  43  ├── requirements.txt            # Dependencies
  44  ├── README.md                   # Project documentation
  45  ├── static/                     # Static assets
  46  │   ├── css/                    # CSS files
  47  │   │   └── style.css           # Main stylesheet
  48  │   └── js/                     # JavaScript files
  49  │       └── chat.js             # Chat functionality
  50  ├── templates/                  # HTML templates
  51  │   ├── index.html              # Main chat interface
  52  │   ├── player.html             # Media player for torrents
  53  │   └── components/             # Reusable UI components
  54  ├── modules/
  55  │   ├── chat/                   # AI chat functionality
  56  │   │   ├── __init__.py
  57  │   │   ├── personas.py         # Different chat personas
  58  │   │   └── chat_handler.py     # Chat processing logic
  59  │   ├── torrent/                # Torrent functionality
  60  │   │   ├── __init__.py
  61  │   │   └── torrent_handler.py  # Torrent handling logic
  62  │   ├── search/                 # Search functionality
  63  │   │   ├── __init__.py
  64  │   │   ├── news.py             # News search
  65  │   │   ├── arxiv.py            # arXiv search
  66  │   │   └── web.py              # Web search
  67  │   └── llm/                    # LLM integration
  68  │       ├── __init__.py
  69  │       └── ollama_client.py    # Ollama integration
  70  
  71  ```
  72  
  73  ## UI Screenshots
  74  
  75  ![Chat Interface](./static/assets/screenshots/chat-ui.png)
  76  *Main chat interface with persona selection*
  77  
  78  ![Torrent Player](./static/assets/screenshots/torrent-player.png)
  79  *Media player with progress controls*
  80  
  81  ![Model Selection](./static/assets/screenshots/model-selection.png)
  82  *Ollama model management interface*
  83  
  84  ## Future Improvements
  85  
  86  1. **User Authentication**
  87     - JWT-based auth system
  88     - Role-based access control
  89  
  90  2. **Rate Limiting**
  91     - API request throttling
  92     - Torrent download quotas
  93  
  94  3. **Enhanced Security**
  95     - Content moderation system
  96     - SSL/TLS encryption
  97  
  98  4. **Plugin System**
  99     - Extensible architecture for new personas
 100     - Third-party integration support
 101  
 102  ## Features
 103  
 104  ### Chat System
 105  - Flask-based web interface
 106  - Server-side session management
 107  - Multiple conversation personas with different system prompts
 108  - Integration with Ollama for local LLM inference
 109  
 110  ### Search System
 111  - DuckDuckGo search integration with title/URL results
 112  - Google search API implementation
 113  - Error handling for search providers
 114  - Results formatting for chat integration
 115  
 116  ### Torrent Functionality
 117  - libtorrent-based download management
 118  - Real-time progress tracking
 119  - Streaming capability for completed files
 120  - File listing for partial downloads
 121  - Status monitoring (progress, peers, speed)
 122  
 123  ### Torrent Functionality
 124  - Uses libtorrent for handling magnet links
 125  - Provides real-time download status
 126  - Supports streaming of downloaded content
 127  
 128  ### Web Interface
 129  - Bootstrap 5 responsive layout
 130  - Component-based template architecture
 131  - Real-time chat interface with message history
 132  - Media player with torrent progress monitoring
 133  - Persona selection dropdown menu
 134  
 135  - Interactive progress bars and status indicators
 136  
 137  ## Setup and Installation
 138  
 139  ### Prerequisites
 140  - Python 3.10
 141  - Ollama service running locally ([installation guide](https://ollama.ai/download))
 142  - libtorrent-rasterbar 2.0+
 143  
 144  ### Virtual Environment Setup
 145  ```bash
 146  # Create virtual environment
 147  python -m venv venv
 148  
 149  # Activate environment (Windows)
 150  venv\Scripts\activate
 151  
 152  # Install dependencies
 153  pip install -r requirements.txt
 154  ```
 155  
 156  ### Installation
 157  1. Clone the repository
 158  2. Install dependencies:
 159     ```bash
 160     pip install -r requirements.txt
 161     ```
 162  3. Configure environment:
 163     ```bash
 164     cp config.yaml.example config.yaml
 165     ```
 166  4. Start the application:
 167     ```bash
 168     python app.py
 169     ```
 170  
 171  ### Configuration
 172  Edit `config.yaml` to customize:
 173  - API keys for search providers
 174  - Torrent download locations
 175  - LLM model preferences
 176  - Session timeout settings
 177  
 178  Access the web interface at http://localhost:9125
 179  
 180  ## Dependencies
 181  
 182  - Flask==2.0.1
 183  - Flask-Session==0.4.0
 184  - Requests==2.26.0
 185  - python-libtorrent==1.2.3
 186  - duckduckgo-search==2.8.5
 187  - googlesearch-python==1.0.1
 188  - Ollama==0.1.2
 189  - python-dotenv==0.19.0
 190  - uvicorn==0.15.0
 191  
 192  Note: Ensure libtorrent-rasterbar 2.0+ is installed system-wide