Metadata-Version: 2.4
Name: devchat_hm
Version: 0.1.1
Summary: DevChat – AI powered project-aware coding assistant
Author-email: Hemanth Meher <hemanthimandi5@gmail.com>
License: MIT
Keywords: ai,chatbot,developer-tools,rag,code-editor
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: click
Requires-Dist: faiss-cpu
Requires-Dist: sentence-transformers
Requires-Dist: groq
Requires-Dist: numpy
Requires-Dist: openai
Requires-Dist: tiktoken

Copy🤖 DevChat - AI-Powered Local Coding Assistant

DevChat is an intelligent, project-aware coding assistant that understands your entire codebase using RAG (Retrieval-Augmented Generation) technology. Ask questions, get instant answers, and even fix bugs - all from your terminal!

🌟 Why DevChat?
Traditional AI assistants don't understand your specific project. DevChat indexes your entire codebase, creates semantic embeddings, and gives you context-aware answers specific to YOUR code.
✨ Key Features

🧠 Project-Aware Intelligence - Understands your complete codebase context
🔍 Smart Code Search - Find functions, classes, and files using natural language
💬 Interactive Chat - Ask questions in plain English
🛠️ Automatic Bug Fixes - Detects and applies code fixes with approval
⚡ Lightning Fast - Uses FAISS vector search for instant results
🎯 Multi-Mode Operation - File-specific, project-wide, and general chat modes
📝 Smart File Detection - Automatically detects which files are relevant
🚀 Powered by Groq - Uses fast Llama 3.1 model for responses


📦 Installation
Requirements

Python 3.9 or higher
Groq API Key (Get one free here)

Install via pip
bashpip install devchat-hm
Set up your API key
bash# Linux/Mac
export GROQ_API_KEY="your-groq-api-key-here"

# Windows (PowerShell)
$env:GROQ_API_KEY="your-groq-api-key-here"

# Windows (CMD)
set GROQ_API_KEY=your-groq-api-key-here

🚀 Quick Start
1. Run DevChat
bashdevchat
2. Enter your project path when prompted
Enter project path: /path/to/your/project
3. Wait for indexing (one-time process)
🔍 Indexing project files...
✅ Indexed: /path/to/your/project/main.py
✅ Indexed: /path/to/your/project/utils.py
...
🤖 DevChat is ready. Ask questions.
4. Start asking questions!
🧑‍💻 > What does the main.py file do?
🤖 DevChat:
The main.py file contains the entry point of the application...

🧑‍💻 > How is authentication handled?
🤖 DevChat:
Authentication is implemented in auth.py using JWT tokens...

🧑‍💻 > Fix the bug in utils.py line 45
🤖 DevChat:
FILE: utils.py
START_LINE: 45
END_LINE: 48
CODE:
def process_data(data):
    if data is None:
        return []
    return [item.strip() for item in data]

Apply fix? (y/n):

🎯 How It Works
DevChat operates in 3 intelligent modes:
1️⃣ File-Specific Mode
When you mention a specific file (e.g., main.py, utils.js), DevChat retrieves only that file's content.
🧑‍💻 > What functions are in auth.py?
2️⃣ Project-Wide Mode
For general project questions, DevChat searches across all indexed files using semantic similarity.
🧑‍💻 > Where is the database connection configured?
3️⃣ General Chat Mode
For non-code questions, DevChat acts like a helpful AI assistant.
🧑‍💻 > Explain what REST APIs are

🛠️ Advanced Features
Automatic Code Fixes
DevChat can detect when you want to modify code and generates precise fixes:
🧑‍💻 > Fix the error in main.py line 23 - variable 'user' might be None
🤖 DevChat:
FILE: main.py
START_LINE: 23
END_LINE: 25
CODE:
if user is not None:
    print(user.name)
else:
    print("User not found")

Apply fix? (y/n): y
✅ Fix applied successfully!
Supported Languages
DevChat supports the following file types:

