Video Demo: https://youtu.be/y8G1eajXLNU
WoofieChat is an intelligent, AI-powered pet care assistant designed to provide accurate and personalized advice for pet owners. Built using advanced natural language processing (NLP) and semantic search, WoofieChat understands user queries and offers reliable responses related to pet care.
As an extension of the Woofie pet management system developed by me, WoofieChat aims to provide interactive, accurate advice for pet owners. I have found that they often struggle to find accurate and context-specific advice about their pet's care. WoofieChat addresses this gap by offering a conversational assistant that leverages AI to deliver relevant pet care guidance. Whether it's about feeding, grooming, or health concerns, WoofieChat provides valuable insights in a user-friendly format.
-
Personalized Advice: Understands pet types (dogs, cats, birds, fish, small pets) and offers tailored responses.
-
Semantic Search: Uses vector embeddings for accurate response matching.
-
Easy Data Management: Utilizes markdown files for structured and human-readable data storage.
-
Robust API: Built with FastAPI, providing a modern and efficient web interface.
-
Testing Suite: Ensures high code quality with comprehensive unit tests.
WoofieChat follows a modular architecture, making it efficient and scalable. The core components are structured as follows:
- Server (
server.py)- FastAPI-based server for handling API requests.
- Manages HTTP responses, CORS, and security.
- Provides RESTful endpoints for chat interactions.
- Inference Engine (
inference.py)
- Processes user inputs and normalizes queries.
- Identifies the pet type and extracts relevant keywords.
- Uses vector similarity to fetch accurate responses.
- Includes fallback responses for ambiguous queries.
- Embedder (
embedder.py)
-
Handles embedding generation using all-MiniLM-L6-v2.
-
Manages vector database operations with ChromaDB.
-
Efficiently retrieves relevant pet care information.
The project uses markdown files to store pet care information, organized by pet type:
woofieData.md: Dog care informationmeowData.md: Cat care informationchirpData.md: Bird care informationsplashData.md: Fish care informationsmallpetsData.md: Small pet care informationallPetsData.md: General pet care information
- NLP and Semantic Search
- Model Choice: Uses all-MiniLM-L6-v2 for text embedding, providing a balance between speed and accuracy.
- Vector Storage: ChromaDB is used to index and retrieve embeddings efficiently.
- Query Processing: Includes normalization, keyword extraction, and animal type detection.
- Main Endpoint: /api/chat accepts a JSON object with the user's query.
- Response Structure: JSON format with fields for response, confidence score, and data source.
The project includes a comprehensive test suite:
tests/test_server.py: API endpoint teststests/test_inference.py: Query processing teststests/test_embedder_actual.py: Data embedding teststests/conftest.py: Test fixtures and setuptests/test_data.md: Test data for unit tests
-
Vector Database
- Chose ChromaDB for its efficient vector storage and retrieval
- Enables semantic search capabilities
- Provides better response quality than keyword matching
-
Markdown Storage
- Used markdown format for knowledge base
- Easy to maintain and update
- Supports rich text formatting
- Human-readable and version-control friendly
-
FastAPI Framework
- Modern, fast web framework
- Built-in API documentation
- Type safety and validation
- Easy to test and maintain
-
Modular Architecture
- Separated concerns into distinct modules
- Easy to extend and modify
- Clear separation of data, logic, and interface
Potential areas for enhancement:
- Add more pet types and care information
- Improve the accuracy of the insights.
- Implement user feedback mechanism
- Add image recognition for pet health issues
- Integrate with veterinary databases
- Add multi-language support
-
Install dependencies:
pip install -r requirements.txt
-
Run the server:
python server.py
-
Access the API at
http://localhost:8000
The main endpoint is /api/chat which accepts POST requests with a JSON body:
{
"message": "What Should I feed my Dog?"
}Response format:
{
"response": "Feeding amounts depend on your dog's age, weight, activity level, and metabolism. Follow package guidelines as a starting point, then adjust based on body condition. You should be able to feel but not see your dog's ribs..",
"confidence": 0.95,
"source": "woofieData.md"
}Run the test suite:
pytestMade with ❤️ by AASHIK