{"id":26137855,"url":"https://github.com/rampal-punia/django-chat","last_synced_at":"2025-03-11T01:08:41.067Z","repository":{"id":253491623,"uuid":"843676466","full_name":"rampal-punia/Django-Chat","owner":"rampal-punia","description":"AI-powered Django-Chat is an innovative chat application that combines the robustness of Django with cutting-edge language models with seamless integration of real-time communication and artificial intelligence, providing users with an intelligent conversational experience.","archived":false,"fork":false,"pushed_at":"2024-09-10T14:34:00.000Z","size":8364,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-10T16:22:59.049Z","etag":null,"topics":["api-rest","chat","chatbot","django","huggingface-transformers","langchain","langchain-python","mistral-8x7b","mistral-ai"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rampal-punia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-17T04:46:16.000Z","updated_at":"2024-09-10T14:43:40.000Z","dependencies_parsed_at":"2024-08-17T05:39:47.274Z","dependency_job_id":"8c7d5d70-29d2-4f1b-b295-04893ea09290","html_url":"https://github.com/rampal-punia/Django-Chat","commit_stats":null,"previous_names":["rampal-punia/django-chat"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rampal-punia%2FDjango-Chat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rampal-punia%2FDjango-Chat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rampal-punia%2FDjango-Chat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rampal-punia%2FDjango-Chat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rampal-punia","download_url":"https://codeload.github.com/rampal-punia/Django-Chat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242951075,"owners_count":20211571,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-rest","chat","chatbot","django","huggingface-transformers","langchain","langchain-python","mistral-8x7b","mistral-ai"],"created_at":"2025-03-11T01:08:40.477Z","updated_at":"2025-03-11T01:08:41.050Z","avatar_url":"https://github.com/rampal-punia.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django-Chat Webapp\n\n## About\n\nDjango-Chat is an AI-powered chat application that combines the robustness of Django with cutting-edge language models. This project showcases the seamless integration of real-time communication and artificial intelligence, providing users with an intelligent conversational experience. It combines text, audio, image, and document processing capabilities, allowing users to engage with AI in multiple formats.\n\nLeveraging WebSockets for instant messaging and Hugging Face's state-of-the-art language models, Django-Chat offers responsive, context-aware interactions. The application features user authentication, conversation management, and automatic title generation, all wrapped in a clean, intuitive interface. Django-Chat provides a solid foundation for your next-level web application.\n\n## What We're Building\n\n|||\n|----|----|\n|\u003cimg src=\"static/imgs/home-page.png\" alt=\"Home Page\"\u003e|\u003cimg src=\"static/imgs/dj-chat.png\" alt=\"Chat Interface\"\u003e|\n|\u003cimg src=\"static/imgs/api_schema_swagger.png\" alt=\"API Schema Swagger\"\u003e|\u003cimg src=\"static/imgs/api_schema_redoc.png\" alt=\"API Schema Redoc\"\u003e|\n|\u003cimg src=\"static/imgs/profile.png\" alt=\"User Profile\"\u003e|\u003cimg src=\"static/imgs/register.png\" alt=\"Registration Page\"\u003e|\n|||\n\n## Table of Contents\n- [Features](#features)\n- [Technologies Used](#technologies-used)\n- [Getting Started](#getting-started)\n  - [Prerequisites](#prerequisites)\n  - [Installation](#installation)\n- [Project Structure](#project-structure)\n- [Key Components](#key-components)\n- [How It Works](#how-it-works)\n- [API Endpoints](#api-endpoints)\n- [WebSocket Integration](#websocket-integration)\n- [Configuration](#configuration)\n- [Contributing](#contributing)\n- [Disclaimer](#disclaimer)\n- [License](#license)\n\n## Features\n\n- **Text Chat**: Real-time text-based conversations with an AI model.\n- **Audio Interface**: Voice-to-text and text-to-voice capabilities for audio conversations.\n- **Image Processing**: Upload and analyze images with AI-generated descriptions.\n- **Document Analysis**: Upload PDF documents and ask questions about their content.\n- **User Authentication**: Secure login and user profile management.\n- **Real-time Updates**: WebSocket integration for instant message delivery.\n- **Markdown Support**: Rich text formatting in chat messages.\n\n\n## Technologies Used\n\n- **Backend**: Django, Django Channels\n- **Real-time Communication**: WebSockets, Django Channels with asynchronous capabilities\n- **Frontend**: HTML, CSS, JavaScript, Bootstrap 5\n- **AI/ML**: Langchain, HuggingFace Transformers\n- **Database**: PostgreSQL with pgvector extension\n- **Audio Processing**: SpeechRecognition, gTTS (Google Text-to-Speech)\n- **Image Processing**: OpenCV, Pillow\n- **Document Processing**: PyPDF2, Langchain document loaders\n- **External APIs**: HuggingFace Inference API\n- **Django Rest Framework**: For building RESTful APIs\n- **Redis**: As a channel layer for WebSocket communication\n- **Daphne**: ASGI server for running Django with WebSocket support\n\n## Getting Started\n\n### Prerequisites\n- Python 3.8+\n- Django 5.x\n- PostgreSQL with pgvector extension\n- Huggingface API\n- Redis server\n\n### Installation\n\n1. Clone the repository:\n   ```\n   git clone https://github.com/rampal-punia/Django-Chat.git\n   cd Django-Chat\n   ```\n\n2. Create a virtual environment and activate it:\n   ```\n   python -m venv venv\n   source venv/bin/activate  # On Windows use `venv\\Scripts\\activate`\n   ```\n\n3. Install the required packages:\n   ```\n   pip install -r requirements.txt\n   ```\n\n4. Set up your environment variables:\n   - Create a `.env` file in the project root\n   - Add necessary variables (e.g., `DJANGO_SECRET_KEY`, `DEBUG`, `HUGGINGFACEHUB_API_TOKEN`, `DATABASE_URL`, `REDIS_URL`)\n\n5. Set up PostgreSQL with pgvector extension:\n   - Ensure PostgreSQL is installed and running\n   - Create a database for the project\n   - Install the pgvector extension in your database\n\n6. Set up Redis:\n   - Ensure Redis is installed and running\n\n7. Run migrations:\n   ```\n   python manage.py migrate\n   ```\n\n8. Start the development server:\n   ```\n   python manage.py runserver\n   ```\n\n9. Visit `http://localhost:8000` in your web browser.\n\n## Project Structure\n\n```\nDjango-Chat/\n├── chat/                  # Core chat functionality\n├── audio_interface/       # Audio processing module\n├── image_interface/       # Image processing module\n├── document_interface/    # Document processing module\n├── users/                 # User authentication and profiles\n├── static/                # Static files (CSS, JS)\n├── templates/             # HTML templates\n├── manage.py\n└── requirements.txt\n```\n\n## Key Components\n\n1. **Chat App**: Handles core text-based chat functionality.\n2. **Audio Interface**: Manages voice input/output and transcription.\n3. **Image Interface**: Processes uploaded images and generates descriptions.\n4. **Document Interface**: Handles PDF uploads and question-answering about documents.\n5. **User Management**: Manages user authentication and profiles.\n\n\n## How It Works\n\n1. **Text Chat**:\n   - Users send messages through a WebSocket connection.\n   - Messages are processed by an AI model via Langchain.\n   - Responses are sent back to the user in real-time.\n\n2. **Audio Chat**:\n   - Users can record audio messages.\n   - Audio is converted to text using speech recognition.\n   - The text is processed by the AI model.\n   - The AI's response is converted back to speech.\n\n3. **Image Analysis**:\n   - Users upload images.\n   - Images are processed using computer vision techniques.\n   - An AI model generates descriptions of the images.\n   - Users can ask questions about the uploaded images.\n\n4. **Document Q\u0026A**:\n   - Users upload PDF documents.\n   - Documents are processed and indexed.\n   - Users can ask questions about the document content.\n   - An AI model provides answers based on the document's content.\n\n\n## API Endpoints\n\nThe project includes a RESTful API for conversations and messages. Key endpoints include:\n\n- `/api/conversations/`: List and create conversations\n- `/api/conversations/\u003cuuid:pk\u003e/`: Retrieve, update, or delete a specific conversation\n- `/api/messages/`: List and create messages\n- `/api/messages/\u003cint:pk\u003e/`: Retrieve, update, or delete a specific message\n\nAPI documentation is available at:\n- `/api/schema/swagger-ui/`: Swagger UI for API documentation\n- `/api/schema/redoc/`: ReDoc for API documentation\n\n## WebSocket Integration\n\nThe application uses WebSockets for real-time communication. The WebSocket consumer is defined in `chat/consumers.py` and handles the following operations:\n\n- Establishing WebSocket connections\n- Receiving and processing messages\n- Generating AI responses using language models\n- Sending responses back to the client\n\nWebSocket routing is configured in `config/routing.py`.\n\n## Configuration\n\nThe project uses a `base.py` file for Django settings. Key configurations include:\n\n- `INSTALLED_APPS`: Includes 'daphne', 'channels', 'rest_framework', 'corsheaders', and 'drf_spectacular' among others.\n- `ASGI_APPLICATION`: Set to 'config.asgi.application' for WebSocket support.\n- `CHANNEL_LAYERS`: Configured to use Redis as the backend.\n- `REST_FRAMEWORK`: Configured with default permission classes and authentication classes.\n- `SPECTACULAR_SETTINGS`: Configuration for API documentation using drf-spectacular.\n- `HUGGINGFACE_API_TOKEN`: Token for accessing Hugging Face models.\n\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## Disclaimer\n\nThis project is intended as a learning exercise and demonstration of integrating various technologies, including:\n\n- Django\n- Django Channels\n- Django REST Framework\n- LangChain\n- Hugging Face Endpoint APIs\n\nPlease note that this application is not designed or tested for production use. It serves as an educational resource and a showcase of technology integration rather than a production-ready web application.\n\nContributors and users are welcome to explore, learn from, and build upon this project for educational purposes.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.\n\n## Hit Start\n\nLike this project! Consider hitting the star ⭐ button.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frampal-punia%2Fdjango-chat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frampal-punia%2Fdjango-chat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frampal-punia%2Fdjango-chat/lists"}