Python (.py)
JavaScript (.js, .jsx)
Java (.java)
C/C++ (.c, .cpp, .h)
HTML/CSS (.html, .css)
JSON (.json)
TypeScript (.ts)

Smart Folder Exclusion
DevChat automatically ignores:

node_modules/
.git/
__pycache__/
dist/, build/
.next/
.venv/


🔧 Configuration
DevChat uses a simple configuration system. Key settings are in devchat/config.py:
pythonclass Config:
    GROQ_API_KEY = os.getenv("GROQ_API_KEY")
    MODEL = "llama-3.1-8b-instant"           # LLM model
    EMBEDDING_MODEL = "all-MiniLM-L6-v2"     # Embedding model
    VECTOR_DB_PATH = "devchat.index"         # Index storage path
Custom Configuration
You can modify these settings by creating a custom config:
pythonfrom devchat.config import Config

Config.MODEL = "llama-3.1-70b-versatile"  # Use a larger model
Config.VECTOR_DB_PATH = "custom_index.db"  # Custom index location

📊 Technical Architecture
┌─────────────────────────────────────────────────────────┐
│                     User Question                        │
└────────────────────┬────────────────────────────────────┘
                     │
                     ▼
         ┌───────────────────────┐
         │   Question Analyzer   │
         │  (File/Project/Chat)  │
         └───────────┬───────────┘
                     │
        ┌────────────┴────────────┐
        │                         │
        ▼                         ▼
┌──────────────┐          ┌──────────────┐
│ File Search  │          │ Vector Store │
│  (Exact)     │          │ (Semantic)   │
└──────┬───────┘          └──────┬───────┘
       │                         │
       └────────────┬────────────┘
                    │
                    ▼
        ┌───────────────────────┐
        │   Build Context       │
        │   (Top-K Documents)   │
        └───────────┬───────────┘
                    │
                    ▼
        ┌───────────────────────┐
        │   LLM (Groq/Llama)    │
        │   Generate Response   │
        └───────────┬───────────┘
                    │
                    ▼
        ┌───────────────────────┐
        │   Response Parser     │
        │   (Fix Detection)     │
        └───────────┬───────────┘
                    │
                    ▼
              ┌──────────┐
              │  Output  │
              └──────────┘
Core Components

Indexer (indexer.py) - Scans project and creates document embeddings
Vector Store (vectorstore.py) - FAISS-based similarity search
RAG (rag.py) - Builds context from relevant documents
LLM (llm.py) - Groq API integration for responses
Chat Loop (chat.py) - Main interaction logic with 3 modes
Editor (editor/) - Code diff, parsing, and patching tools


💡 Usage Examples
Example 1: Understanding Code Structure
🧑‍💻 > What classes are defined in models.py?
🤖 DevChat:
The models.py file defines 3 classes:
1. User - Represents user accounts
2. Post - Represents blog posts
3. Comment - Represents post comments
Example 2: Finding API Endpoints
🧑‍💻 > Where are the API routes defined?
🤖 DevChat:
API routes are defined in routes/api.py:
- GET /api/users - Fetch all users
- POST /api/users - Create new user
- GET /api/posts - Fetch all posts
Example 3: Debugging Errors
🧑‍💻 > Why am I getting "KeyError: 'user_id'" in app.py?
🤖 DevChat:
In app.py line 34, you're accessing request.form['user_id'] 
without checking if it exists. Use request.form.get('user_id') 
instead to avoid KeyError.
Example 4: Code Modification
🧑‍💻 > Update the database connection timeout to 30 seconds in config.py
🤖 DevChat:
FILE: config.py
START_LINE: 12
END_LINE: 12
CODE:
DB_TIMEOUT = 30  # seconds

Apply fix? (y/n): y
✅ Fix applied successfully!

