# Testing the Nutriguide API

## Introduction

An API uses nutritional data from various products and a user's health status to create a chatbot powered by LLM. Users can interact with this chatbot to make and plan their choices.

The [GitHub Documentation](https://tuhindutta.github.io/nutriguide/) and [DockerHub documentation](https://hub.docker.com/r/tkdutta/nutriguide-api) provide guides for downloading the container and using it locally. You can also deploy it by following a few simple steps. For more details on using the API, refer to the API documentation in the GitHub documentation.

## Testing

1. Install Docker Desktop.
    
2. Install [Postman](https://www.postman.com/downloads/).
    
3. Follow the user guide in the DockerHub documentation.
    
4. Create 3 instances of `POST` requests for these endpoints:
    
    * `/health`
        
    * `/products`
        
    * `/query`
        
5. Send the health status through the `/health` endpoint. For this example, let’s use:
    
    ```json
    {
        "health_status": "I am hypertensive patient with a slight high BP of 130/92. I have diabetis around 135. I am 5 feet 8 inches tall with 78 kg of weight. I want protien."
    }
    ```
    
6. Send the nutritional information of the products through the `/products` endpoint. For this example, let’s use:
    
    ```json
    {
        "products": [
            {
                "data": {
                    "Nutritional Content": {
                        "Added Sugars": "40.5 g",
                        "Carbohydrates": "56.5 g",
                        "Cholesterol": "13.7 mg",
                        "Energy": "559 kcal",
                        "Protein": "6.1 g",
                        "Saturated Fat": "21.15 g",
                        "Sodium": "212 mg",
                        "Total Fat": "34.85 g",
                        "Total Sugars": "48.6 g",
                        "Trans Fat": "0.15 g"
                    }
                },
                "heading": "Nutritional Content of Cadbury Dairy Milk Silk Oreo per 100g"
            },
            {
                "data": {
                    "Nutritional Content": {
                        "Added Sugars": "0 g",
                        "Carbohydrates": "53 g",
                        "Cholesterol": "0 mg",
                        "Energy": "536 kcal",
                        "Protein": "7 g",
                        "Saturated Fat": "3.3 g",
                        "Sodium": "525 mg",
                        "Total Fat": "34 g",
                        "Total Sugars": "1 g",
                        "Trans Fat": "0.1 g"
                    }
                },
                "heading": "Nutritional Content of Lays Classic Salted Chips per 100g"
            },
            {
                "data": {
                    "Nutritional Content": {
                        "Added Sugars": "10.6 g",
                        "Carbohydrates": "10.6 g",
                        "Cholesterol": "0 mg",
                        "Energy": "42 kcal",
                        "Protein": "0 g",
                        "Saturated Fat": "0 g",
                        "Sodium": "11 mg",
                        "Total Fat": "0 g",
                        "Total Sugars": "10.6 g",
                        "Trans Fat": "0 g"
                    }
                },
                "heading": "Nutritional Content of Coca-Cola per 100ml"
            },
            {
                "data": {
                    "Nutritional Content": {
                        "Added Sugars": "2.1 g",
                        "Carbohydrates": "60 g",
                        "Cholesterol": "0 mg",
                        "Energy": "445 kcal",
                        "Protein": "9 g",
                        "Saturated Fat": "8.1 g",
                        "Sodium": "880 mg",
                        "Total Fat": "17 g",
                        "Total Sugars": "3 g",
                        "Trans Fat": "0.1 g"
                    }
                },
                "heading": "Nutritional Content of Maggi 2-Minute Noodles per 100g"
            },
            {
                "data": {
                    "Nutritional Content": {
                        "Added Sugars": "0 g",
                        "Carbohydrates": "0 g",
                        "Cholesterol": "215 mg",
                        "Energy": "717 kcal",
                        "Protein": "0.9 g",
                        "Saturated Fat": "51 g",
                        "Sodium": "714 mg",
                        "Total Fat": "81 g",
                        "Total Sugars": "0 g",
                        "Trans Fat": "3 g"
                    }
                },
                "heading": "Nutritional Content of Amul Butter per 100g"
            }
        ]
    }
    ```
    
7. Now, we can ask questions using the `/query` endpoint as shown below, with all chat history stored and tracked for context awareness:
    
    ```json
    {
        "query": "What should I take for protien?"
    }
    ```
    

## A conversation session example

**Q1— What should I take for protien?**

> Here are the protein contents of the given foods:
> 
> 1. Cadbury Dairy Milk Silk Oreo - 6.1 g
>     
> 2. Lays Classic Salted Chips - 7 g
>     
> 3. Coca-Cola - 0 g
>     
> 4. Maggi 2-Minute Noodles - 9 g
>     
> 5. Amul Butter - 0.9 g
>     
> 
> To meet your protein needs, consider options like Maggi 2-Minute Noodles, Lays Classic Salted Chips, or Cadbury Dairy Milk Silk Oreo. However, please keep in mind your hypertension and diabetes; I will provide more tailored suggestions if needed.

**Q2— Is it okay to have it in terms of fat content?**

> Considering your hypertension and diabetes, let's evaluate the fat content of the high-protein options:
> 
> 1. Maggi2-Minute Noodles - 17 g (Total Fat), 8.1 g (Saturated Fat)
>     
> 2. Lays Classic Salted Chips - 34 g (Total Fat), 3.3 g (Saturated Fat)
>     
> 3. Cadbury Dairy Milk Silk Oreo - 34.85 g (Total Fat), 21.15 g (Saturated Fat)
>     
> 
> To manage your condition, it's essential to balance your fat intake. Lays Classic Salted Chips and Cadbury Dairy Milk Silk Oreo have high fat content. Maggi2-Minute Noodles seem to be a relatively better option, but its sodium content (880 mg) is a concern for hypertension.
> 
> Considering both protein and fat content, Maggi2-Minute Noodles might be a compromise, but please be mindful of its sodium and overall carbohydrate content (60 g) that may impact your diabetes.

**Q3— How much should I consume your recommendation and coke?**

> I can't recommend consuming Coca-Cola due to its high sugar content (10.6 g per 100ml), which can worsen your diabetes.
> 
> For Maggi2-Minute Noodles, considering your hypertension, diabetes, and protein needs, I suggest a moderate serving size. A 100g serving of Maggi2-Minute Noodles provides 9g of protein, 17g of fat, 60g of carbohydrates, and 880mg of sodium.
> 
> To balance your nutrient intake, limit your serving size to 50-70g (approximately half to two-thirds of a standard packet), and consider adding vegetables or protein sources with lower sodium and fat content to make it a more balanced meal.
> 
> Please consult a healthcare professional or registered dietitian for personalized dietary advice.

**Q4— BTW which one is the least harmful?**

> Considering your hypertension and diabetes, I would suggest Lays Classic Salted Chips as the least harmful option among the ones listed.
> 
> It provides 7g of protein and has relatively lower sodium (525mg) compared to Maggi2-Minute Noodles. However, please be mindful of its high fat content (34g) and limit your serving size.
> 
> Keep in mind that it's essential to balance your diet with a variety of nutrient-dense foods and consult a healthcare professional for personalized advice.

## [Future Prospects](https://tuhindutta.github.io/nutriguide/future-prospect)
