Nutri analysisis a nutrition analysis and information app that helps you understand the nutritional content of foods and get personalized nutrition advice through a conversational AI assistant.
- Nutrition Analysis: Get detailed nutritional information for thousands of foods
- Custom Quantity Measurement: Adjust portion sizes to see scaled nutrition values
- Visualization: View nutritional data in easy-to-understand charts
- AI-Powered Conversation: Ask nutrition-related questions and get informed responses
- Search Foods: Browse through a comprehensive database of common foods
Nutri analysiscombines structured data retrieval with local AI processing to provide nutrition information without dependency on cloud-based LLMs:
-
Data Retrieval Layer:
- Uses the USDA FoodData Central API to fetch accurate nutritional data
- Organizes foods by categories for easy browsing
- Scales nutrient values based on user-specified quantities
-
Local AI Processing:
- Leverages Ollama to run a smaller, efficient LLM (llama3.2:1b) locally on your machine
- Processes natural language queries about nutrition
- Maintains context about previously analyzed foods
- Generates responses based on scientific nutrition knowledge
- Works completely offline once set up
-
Interactive UI:
- Built with Streamlit for an intuitive, responsive interface
- Provides both structured analysis and conversational modes
- Visualizes nutrition data through interactive charts
- Maintains conversation history for contextual responses
-
Contextual Understanding:
- Remembers last analyzed food and quantity for follow-up questions
- Uses system prompts to guide the AI toward nutrition-focused responses
- Maintains conversation state between interactions
- Python 3.7 or higher
- pip (Python package installer)
- USDA API Key (free to obtain)
-
Clone this repository:
git clone https://github.com/your-username/local-rag.git cd local-rag -
Install the required dependencies:
pip install -r requirements.txt -
Get a USDA API Key:
- Visit USDA FoodData Central API to sign up for free
- Copy your API key
-
Add your API key to the project:
- Open
main.pyin your preferred text editor - Replace the empty
API_KEY = ""with your key:API_KEY = "your-api-key-here"
- Open
-
Install Ollama:
- Follow the instructions at Ollama's official website to install Ollama
- Pull the required model:
ollama pull llama3.2:1b
Start the application with:
streamlit run main.py
The app should open automatically in your default web browser at http://localhost:8501.
- Select "Nutrition Analysis" from the sidebar
- Choose between "Select from List" or "Custom Food/Recipe"
- For "Select from List", pick a food from the dropdown
- For "Custom Food/Recipe", type the name of your food or dish
- Adjust the quantity as needed (default is 1 serving)
- Click "Analyze Nutrition" to see detailed information
- Select "Conversational Mode" from the sidebar
- Type your nutrition-related questions in the chat input
- Get AI-generated responses based on nutrition science
- Previous conversations will be displayed above
- Click "Clear Conversation" in the sidebar to start fresh
- Use specific food names for more accurate analysis
- When asking questions, be specific about the food or nutrient you're interested in
- Adjust quantities to match your actual portions
- Try comparing different foods by running multiple analyses
Error: API Key Invalid
- Make sure you've correctly added your USDA API key to the code
No Results Found
- Try using more general terms (e.g., "apple" instead of "granny smith apple")
- Check your spelling
Ollama Model Not Loading
- Ensure Ollama is running in the background
- Verify you've pulled the correct model (
llama3.2:1b)
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- USDA FoodData Central for providing the nutrition database
- Streamlit for the web application framework
- Ollama for the local LLM capabilities