🎓 Best Practices
1. Be Specific
❌ "Tell me about the code"
✅ "What does the authenticate() function in auth.py do?"
2. Mention File Names
Including file names helps DevChat give precise answers:
🧑‍💻 > How does error handling work in utils.py?
3. Use Action Keywords for Fixes
Keywords like "fix", "update", "change", "modify" trigger fix mode:
🧑‍💻 > Fix the indentation error in main.py line 45
4. Ask Follow-up Questions
DevChat maintains context within a session:
🧑‍💻 > What does the User class do?
🤖 DevChat: [explains User class]

🧑‍💻 > Show me the __init__ method
🤖 DevChat: [shows init method]

🤝 Contributing
Contributions are welcome! Here's how you can help:
Reporting Issues
Found a bug? Open an issue with:

Description of the problem
Steps to reproduce
Expected vs actual behavior
Your Python version and OS

Feature Requests
Have an idea? Open a feature request describing:

The feature you'd like
Why it would be useful
How it might work

Pull Requests

Fork the repository
Create a feature branch (git checkout -b feature/amazing-feature)
Make your changes
Write/update tests if applicable
Commit your changes (git commit -m 'Add amazing feature')
Push to your fork (git push origin feature/amazing-feature)
Open a Pull Request


📝 License
This project is licensed under the MIT License - see the LICENSE file for details.

👨‍💻 Author
Hemanth Meher

📧 Email: hemanthimandi5@gmail.com
🐙 GitHub: @hemanthmeher
💼 LinkedIn: Connect with me


🙏 Acknowledgments

Groq - Lightning-fast LLM inference
FAISS - Efficient similarity search by Facebook AI
Sentence Transformers - State-of-the-art text embeddings
Click - Beautiful command-line interfaces


🔮 Roadmap
Coming Soon

 Support for more programming languages
 Integration with VS Code extension
 Multi-file code generation
 Project-wide refactoring suggestions
 Integration with GitHub for PR analysis
 Support for OpenAI GPT models
 Custom embedding models
 Web interface (optional GUI)


📊 Project Stats

Lines of Code: ~500
Dependencies: 6 core packages
Supported File Types: 11+
Average Response Time: <2 seconds
Index Size: Varies by project (typically 1-10 MB)


⚡ Performance Tips
1. Index Only What You Need
If you have a large project, consider indexing specific directories:
python# Modify indexer.py to limit scope
project_path = "/your/project/src"  # Instead of root
2. Use Faster Models
For quicker responses, use smaller models:
pythonConfig.MODEL = "llama-3.1-8b-instant"  # Fast
# vs
Config.MODEL = "llama-3.1-70b-versatile"  # Accurate but slower
3. Reuse Indexes
DevChat saves the index to devchat.index. On subsequent runs, it loads from disk instead of re-indexing (future feature).

❓ FAQ
Q: Do I need an internet connection?
A: Yes, DevChat uses the Groq API which requires internet. The vector search is local, but LLM inference is cloud-based.
Q: Is my code sent to the cloud?
A: Only the relevant code snippets matching your question are sent to Groq's API along with your prompt. Full codebase stays local.
Q: Can I use OpenAI instead of Groq?
A: Currently, DevChat is configured for Groq. OpenAI support is planned for future versions.
Q: How accurate are the answers?
A: DevChat is as accurate as the LLM (Llama 3.1) and the relevance of retrieved documents. It works best with well-structured codebases.
Q: Can I use this in production?
A: DevChat is great for development and debugging. For production AI features, consider rate limits and error handling.
Q: How do I reset the index?
A: Simply delete the devchat.index file and run DevChat again to re-index your project.

🚨 Troubleshooting
Issue: "GROQ_API_KEY not found"
Solution: Make sure you've set the environment variable:
bashexport GROQ_API_KEY="your-key-here"
Issue: No files being indexed
Solution: Check if your files have supported extensions (.py, .js, etc.) and aren't in ignored folders.
Issue: "NOT FOUND" responses
Solution:

Ensure the file/code you're asking about actually exists in your indexed project
Try rephrasing your question with more specific keywords
Mention specific file names for better results

Issue: Slow indexing
Solution:

Large projects take longer to index
Exclude unnecessary directories by modifying IGNORE_DIRS in indexer.py
