--- title: Chatbot for Project Guidance emoji: 📚 colorFrom: yellow colorTo: indigo sdk: gradio sdk_version: 5.14.0 app_file: app.py pinned: false short_description: Custom AI Chatbot for Project Guidance license: osl-3.0 environment: conda --- # Custom AI Chatbot for Project Guidance This project implements a custom AI chatbot designed to guide users through complex projects based on predefined roadmaps and rules. **Features:** * **Roadmap-based Guidance:** Follows a structured roadmap defined in `roadmap.yaml`. * **Rule Enforcement:** Adheres to project rules defined in `rules.yaml`. * **Dynamic Response Generation:** Provides context-aware and step-by-step guidance. * **Code Snippet Generation:** Generates complete code snippets for project phases using templates. * **LLM Selection:** Integrates with Hugging Face Hub for flexible LLM selection (DeepSeek and Gemini models). * **Model Switching:** Allows users to switch between available LLMs via the UI. * **Basic LLM Responses:** Generates responses using the selected LLM for general queries. * **Token Control:** Limits LLM response length using `max_response_tokens` in `configs/chatbot_config.yaml`. * **Configuration Update Mode:** Allows authorized users to modify chatbot configuration (rules) via chat commands in a special "update mode". * **Error Handling:** Includes error handling for model loading, switching, and configuration updates, with UI warnings. * **Deployable on Hugging Face Spaces:** Built using Gradio for easy deployment. **Important Notes on Safety Settings and Self-Update:** * **Direct Safety Configuration Limited:** For the Hugging Face models used directly via `transformers` (DeepSeek and Gemini Flash), there are **no easily configurable, standardized "safety settings"**. Safety is model-dependent. * **Model-Dependent Safety:** Safety behavior is primarily determined by how these models were trained. * **Configuration-Based Self-Update:** The "self-update" feature is implemented as a *configuration modification* system. It allows authorized users to change the chatbot's rules by modifying the `rules.yaml` file via chat commands in "update mode." **It does not modify the core Python code itself.** * **Security Warning:** The "self-update" feature, even in its configuration-based form, introduces security considerations. **Secret commands are NOT a robust security measure.** In a real deployment, stronger authentication and authorization would be essential. Use this feature with caution and only in trusted environments. **Getting Started:** 1. **Clone this repository.** 2. **Install dependencies:** `pip install -r requirements.txt` 3. **Customize `roadmap.yaml` and `rules.yaml`** to define your project guidance. 4. **Configure `configs/chatbot_config.yaml`** to set up LLMs, token limits, and chatbot behavior. 5. **Run the Gradio app:** `python app.py` 6. **To enter update mode:** Type `sagor is python/start` in the chat. 7. **To get help in update mode:** Type `sagor is python/help`. 8. **To exit update mode:** Type `sagor is python/exit`. 9. **Deploy to Hugging Face Spaces** (refer to Hugging Face Spaces documentation). **Available Models:** * DeepSeek-R1-Distill-Llama-8B * Gemini 2.0 Flash (Exp 01-21) **Further Development:** * Enhance LLM response generation for more context-aware and project-specific guidance. * Implement more sophisticated state management to track user progress through the roadmap. * Improve code generation with more dynamic templates and customization options. * Develop a more advanced GUI or web-based interface for configuration management. * Add more LLMs to the selection pool. * Implement more robust error handling and logging. * Explore and potentially integrate keyword-based output filtering for basic safety control. * Investigate using commercial LLM APIs for more advanced safety settings and control. * **Improve security and authorization for the configuration update mode.** **License:** [Your License]